Skip to content

Instantly share code, notes, and snippets.

View rodmhgl's full-sized avatar
🐒
Just monkeyin' around

Rod Stewart rodmhgl

🐒
Just monkeyin' around
View GitHub Profile
@rodmhgl
rodmhgl / apiops_lab.py
Last active July 19, 2024 12:05
Creates two simple diagrams using Python
from diagrams import Cluster, Diagram, Edge
from diagrams.azure.general import Usericon, Resourcegroups
from diagrams.azure.compute import ContainerInstances
from diagrams.azure.integration import APIManagement
from diagrams.azure.devops import Devops, Pipelines, Repos
graph_attrs = {
'bgcolor': 'snow2',
'fontsize': '48',
'labelloc': 'top',
@rodmhgl
rodmhgl / setenv.sh
Last active September 6, 2023 22:21
Export environment variables matching a string to a file to be sourced later
#!/usr/bin/env bash
# pilfered from a MSFT AKS tutorial and tweaked
if [ "$#" -ne 2 ]; then
echo "Will export env variables that end with <search_string>"
echo "Usage: $0 <search_string> <output_filename>"
exit 1
fi
@rodmhgl
rodmhgl / Install-Terraform.ps1
Created February 10, 2022 23:18
Downloads and installs Terraform. $tfPath will be added to PATH permanently via registry settings - run as Administrator.
$pathKey = 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment'
$tfFilename = 'terraform_1.1.5_windows_amd64.zip'
$tfURL = "https://releases.hashicorp.com/terraform/1.1.5/$tfFilename"
$tfPath = 'C:\tf'
Invoke-WebRequest $tfURL -UseBasicParsing -OutFile $tfFilename
Expand-Archive ".\$tfFilename" -DestinationPath $tfPath -Force
$oldpath = (Get-ItemProperty -Path $pathKey -Name PATH).path
@rodmhgl
rodmhgl / AssignmentComparison.ps1
Created June 8, 2018 14:11
Demonstrates assigning object collection with Array addition versus Direct Assignment
$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 April 2, 2018 16:02
XPath Troubleshooting
<?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 June 23, 2020 17:23
In-progress PowerShell interface to Pi-hole API - Tested with v3.2
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'
$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 / Show-Blocks.ps1
Created November 7, 2017 00:58
Just demoing Begin, Process, End with some pseudo-code
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 August 17, 2017 15:44
Just playing around
function getSpace {
[cmdletbinding()]
param(
[string]$space = ' ',
[string]$separator = '-',
[int]$depth
)
Write-Output $(($space + $separator) * $depth)
}
@rodmhgl
rodmhgl / Reset-Password.ps1
Last active July 12, 2017 23:41
For James Espinoza - Help Desk script to reset user's password
[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 {