This file contains 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 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 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 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 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 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 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 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. |
This file contains 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-STTinyURL { | |
param( | |
[Parameter(Mandatory=$true, | |
ValueFromPipeline=$true, | |
Position=0) | |
] | |
[String[]]$OriginalURL) | |
Process { | |
$OriginalURL | ForEach-Object { |
This file contains 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
# Courtesy of /u/LordZillion from /r/PowerShell | |
$Users = Import-Csv -Path C:\Temp\AllTheUsers.csv | |
$HashTable = @{} | |
Foreach($User in $Users) { | |
[int]$HashTableReference = $User.ExternalID | |
$HashTable[$HashTableReference] += New-Object -TypeName PSObject -Property @{ | |
'UserName' = ($User.UserName); | |
'Password' = ($User.Password); | |
'Email' = ($User.Email); |