I\'m writing a script to check the version on about 15 remote servers and the script is taking much longer to execute than I would expect.
$listServers = @(\"com
Queries against Win32_Product
trigger a reconfiguration of installed packages, which is what makes the process so time-consuming. It also makes such queries potentially harmful, since it may inadvertently reset configuration parameters.
For something like a version check on a particular program you're better off reading the information directly from the (remote) registry:
$listServers | % {
$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $_)
$key = $reg.OpenSubKey('SOFTWARE\JavaSoft\Java Runtime Environment')
New-Object -Type PSObject -Property @{
'Server' = $_
'JavaVersion' = $key.GetValue('CurrentVersion')
}
} | Export-Csv 'C:\temp\javaVersion.csv' -NoType