PowerShell: Where-Object Cmdlet
A few weeks ago, as I sat at my home-office desk drinking from my cup of coffee (okay… I don’t drink coffee) and reflected on my journey as a Microsoft 365 administrator and what the next few years may have to offer – hmmm… what I have to offer - to aspiring system administrators and organizations – I thought to share some of the small challenges I have dealt with over the years that may benefit the community. So, I committed to starting a series of articles sharing how-to guides, PowerShell cmdlets, and their implementation in simple functional scripts, perspectives on cloud technologies, performance reporting, etc.
Here we go with the first of hopefully many to come.
Starting with the Where-Object cmdlet – I hope someone finds this useful and applicable.
The Where-Object cmdlet is used to select objects that match values from an array of objects.
It is effective in comparing/matching values between different arrays.
Use Case:
A client had a list of Wi-Fi profiles associated with the Enrollment Manager account that was pushed to over 400 workstations via roaming profiles.
This presented several risks which included profile mismanagement and conflict, impact on network performance because of excessive profile data, user tracking etc.
The request was to clean up the Wi-Fi profile on the workstations.
Solution:
Implemented an Intune Remediation using a PowerShell script that checks for any match between an array of the listed Wi-Fi profiles from the Enrollment Manager account and the Wi-Fi profiles on user Windows profiles.
In the post, I will share a short version of the simple script used for remediation.
Script: