Skip to content

Instantly share code, notes, and snippets.

🌴
On vacation

Rod Stewart rodmhgl

🌴
On vacation
Block or report user

Report or block rodmhgl

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rodmhgl
rodmhgl / Create-PowerShellHere.ps1
Created Jan 9, 2017
Create PowerShell Here Right-Click Explorer Option
View Create-PowerShellHere.ps1
<#
.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
@rodmhgl
rodmhgl / temp.ps1
Last active Dec 15, 2016
Why is remoting slower than running over the network?
View temp.ps1
# 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
@rodmhgl
rodmhgl / Get-RSFileHash.ps1
Last active Nov 17, 2016
Just looking to get input on the best way to handle parameter sets
View Get-RSFileHash.ps1
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
@rodmhgl
rodmhgl / jobdemo.ps1
Last active Nov 8, 2017
Quick PowerShell Jobs Demo
View jobdemo.ps1
# 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
}
@rodmhgl
rodmhgl / gist:19a188c7f48848ed35f2
Last active Sep 17, 2015
Rename Student Names to IDs
View gist:19a188c7f48848ed35f2
Function Create-HashTable {
param ($filePath)
$mytable = Import-Csv -Path $filePath
$HashTable=@{}
foreach($r in $mytable)
{
$HashTable[$r.Name] = $r.ID
}
return $HashTable
}
View gist:3d7b59f25b5c1a5642f7
$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.
View Get-STTinyURL
function Get-STTinyURL {
param(
[Parameter(Mandatory=$true,
ValueFromPipeline=$true,
Position=0)
]
[String[]]$OriginalURL)
Process {
$OriginalURL | ForEach-Object {
View gist:cac3d84c2c918c81c1c1
# 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);
@rodmhgl
rodmhgl / DC_Regex
Created Oct 22, 2013
Regex, extract DC from DN
View DC_Regex
$DN = 'CN=Username,OU=OrganizationalUnit,DC=lab,DC=local'
$pattern = '(?i)DC=\w{1,}?\b'
([RegEx]::Matches($DN, $pattern) | ForEach-Object { $_.Value }) -join ','
@rodmhgl
rodmhgl / Reset-RDPListener
Created Jun 28, 2013
Attempts to reset the RDP listener of a remote server. Sometimes it works, sometimes it doesn't, but it's always worth a shot.
View Reset-RDPListener
function Reset-RDPListener {
param($ComputerName)
$ts = Get-WMIObject -class win32_Terminalservicesetting -comp $ComputerName
$ts.SetAllowTSConnections($false)
$ts.SetAllowTSConnections($true)
}
You can’t perform that action at this time.