top of page

PowerShell Get-ADComputer

 

# Small Snippet to Find Computers that have not reported to AD in over 90 days

 

$date = [DateTime]::Today.AddDays(-90)

Get-ADComputer -Filter  ‘PasswordLastSet -le $date’-properties * | Select Name, PasswordLastSet, Enabled | Export-csv C:\temp\Old_Computers.csv 

 

#Query using Searchbase and utilize the Where / Filter

#Where ...

Get-ADComputer -SearchBase 'DC=MyNewForest,DC=LOCAL' -Filter * -Properties * | Select Name,OperatingSystem | Where{$_.OperatingSystem -Like "Windows Server 2019*"}

#-Filter...

Get-ADComputer -SearchBase 'dc=MyNewForest,dc=local' -Filter {(name -like "My*") -and (Enabled -eq $True)} | Select -ExpandProperty Name

bottom of page