Skip to content

Instantly share code, notes, and snippets.

@ciphertxt
Created December 22, 2015 16:16
Show Gist options
  • Select an option

  • Save ciphertxt/e59f7b8df494a09bc715 to your computer and use it in GitHub Desktop.

Select an option

Save ciphertxt/e59f7b8df494a09bc715 to your computer and use it in GitHub Desktop.
#requires -Version 2 -Modules ActiveDirectory
Get-ADOrganizationalUnit -Filter * |
ForEach-Object {
$OU = $_
Get-ADComputer -Filter * -SearchBase $OU.DistinguishedName -SearchScope SubTree -Properties Enabled, OperatingSystem |
Where-Object { $_.Enabled -eq $true } |
Group-Object -Property OperatingSystem -NoElement |
Select-Object -Property Count, Name, OU, OUDN |
ForEach-Object {
$_.OU = $OU.Name
$_.OUDN = $OU.DistinguishedName
$_
}
} |
Out-GridView
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment