Hello, having a script which will query FEP installation and Signature version on remote computers
If the computers are online and everything works, there is no problm.
How to deal with exceptions like
ItemNotFoundException, PSRemotingTransportException (Access to the server denied), PSremoting not enabled ..
I would like to have output like
name;Product;Version;ErrorHandling
server1;;;AccessDenied
server2;;;ItemNotFound
server3;Microsoft Forefront Endpoint Protection;1.175.2096.0;
server4;;;ItemNotFound
server5;;;ServerOffline
Please guide me how to these exceptions into $errorhandling variableParam ([int]$BatchSize=20) #list of servers [array]$source = (get-adcomputer -filter {operatingsystem -like "Windows server*" -and name -like "s*exf*"}) |select -expandproperty dnshostname #scriptblock $blok = { $mycol = @() $AVSignatureVersion = Get-ItemProperty 'hklm:\SOFTWARE\Microsoft\Microsoft Antimalware\Signature Updates\' |select -Expandproperty AvSignatureVersion $ProductName = Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* |?{$_.displayname -like "*Microsoft Forefront Endpoint*" -and ($_.installLocation)} |select -ExpandProperty Displayname $MyObject = New-Object PSObject -Property @{ AVSignatureVersion = $AVSignatureVersion ProductName = $ProductName ErrorHandling =
} $mycol += $MyObject $mycol } $i = 0 for ($i=0; $i -lt $itemCount;$i += $batchSize){ $activeJobCount += 1; $totalJobCount += 1; $HostList = @() $HostList += $source |select -skip $i -first $batchsize $j = invoke-command -computername $Hostlist -scriptblock $blok -asjob }
.. and.. i guess, some errors are getting inside scriptblock ([ItemNotFound]) and others like [accessDenied] outside? So, is it possible to get the job exception into $myCol?