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...
PowerShell Weekly Redesign!
I am pleased to announce that PowerShell Weekly has been redesigned and moved to its own sub-site psweekly.dowst.dev. All past posts and links are available there as well. What’s New New look and feel Thumbnails for every link Improved searching of the 2,000+ links Search by keyword, date, author, category Custom RSS Feed specifically the links
2021: A PowerShell Year in Review
2021 was quite the year for PowerShell. We saw a lot of first and improvements in the platform. Not just from Microsoft but the community as a whole. I also personally hit a few milestones. First and foremost, happy 15th birthday to PowerShell. This year was also a huge year for me. My book Practical Automation with PowerShell was released...
Find Java Based Azure App Services
A quick Azure PowerShell command to locate any Java based Azure App Services and Functions so you can check if they are vulnerable to the CVE-2021-44228 Apache Log4j2 vulnerability. Get-AzWebApp | ForEach-Object{ Get-AzWebApp -ResourceGroupName $_.ResourceGroup -Name $_.Name | Select-Object -Property Name, @{l='JavaVersion';e={$_.SiteConfig.JavaVersion}}, ResourceGroup, Id } | Format-Table
Practical Automation with PowerShell
After months and months of work, I’m proud to announce my new book is now available for purchase. Practical Automation with PowerShell reveals how you can use PowerShell to build automation solutions for a huge number of common admin and DevOps tasks. It takes you beyond scripting basics and shows you how to handle the unforeseen complexities that can keep...
Quick and Easy Password Generator
This is a quick and easy password/random character generator. It returns random numbers between 33 and 126 and converts the number to the corresponding ASCII character. $password = [string]::Empty 1..32 | ForEach-Object { $password += [char]$(33..126 | Get-Random) }
Resubmit Azure Automation Runbook Job
This snippet will allow you to re-run any Azure Automation Runbook job with the same parameters and in the same context (Azure or Hybrid Worker Group). # Set the variables from the previous job $AutomationAccountName = '' $ResourceGroupName = '' $JobId = '' # Get the previous job $AutoAccount = @{ AutomationAccountName = $AutomationAccountName ResourceGroupName = $ResourceGroupName } $PreviousJob =...
Copy Azure Permissions
I was replacing an old service account with a service principal, and needed to replicate the permissions in Azure. I was able to do that without missing anything, using the command below. $CopyFrom = 'Object to copy from' $CopyTo = 'Object to copy to' Get-AzRoleAssignment -ObjectId $CopyFrom | ForEach-Object{ New-AzRoleAssignment -ObjectId $CopyTo -RoleDefinitionId $_.RoleDefinitionId -Scope $_.Scope }
Reboot remote computer and wait
This script that will send a reboot command to a remote computer. It will then monitor for it to go offline and then come back online. Optionally, you can have it monitor for a service to return to running. # The remote computer to reboot $computer = 'YourComputer' # the name of a service to check for after reboot $Service...
Testing and Deploying ARM Templates
I often find that when building an ARM template, I need to test it multiple times. So, I created the script below that will create the resource group (is it doesn’t exist), run the test cmdlet (and stop if there is a problem), and deploy the template to Azure. It will create a new name for the deployment each time...