Author: Matthew Dowst

General

Display Profile Functions

If you are like me and have multiple machines you work on with different profiles, it can be difficult to remember which profile contains which functions. So, I wrote a quick function that will display all the functions for me on start up. Just add the code below to the bottom of your $profile file. Function Get-ProfileFunctions { $__ProfileFunctions =...
Azure

Start Azure VM and Open Bastion

The following snippet will check if a VM is turned on, and if not start it, then launch the Bastion connection window in Edge. $VM = Get-AzVM -Name 'LN-TCTester-01' -Status if($VM.PowerState -eq 'VM deallocated'){ $VM | Start-AzVM } Start-Process -Path msedge -ArgumentList "https://portal.azure.com/#/resource$($VM.Id)/bastionHost"
Automation

Automation Authoring

When I started writing my book, Practical Automation with PowerShell, I discovered how much time and energy is required to keep everything up to date. For example, if I changed a piece of code in the text, I had to make sure the code sent to the publisher and uploaded to GitHub matched. Not to mention the style guidelines I...
Uncategorized

Compare Images

The following function can be used to compare two pictures based on size and a pixel-by-pixel comparison. Function Compare-Images { param( $ReferenceFile, $DifferenceFile ) $ReferenceImage = [System.Drawing.Bitmap]::FromFile($ReferenceFile) $DifferenceImage = [System.Drawing.Bitmap]::FromFile($DifferenceFile) if ($ReferenceImage.Size -ne $DifferenceImage.Size) { Write-Host "Images are of different sizes" $false } else { # Set the difference to 0 [float]$Difference = 0; # Parse through each pixel for...