I am trying to write a script that will delete the local profile of the test account. I use the following line to return the SID of any account that starts with "test -"
PowerShell: $UserSID = (Get-WmiObject Win32_UserProfile | Where {$_.LocalPath -like '*\test-*'}).SID
Once I had the SID, I used wmic to remove it, but I'm not sure how to translate this code into PowerShell.
WMIC: wmic /node:"localhost" path win32_UserProfile where Sid="%%b" Delete
source
share