Using Powershell to find unsecured accounts with no passwords
Since it's inclusion in Windows Server 2008 I've been tinkering a lot with Windows Powershell. I rapidly growing to be a convert. Sorry cmd.exe
Anyway, one of the features is that you can use PS to call WMI. Which got me thinking on how to solve a problem I had not so long ago; How to identify whether client machines had previously created accounts with no passwords set.
Here is the short script I wrote to do this.
$machine = "localhost"
foreach ($i in $machine)
{Write-Host "Connecting to" $i "please wait..";
Get-WmiObject -computername $i -class win32_UserAccount |
Select-Object Name, Disabled, PassswordRequired, SID, SIDType |
Where-Object ($_.PasswordRequired -eq 0) |
Sort-Object - property name | Write-Host}
Of course I've left out one vital piece which will prevent you from running this script. This piece you'll have to figure out for yourself. Hint: Execution Policy
Which leads me to the next question: How much should one disclose when talking about security? Would you have put the final piece up to enable this script to be run?