Created
July 17, 2018 17:36
-
-
Save h3nryza/69608ccd3f815d0e101ea008a52beb9e to your computer and use it in GitHub Desktop.
Powershell AD users and computer last reset in the x days
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Import-Module *Active* | |
| #Windows 7, Enabled, Last 35Days | |
| get-adcomputer -filter * -properties * | select DNSHostName,OperatingSystem,Enabled,@{N='pwdLastSet'; E={[DateTime]::FromFileTime($_.pwdLastSet)}}| where{$_.pwdLastSet -ge (get-date).adddays(-60) -and $_.OperatingSystem -like "*7*" -and $_.enabled -like "*True*"} | export-csv ADComputers.csv | |
| #Servers, Enabled, Last 35Days | |
| get-adcomputer -filter * -properties * | select DNSHostName,OperatingSystem,Enabled,@{N='pwdLastSet'; E={[DateTime]::FromFileTime($_.pwdLastSet)}}| where{$_.pwdLastSet -ge (get-date).adddays(-60) -and $_.OperatingSystem -like "*Server*" -and $_.enabled -like "*True*"} | export-csv ADServers.csv | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Import-Module *Active* | |
| Get-ADuser -Filter {UserPrinciplieName -like "**"} -prop * | Select isDeleted,enabled,CN,displayName,description, @{n="lastLogonDate";e={[datetime]::FromFileTime($_.l)}},{n="lastLogonDate";e={[datetime]::FromFileTime($_.lastLogonTimestamp)}}, @{n="pwdLastSet";e={[datetime]::FromFileTime($_.pwdLastSet)}},sid,department,employeeID,mail,tel | where{$_.pwdLastSet -ge (get-date).adddays(-60)} | export-csv ADUsers.csv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment