Created
February 18, 2020 23:31
-
-
Save iyre/91d1d0d623b3e4a4c889e3a17b08642b to your computer and use it in GitHub Desktop.
Get a list of active domain computers
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
$DateOffset = 30 | |
$StartDate = (Get-Date).adddays(-($DateOffset)) | |
$SearchBase = "OU=Domain Computers, DC=contoso, DC=com" | |
Get-ADComputer -Filter { | |
( LastLogonDate -gt $StartDate ) -and | |
( Name -ne "$env:COMPUTERNAME" ) | |
} -SearchBase $SearchBase -Properties LastLogonDate | | |
Sort-Object -Property LastLogonDate | | |
Format-Table -Property Name, LastLogonDate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment