Skip to content

Instantly share code, notes, and snippets.

@chipitsine
Created June 10, 2015 12:33
Show Gist options
  • Save chipitsine/ac5e6131b1f16adb33a9 to your computer and use it in GitHub Desktop.
Save chipitsine/ac5e6131b1f16adb33a9 to your computer and use it in GitHub Desktop.
blank passwords
#requires -Modules ActiveDirectory
ipmo ActiveDirectory
cls
$d = (Get-date).AddDays(-30)
$c = Get-ADComputer -Filter { (Enabled -eq $true) -and (PasswordLastSet -ge $d) -and (OperatingSystem -notlike "*Server*")}
$c | % {
[String] $computer = $_.Name
'examining : {0}...' -f $computer
$de = [ADSI]('WinNT://{0}' -f $computer)
$users = $de.psbase.children | where{$_.psbase.schemaClassName -match 'user'} | select @{n='Name';e={$_.name}}
$users | % {
[String] $user = $_.Name
if(([adsi]“WinNT://$computer/$user”).invokeget('AccountDisabled') -eq $false){
try{
([adsi]“WinNT://$computer/$user”).SetPassword('')
'computer: {0,-20} user: {1,-20}' -f $computer, $user
}catch{ }
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment