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...
Apply CVE-2020-1350 Workaround to Remote Computer
A patch has been released for the security vulnerability CVE-2020-1350, which has a 10 out of 10 on the CVSS scale and affects all Windows DNS servers from 2003 to 2019. However, since not everyone can patch systems right away, Microsoft has provided a workaround. The workaround restricts the size of DNS response packets, which only requires a restart of...
Parse Email Address
You can use this snippet to parse an email address and extract the different components of it. (Tip. It works for UPNs too) New-Object "System.Net.Mail.MailAddress" -ArgumentList $emailAddress
View All Scheduled Tasks in a Single Pane
Get-ScheduledTask | Select-Object * | Out-Gridview Source: Guy Leech
List all Devices in Device Manager
Get-WmiObject Win32_PNPEntity | Sort-Object -Property PNPClass | Format-Table Name, PNPClass, DeviceID, Manufacturer, Status Source: Thorsten E.
A Quick Lesson in Boolean
I often see scripts that are checking for True/False values using an If/Else statement like the one below. While this technically will work for Boolean values, there are situations where this will not work. For example, if you pass the string value of “False” to the statement above it will evaluate as True. This is because the if condition in...
Fast Deploy Microsoft Teams for Education
Recently one of my colleagues came to me with an interesting situation. His wife runs a homeschool co-op. Basically, a group of parents who homeschool their children, with different parents covering different subjects. Due to COVID-19, he needed a quick way to get them setup in Office 365 and Teams. So, I put together a quick upload script to import...
Properly Capitalize a Title Using PowerShell
Being married to someone who majored in English has made me extra conscious of my spelling and capitalization. So, for my blog posts, I’ve written a script to help me ensure my titles are properly capitalized. It is not perfect (i.e. it doesn’t do a dictionary lookup), but it follows the basic APA guidelines. I thought I would share it,...
