# Zuerst installieren wir das notwendige Powershell-Modul
Install-Module -Name DotNetVersionLister -Scope CurrentUser -Force
# Skript zur Abfrage der Versionen auf allen oder definierten Systemen
#$ComputerName = Get-ADGroupMember -Identity SomeComputerObjectGroup | Select-Object -ExpandProperty Name
#$ComputerName = Get-ADComputer -Filter * -Propert Name | Select-Object -ExpandProperty Name
$ComputerName = @(‘DC2′,’SRVSUBCA’,’SRVRDP’,’SRVEX’)
Import-Module -Name DotNetVersionLister -ErrorAction Stop
$DotNetVersionsHash = @{}
foreach ($Computer in $ComputerName) {
$DotNetVersion = Get-DotNetVersion -ComputerName $Computer -PSRemoting -ContinueOnPingFail -NoSummary
if ($DotNetVersion -and -not $DotNetVersion.Error) {
if ($DotNetVersion.’>=4.x’ -match ‘\S’ -and $DotNetVersion.’>=4.x’ -notmatch ‘error|not installed|universe’) {
$DotNetVersionsHash[$Computer] = $DotNetVersion.’>=4.x’
}
elseif ($DotNetVersion.’v4\Client’ -eq ‘Installed’ -or $DotNetVersion.’v4\Full’ -eq ‘Installed’) {
$DotNetVersionsHash[$Computer] = ‘4.0’
}
elseif ($DotNetVersion.’v3.5′ -eq ‘Installed’) {
$DotNetVersionsHash[$Computer] = ‘3.5’
}
elseif ($DotNetVersion.’v3.0′ -eq ‘Installed’) {
$DotNetVersionsHash[$Computer] = ‘3.0’
}
elseif ($DotNetVersion.’v2.0.50727′ -eq ‘Installed’) {
$DotNetVersionsHash[$Computer] = ‘2.0’
}
else {
$DotNetVersionsHash[$Computer] = ‘<2.0’
}
}
else {
$DotNetVersionsHash[$Computer] = ‘Error’
}
}
$DotNetVersionsHash.GetEnumerator() | Format-Table -AutoSize