A script that finds accounts with no password allowed and changes the flag
#Looks for user accounts with no password allowed and changes it
#timestamp function
filter timestamp {"$(get-date -Format G): $_"}
#get script name
$scriptname = $MyInvocation.MyCommand.Name
#output file
$log = ".\$($scriptname).csv"
#test for log file
if (!(test-path $log)) { New-Item -Path $log | Out-Null}
else { clear-content -path $log -Force }
##================================================
get-aduser -filter * -properties * | select-object samaccountname,useraccountcontrol | ForEach-Object {
if ($_.useraccountcontrol -eq "544") {
write-output "$($_.samaccountname) - $($_.useraccountcontrol)"
#Add-Content -path $log "$($_.samaccountname),$($_.useraccountcontrol)"
set-adaccountcontrol $_.samaccountname -PasswordNotRequired $false
}
}
Edited by browolf

1 Comment
Recommended Comments
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now