Again… why was this seemingly so difficult to Google/Bing… I frequently have to write PowerShell code where I need to get the profiles on the computer and then manipulate it somehow… so I noticed that there’s a property in the Win32_Userprofile class called “Special” which returns “True” when it’s a system profile. I was trying all kinds of pipe options to Where-object but couldn’t get it… then finally stumbled upon the answer below:
<# This PowerShell script will show you how to get a list of profiles on the computer WITHOUT including the special system profile #> # Save the profiles to an array for parsing $ProfileList = gwmi Win32_Userprofile -filter "Special = 'False'" # or you can enumerate the profiles directly gwmi Win32_Userprofile -filter "Special = 'False'" # What I did was just assign the result set into the array # and then used the following ForEach ($User in $ProfileList) { $UserPath = $User.LocalPath <#-- Do something here #> }
