Advertisement
Guest User

Untitled

a guest
Aug 20th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $servername = Get-Content 'C:\Users\rholmes\Desktop\ComputerList2.txt'
  2.  
  3. # Check the Latest virus Definition Date
  4.  
  5. $myData = Foreach ($server in $servername) {
  6.     $output = [pscustomobject] @{
  7.         Server = $server
  8.         version = "UNKNOWN"
  9.         LatestVirusDefinitionDate = "UNKNOWN"
  10.         LatestVirusDefinitionRevision = "UNKNOWN"
  11.     }
  12.     Try {
  13.  
  14.         Write-Verbose "Trying to connect to '$server'"
  15.  
  16.         $Reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine',$server)
  17.  
  18.         $key = $Reg.OpenSubKey("SOFTWARE\Symantec\Symantec Endpoint Protection\CurrentVersion")
  19.         $key2 = $Reg.OpenSubKey("SOFTWARE\Symantec\Symantec Endpoint Protection\CurrentVersion\public-opstate")
  20.  
  21.  
  22.         $output.version = $key.getvalue("PRODUCTVERSION")
  23.         $output.LatestVirusDefinitionDate = $key2.getvalue("LatestVirusDefsDate")
  24.         $output.LatestVirusDefinitionRevision = $key2.getvalue("LatestVirusDefsRevision")
  25.  
  26.     } catch {
  27.         # Exception probably indicates that the registry open failed
  28.    
  29.         Write-Error "Error - getting detailed from '$Server' failed"
  30.         Write-Error $_
  31.     }
  32. }
  33.  
  34. $myData | Export-Csv $env:TEMP\mydata.csv
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement