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 / 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
rodmhgl / Data.xml
Last active Apr 2, 2018
XPath Troubleshooting
View Data.xml
<?xml version="1.0" encoding="utf-8"?>
<bpr:release xmlns:bpr="http://www.blueprism.co.uk/product/release">
<bpr:name>BPRelease v3</bpr:name>
<bpr:release-notes>
</bpr:release-notes>
<bpr:created>2018-03-31 04:20:16Z</bpr:created>
<bpr:package-id>4</bpr:package-id>
<bpr:package-name>BPRelease_Info Troubleshooting</bpr:package-name>
<bpr:user-created-by>admin</bpr:user-created-by>
<bpr:contents count="2">
@rodmhgl
rodmhgl / Invoke-PiHoleApi.ps1
Last active Dec 14, 2017
In-progress PowerShell interface to Pi-hole API - Tested with v3.2
View Invoke-PiHoleApi.ps1
Function Invoke-PiHoleApi {
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = "High"
)]
param(
[ValidateSet('type', 'version', 'summaryRaw', 'summary', 'overTimeData10mins', 'recentBlocked', 'topItems', 'getQuerySources', 'getForwardDestinations', 'getQueryTypes', 'getAllQueries', 'enable', 'disable')]
[String]$Method = 'summary',
[String]$Token = 'a67cc2dccc636ec92842101cc4de47a8c8132e6688415b8a2d7230c2142db2a6',
[String]$Address = '192.168.1.18'
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
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 / 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 {
param(
[Parameter(
Mandatory = $true,
ValueFromPipelineByPropertyName = $true,
ValueFromPipeline = $true
)][String[]]$Username
@rodmhgl
rodmhgl / getSpace.ps1
Last active Aug 17, 2017
Just playing around
View getSpace.ps1
function getSpace {
[cmdletbinding()]
param(
[string]$space = ' ',
[string]$separator = '-',
[int]$depth
)
Write-Output $(($space + $separator) * $depth)
}
@rodmhgl
rodmhgl / Reset-Password.ps1
Last active Jul 12, 2017
For James Espinoza - Help Desk script to reset user's password
View Reset-Password.ps1
[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 {
@rodmhgl
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 {
<#
.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
@rodmhgl
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": [
"-ExecutionPolicy",
"Unrestricted",
"Merge-Script -Script '${file}' -Bundle -OutputPath '${fileDirname}\\out' -OutputType Script;",
You can’t perform that action at this time.