I have the following code:
$versionList = "Windows 2000","Windows XP","Windows Vista","Windows 7","Windows 8","Windows Server 2003","Windows Server 2008","Windows Server 2008 R2","Windows Server 2012","Windows Server 2012 R2"
for($i = 0;$i -ne 10;$i++){
$versionCheck = Get-ADComputer -Filter * -Property * | select OperatingSystem | where {$_.OperatingSystem -match $versionList[$i]}
if($i -eq 0){
Write-Host "Clients:" -for Green
}
if($i -eq 5){
Write-Host "Servers:" -for Green
}
Write-Host $versionList[$i] `t $($versionCheck.OperatingSystem).Count
}
This gives the following output:
Clients:
Windows 2000 0
Windows XP 0
Windows Vista 0
Windows 7 0
Windows 8 0
Servers:
Windows Server 2003 0
Windows Server 2008 0
Windows Server 2008 R2 0
Windows Server 2012 1
Windows Server 2012 R2 0
The numbers for the Server based Operating systems line up fine. The clients not so much. I would normally format this into a table but as the variables get renewed every time the loop runs that would make a lot of tables. How would I go abouts to format this properly?