Using Powershell to find unsecured accounts with no passwords

Published 12 April 08 12:17 AM | nking 

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?

Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

No Comments

Leave a Comment

(required) 
(optional)
(required) 

  
Enter Code Here: Required

Search

This Blog

Syndication

Page view tracker