samiam41
asked on
Place stale user accounts into "dormant" OU
Hey Experts. I'm cutting my teeth on PowerShell and wanted some help building this new script.
I'd like the script to disable user accounts that haven't been logged into for 30 or more days. After disabling it, move it to the "dormant" ou. Finally output which account(s) were disabled and moved.
Again, pretty new to PowerShell and would appreciate your help! Thank you experts!
Here is what I've come up with so far but needs tweaking.
I'd like the script to disable user accounts that haven't been logged into for 30 or more days. After disabling it, move it to the "dormant" ou. Finally output which account(s) were disabled and moved.
Again, pretty new to PowerShell and would appreciate your help! Thank you experts!
Here is what I've come up with so far but needs tweaking.
Search-ADAccount -accountinactive -timespan 30 -usersonly -SearchBase "ou=depts,dc=domain"|ft name,userprincipalname,lastlogondate,DistinguishedName|out-file C:\tools\Logs\logon-ad-user.log
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for your help!!
ASKER