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
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);
View Get-STTinyURL
function Get-STTinyURL {
Process {
$OriginalURL | ForEach-Object {
View gist:3d7b59f25b5c1a5642f7
$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.
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
foreach($r in $mytable)
$HashTable[$r.Name] = $r.ID
return $HashTable
rodmhgl / Get-SAMAccountName
Created Jun 28, 2013
PowerShell snippet - requires Quest AD Tools - will search Active Directory for the given Display Name, and return the samaccountname, display name, office, and telephone number for matching users
View Get-SAMAccountName
function Get-SamAccountName {
param ($DisplayName)
Get-QADUser -DisplayName "*$DisplayName*" | select samaccountname, displayname, office, telephonenumber
rodmhgl / Get-RealName
Created Jun 28, 2013
PowerShell - Searches Active Directory for a given SAMAccountName, returns SAMAccountName, displayname, office, telephonenumber
View Get-RealName
function Get-RealName {
param ($SAMAccountName)
Get-QADUser -SamAccountName $SAMAccountName | select samaccountname, displayname, office, telephonenumber
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 {
$ts = Get-WMIObject -class win32_Terminalservicesetting -comp $ComputerName
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 / 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 {
Returns an MD5 filehash when given a file path
Returns an MD5 filehash when given a file path
Get-RSFileHash -Filename c:\temp\filetohash.txt
Get-ChildItem c:\temp\*.txt | get-rsfilehash
rodmhgl / temp.ps1
Last active Dec 15, 2016
Why is remoting slower than running over the network?
View temp.ps1
# Remote Code
$SB = {
$SHA1 = New-Object -TypeName System.Security.Cryptography.SHA1CryptoServiceProvider
$stream = []::Open($file, [System.IO.FileMode]::Open, [System.IO.FileAccess]::Read)
$hash = [System.BitConverter]::ToString($SHA1.ComputeHash($stream))
$hash = $hash.replace('-','')
$hash = "0x$hash"
return $hash
You can’t perform that action at this time.