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,...
Remove First Entry in Fixed Array
Here is a quick little trick for removing the first entry in a fixed size array. This can be used when you receive the error message: Exception calling “RemoveAt” with “1” argument(s): “Collection was of a fixed size.” # Remove first entry $array = $array[1..($array.Length-1)]
Search Intune for Devices with Application Installed
This script uses the GraphAPI to check all devices in Intune to see if they have a particular application installed. $Application = "*PuTTY*" $Username = '[email protected]' Function Get-AuthToken { <# .SYNOPSIS This function is used to authenticate with the Graph API REST interface .DESCRIPTION The function authenticate with the Graph API Interface with the tenant name .EXAMPLE Get-AuthToken Authenticates you...
Run PSExec From PowerShell
PowerShell remoting help in a lot of areas, but there are times when you need to use PSExec. For those instances, I’ve created a function that you can use to run a command on a remote machine using PSExec. Function ExecutePsExec($computer, $command){ $ping = Test-Connection $computer -Count 1 -Quiet if($ping){ $StdOutput = (Join-path $env:temp "$($computer).txt") Start-Process -FilePath $psexec -ArgumentList "-s...
Homework – Double Digit Addition without Carrying
My son decided to pretend to be sick from school the other day, so after we finished all the work the teach gave us, I decided to make him some extra work. This code will generate a page with 25 double digit addition problems. They haven’t learn to carry over digits yet, so all sums are less than 10. Maybe...