Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #https://blogs.technet.microsoft.com/ashleymcglone/2014/01/29/use-powershell-to-find-windows-xp-computers-still-alive-in-your-active-directory-domain/
- Import-Module ActiveDirectory
- $XP = Get-ADComputer -Filter {OperatingSystem -like "*XP*"} `
- -Properties Name, DNSHostName, OperatingSystem, `
- OperatingSystemServicePack, OperatingSystemVersion, PasswordLastSet, `
- whenCreated, whenChanged, LastLogonTimestamp, nTSecurityDescriptor, `
- DistinguishedName |
- Where-Object {$_.whenChanged -gt $((Get-Date).AddDays(-90))} |
- Select-Object Name, DNSHostName, OperatingSystem, `
- OperatingSystemServicePack, OperatingSystemVersion, PasswordLastSet, `
- whenCreated, whenChanged, `
- @{name='LastLogonTimestampDT';`
- Expression={[datetime]::FromFileTimeUTC($_.LastLogonTimestamp)}}, `
- @{name='Owner';`
- Expression={$_.nTSecurityDescriptor.Owner}}, `
- DistinguishedName
- $XP | Out-GridView
- $XP | Export-CSV .\xp.csv
- ($XP | Measure-Object).Count
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement