last logon server user account over 400 days
Search-ADAccount -UsersOnly -AccountInactive -TimeSpan 400 | ?{$_.enabled -eq $True} | Get-ADUser -Properties Name, sAMAccountName, givenName, sn | Select Name, sAMAccountName, givenName, sn
---------------------------------------------------------------------------------------------------------
Fine tune script over 400 days
Search-ADAccount -UsersOnly -AccountInactive -TimeSpan 400 | Get-ADUser -Properties Name, sAMAccountName, givenName, sn | Select Name, sAMAccountName, givenName, sn > c:\report\test1.txt
Search-ADAccount -UsersOnly -AccountInactive -TimeSpan 400 | Get-ADUser -Properties Name, sAMAccountName, givenName, sn | Select Name, sAMAccountName, givenName, sn | export-csv c:\report\test1.csv
-------------------------------------------------------------------------------------------------------
since day
Search-ADAccount -AccountInactive -DateTime 10/15/2015 | where {$_.ObjectClass -eq 'user'} | FT Name,ObjectClass –A > c:\temp\xxx.txt
-----------------------------------------------------------------------------------------------------
Base OU finding incative account
Search-ADAccount -UsersOnly -SearchBase "OU=Students,OU=SCS Users,DC=scs,DC=local" -AccountInactive -TimeSpan 400 | Get-ADUser -Properties Name, sAMAccountName, givenName, sn | Select Name, sAMAccountName, givenName, sn > c:\temp\test1.txt
"OU=Students,OU=SCS Users,DC=scs,DC=local"
沒有留言:
張貼留言