Run this from an account which has access to all servers in the list.
# Get .NET Version and PowerShell Versions for all computers in AllComputersList.
#
$remoteCommand = @"
Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -recurse |
Get-ItemProperty -name Version,Release -EA 0 |
Where { `$_.PSChildName -match '^(?!S)\p{L}'} | sort Version -Descending |
Select-Object -first 1 -ExpandProperty Version
"@
$VersionReport = @()
$AllComputersList |%{
$CurrentServer = $_
$dotNetVersion = $(Invoke-Command -Computername $CurrentServer -Scriptblock $ScriptBlock -ErrorAction SilentlyContinue)
$PsVersion = $(Invoke-Command -Computername $CurrentServer -Scriptblock {$PSVersionTable.psversion} -ErrorAction SilentlyContinue)
$os = Get-WmiObject -class Win32_OperatingSystem -computername $CurrentServer
$Versions = [pscustomobject]@{
Computer = $CurrentServer
NETVersion = $dotNetVersion
PSVersion = $PsVersion
OSVersion = $os.Version + "`t" + $os.Caption
}
$VersionReport += $Versions
Write-Host "$(Get-Date -Format g) [$CurrentServer] `t.NET Version $dotNetVersion `tPSVersion $PsVersion `t$($os.Version)"
}
$VersionReport | sort PSVersion,Computer |Out-GridView
