Skip to content

Instantly share code, notes, and snippets.

@toburger
Created December 6, 2012 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toburger/4225016 to your computer and use it in GitHub Desktop.
Save toburger/4225016 to your computer and use it in GitHub Desktop.
param ([string]$ComputerName = '*')
begin {
filter Check-Online {
trap { continue }
. {
$timeout = 1000
$obj = New-Object system.Net.NetworkInformation.Ping
$result = $obj.Send($_, $timeout)
if ($result.status -eq 'Success') { $_ }
}
}
}
end {
$pcs = get-adcomputer -filter * | ? Name -like $ComputerName
$pcs | % {
$machinename = $_.Name
if (-not ($machinename | Check-Online)) {
new-object pscustomobject -Property @{
ComputerName = $machinename;
Version = 'offline'
}
} else {
try {
$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $MachineName)
$regKey = $reg.OpenSubKey('SOFTWARE\Microsoft\Silverlight')
$version = $regKey.GetValue('Version')
new-object pscustomobject -Property @{
ComputerName = $machinename;
Version = [Version]$version;
}
} catch [UnauthorizedAccessException] {
new-object pscustomobject -Property @{
ComputerName = $machinename;
Version = 'unauthorized';
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment