I need to find the Internet Explorer version on each of the computers in our domain. I have a powershell script that works if the computer is online but fails if the computer is off line or worse give a false version for that computer. See Script below:
$array =@()
$keyname = 'SOFTWARE\\Microsoft\\Internet Explorer'
$computernames = Get-Content C:\apps\Computer.csv
foreach ($server in $computernames)
{
$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $server)
$key = $reg.OpenSubkey($keyname)
$value = $key.GetValue('Version')
$value1 = $key.GetValue('svcUpdateVersion')
$obj = New-Object PSObject
$obj | Add-Member -MemberType NoteProperty -Name "ComputerName" -Value $server
$obj | Add-Member -MemberType NoteProperty -Name "Base_IEVersion" -Value $value
$obj | Add-Member -MemberType NoteProperty -Name "Updated_IEVersion" -Value $value1
$array += $obj
}
$array | select ComputerName, Base_IEVersion, Updated_IEVersion | export-csv C:\apps\IE_Version.csv
What I was thinking is to add a connection test using the Test-Connection cmdlet. What I would like to happen is if the computer is online and the test-connection returns a "true" the script returns the reg key values and write them to the array but if the computer is not online then the script write the $server variable to the array and moves on. In the end I would then have a list of the computer names and the IE version for those that are online and I could easily see the computers that I would have to revisit. Any ideas?
Alan Schroeder