Created
February 7, 2022 03:09
-
-
Save SweetAsNZ/fe1eeb0628ca490fe9264eac195644b6 to your computer and use it in GitHub Desktop.
Get All Server OS's For AD Joined Enabled Servers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-ServersOS { | |
Write-Output "Enabled Computer Accounts Only" | |
$Servers = Get-ADComputer -Filter * -Properties Name,OperatingSystem,Enabled -ResultSetSize 1000000 | | |
Where-Object {$_.OperatingSystem -like "Windows Server*"} | Select-Object Name,Enabled,OperatingSystem | Sort-Object Name | |
( $Servers | Where {($_.Enabled -eq $true)} ).OperatingSystem | Sort-Object | Get-Unique -AsString | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment