This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[cmdletbinding()] | |
param( | |
# Give the user the opton to user a -User command line parameter | |
[string]$User = $(Read-Host "Enter a samAccountName") | |
) | |
# Show $User details on console | |
# Consider which properties you actually need | |
# Using * is a memory hog and unnecesary | |
try { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Get-GitTip { | |
<# | |
.SYNOPSIS | |
Grabs a random tip from the Git-Tips Github repository | |
.DESCRIPTION | |
Grabs a random tip from the Git-Tips Github repository | |
Designed to be used as part of my $profile to receive a daily tip | |
.PARAMETER URI |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.1.0", | |
"tasks": [ | |
{ | |
"taskName": "build", | |
"command": "powershell", | |
"args": [ | |
"-ExecutionPolicy", | |
"Unrestricted", | |
"Merge-Script -Script '${file}' -Bundle -OutputPath '${fileDirname}\\out' -OutputType Script;", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Export-Log { | |
<# | |
.Synopsis | |
Writes tab-separated log messages to a specified file. | |
.DESCRIPTION | |
Writes tab-separated log messages to a specified file. | |
.EXAMPLE | |
Export-Log -messagetype ERROR -logfile c:\temp\log.csv -message "Encountered error performing operation." | |
Will log an error message to the log located in c:\temp\log.csv | |
.EXAMPLE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Creates a right-click (or shift right-click) explorer menu option to open Powershell at the selected location | |
.DESCRIPTION | |
Creates a right-click (or shift right-click) explorer menu option to open Powershell at the selected location | |
.EXAMPLE | |
.\Create-PowerShellHere.ps1 | |
Will create a right-click menu with the default text, "Open PowerShell Here" | |
.EXAMPLE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Remote Code | |
$SB = { | |
param($file) | |
$SHA1 = New-Object -TypeName System.Security.Cryptography.SHA1CryptoServiceProvider | |
$stream = [System.io.file]::Open($file, [System.IO.FileMode]::Open, [System.IO.FileAccess]::Read) | |
$hash = [System.BitConverter]::ToString($SHA1.ComputeHash($stream)) | |
$hash = $hash.replace('-','') | |
$hash = "0x$hash" | |
$stream.Close() | |
return $hash |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-RSFileHash { | |
<# | |
.Synopsis | |
Returns an MD5 filehash when given a file path | |
.DESCRIPTION | |
Returns an MD5 filehash when given a file path | |
.EXAMPLE | |
Get-RSFileHash -Filename c:\temp\filetohash.txt | |
.EXAMPLE | |
Get-ChildItem c:\temp\*.txt | get-rsfilehash |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# functions.ps1 contains functions like Get-Services, Get-Process, | |
# Get-CustomFunction1, Get-CustomFunction2, etc. that execute | |
# locally on the remote computer. Output is ex | |
function Get-CustomFunction { | |
sleep 2 | |
write-output $true | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Create-HashTable { | |
param ($filePath) | |
$mytable = Import-Csv -Path $filePath | |
$HashTable=@{} | |
foreach($r in $mytable) | |
{ | |
$HashTable[$r.Name] = $r.ID | |
} | |
return $HashTable | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$buttonStartJob_Click={ | |
$buttonStartJob.Enabled = $false | |
#Create a New Job using the Job Tracker | |
Add-JobTracker -Name "JobName" ` | |
-JobScript { | |
#-------------------------------------------------- | |
#TODO: Set a script block | |
#Important: Do not access form controls from this script block. |