Skip to content

Instantly share code, notes, and snippets.

Get-AdComputer -Filter * -Property * -SearchBase 'OU=PhysicalSpace,OU=LabMachines,OU=Computers,OU=Unit,DC=fabrikam,DC=com' | Select-Object Name, IPv4Address | Export-CSV .\PhysicalSpace-ADComputers.csv -NoTypeInformation -Encoding UTF8
@zaskem
zaskem / QueryMachines.ps1
Created January 12, 2020 19:09
Query Workstations in AD by Name Prefix
Get-ADComputer -Filter 'Name -like "MNS*"' -Property * | Select-Object Name, Description, DistinguishedName, OperatingSystem, OperatingSystemVersion, @{n='LastLogonTimeStamp';e={[DateTime]::FromFileTime($_.LastLogonTimeStamp)}}, WhenCreated, IPv4Address | Export-CSV .\WorkstationsLikeMNS.csv -NoTypeInformation -Encoding UTF8