How to get Active Directory Computer’s info via Powershell?

Import-Module activedirectory

 

Get the list of computers whose last password set in the network from TODAY to next 3 years. (look -ge switch)

$old = (Get-Date).AddDays(-1095)
Get-ADComputer -Filter 'PasswordLastSet -ge $old' -Properties * | Sort PasswordLastSet | FT Name,PasswordLastSet,LastLogonDate,IPv4Address -Autosize

 

Get the list of computers whose last password set in the network for 4 years back. (look -lt switch)

$old = (Get-Date).AddDays(-1460)
Get-ADComputer -Filter 'PasswordLastSet -lt $old' -Properties * | Sort PasswordLastSet | FT Name,PasswordLastSet,LastLogonDate,IPv4Address -A

Get-ADComputer -Filter 'Name -like "IT-*"' -Properties * | Sort PasswordLastSet | FT Name,PasswordLastSet,LastLogonDate,IPv4Address -Wrap -Auto | Out-File C:\Temp\ComputerLastLogonDate.txt

 

References:

http://www.oxfordsbsguy.com/2014/04/28/powershell-get-adcomputer-to-retrieve-computer-last-logon-date-part-1/

http://www.oxfordsbsguy.com/2014/11/20/powershell-get-adcomputer-to-retrieve-computer-last-logon-date-and-disable-them-part-2/

https://www.experts-exchange.com/questions/23688535/How-do-I-Disable-Multiple-Computer-Accounts-via-Script-Batch-File.html

http://woshub.com/get-adcomputer-getting-active-directory-computers-info-via-powershell/

http://www.powershelladmin.com/wiki/Getting_computer_names_from_AD_using_Powershell

https://blogs.technet.microsoft.com/askds/2010/02/04/inventorying-computers-with-ad-powershell/

https://social.technet.microsoft.com/Forums/exchange/en-US/a10c7878-de93-4fb2-9b78-77b99b7bc21d/deleting-multiple-computer-accounts-at-once?forum=winserverDS

Advertisements