All the new user accounts created in Active Directory are kept as disabled and the option "user must change password on next login" is ticked. This accounts will remain as disabled for 7 days and in the 8th day it needs to be enabled.. Creating the account is already done by another script and I am stuck with account enable part.
How can I archive enabling these account using PowerShell script? How to use all account properties like lastlogon date, account creation date, account status(disabled), and the option "user must change password on next login" to validate and find the user is a new user which needs to enable?
Get-ADUser -filter {(enabled -eq $false) -and (pwdLastSet -eq 0) - and -not (lastlogontimestamp -like "*")} -Properties whencreated | Where-Object { $_.whencreated -gt (get-date).adddays(-7) } | select name,SamAccountName,whenCreated | export-csv -path data.csv -NoTypeInformation
The Above command works well to collect the user information.. But if i need to communicate over LDAP (ADSI), how i need to change this code..? I'm totally new to this .. :(