document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #https://blogs.technet.microsoft.com/ashleymcglone/2014/01/29/use-powershell-to-find-windows-xp-computers-still-alive-in-your-active-directory-domain/
  2. Import-Module ActiveDirectory
  3. $XP = Get-ADComputer -Filter {OperatingSystem -like "*XP*"} `
  4.     -Properties Name, DNSHostName, OperatingSystem, `
  5.         OperatingSystemServicePack, OperatingSystemVersion, PasswordLastSet, `
  6.         whenCreated, whenChanged, LastLogonTimestamp,  nTSecurityDescriptor, `
  7.         DistinguishedName |
  8.     Where-Object {$_.whenChanged -gt $((Get-Date).AddDays(-90))} |
  9.     Select-Object Name, DNSHostName, OperatingSystem, `
  10.         OperatingSystemServicePack, OperatingSystemVersion, PasswordLastSet, `
  11.         whenCreated, whenChanged, `
  12.         @{name=\'LastLogonTimestampDT\';`
  13.           Expression={[datetime]::FromFileTimeUTC($_.LastLogonTimestamp)}}, `
  14.         @{name=\'Owner\';`
  15.           Expression={$_.nTSecurityDescriptor.Owner}}, `
  16.         DistinguishedName
  17. $XP | Out-GridView
  18. $XP | Export-CSV .\\xp.csv
  19. ($XP | Measure-Object).Count
');