Skip to content

Instantly share code, notes, and snippets.

On vacation

Rod Stewart rodmhgl

On vacation
View GitHub Profile
rodmhgl / AssignmentComparison.ps1
Created Jun 8, 2018
Demonstrates assigning object collection with Array addition versus Direct Assignment
View AssignmentComparison.ps1
$blah = get-childitem -Path c:\temp -Directory
$AddedTicks = Measure-Command -Expression {
$AddedToArray = @()
foreach ($b in $blah) {
$myOBJ = New-Object System.Object
$myOBJ | Add-Member -Type NoteProperty -Name IsBlah -Value $b.BaseName
$AddedToArray += $myOBJ
} | Select-Object Ticks
rodmhgl / Data.xml
Last active Apr 2, 2018
XPath Troubleshooting
View Data.xml
<?xml version="1.0" encoding="utf-8"?>
<bpr:release xmlns:bpr="">
<bpr:name>BPRelease v3</bpr:name>
<bpr:created>2018-03-31 04:20:16Z</bpr:created>
<bpr:package-name>BPRelease_Info Troubleshooting</bpr:package-name>
<bpr:contents count="2">
rodmhgl / Invoke-PiHoleApi.ps1
Last active Jun 23, 2020
In-progress PowerShell interface to Pi-hole API - Tested with v3.2
View Invoke-PiHoleApi.ps1
Function Invoke-PiHoleApi {
SupportsShouldProcess = $true,
ConfirmImpact = "High"
[ValidateSet('type', 'version', 'summaryRaw', 'summary', 'overTimeData10mins', 'recentBlocked', 'topItems', 'getQuerySources', 'getForwardDestinations', 'getQueryTypes', 'getAllQueries', 'enable', 'disable')]
[String]$Method = 'summary',
[String]$Token = 'a67cc2dccc636ec92842101cc4de47a8c8132e6688415b8a2d7230c2142db2a6',
[String]$Address = ''
View Retrieve-OnlyGroupsFromACL.ps1
$NetBiosName = "DOMAIN"
(Get-Acl c:\temp).Access |
Where-Object {
($_.IdentityReference -split '\\') -eq $NetBiosName
} |
ForEach-Object {
$SAMAccountName = ($_.IdentityReference -split '\\')[1]
$Class =( Get-ADObject -Filter {Samaccountname -eq $SAMAccountName}).objectclass
switch ($Class) {
rodmhgl / Show-Blocks.ps1
Created Nov 7, 2017
Just demoing Begin, Process, End with some pseudo-code
View Show-Blocks.ps1
Function Give-UserLicense ($User) {
#return $true
Function Add-UserLicenses {
Mandatory = $true,
ValueFromPipelineByPropertyName = $true,
ValueFromPipeline = $true
rodmhgl / getSpace.ps1
Last active Aug 17, 2017
Just playing around
View getSpace.ps1
function getSpace {
[string]$space = ' ',
[string]$separator = '-',
Write-Output $(($space + $separator) * $depth)
rodmhgl / Reset-Password.ps1
Last active Jul 12, 2017
For James Espinoza - Help Desk script to reset user's password
View Reset-Password.ps1
# 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 {
rodmhgl / Get-GitTips.ps1
Last active Jun 30, 2017
Grabs a random tip from the Git-Tips Github repository
View Get-GitTips.ps1
Function Get-GitTip {
Grabs a random tip from the Git-Tips Github repository
Grabs a random tip from the Git-Tips Github repository
Designed to be used as part of my $profile to receive a daily tip
rodmhgl / tasks.json
Last active May 23, 2017
I always end up with that one customer who wants me to email them the PS1 file. I've always hated having to do the manual copy and rename, so let's automate it until they get actual source control.
View tasks.json
"version": "0.1.0",
"tasks": [
"taskName": "build",
"command": "powershell",
"args": [
"Merge-Script -Script '${file}' -Bundle -OutputPath '${fileDirname}\\out' -OutputType Script;",
View Export-Log.ps1
function Export-Log {
Writes tab-separated log messages to a specified file.
Writes tab-separated log messages to a specified file.
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
You can’t perform that action at this time.