Advertisement
Guest User

Untitled

a guest
Jun 18th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. $machines = Get-ADComputer -SearchBase "DOMAIN OU" -Filter {Enabled -eq $true} | Foreach {$_.DNSHostName}
  2. $Output=ForEach ($System in $Machines) {
  3. $app = $null
  4. $ServerStatus = "Unreachable"
  5. $AppStatus = "Presense Unknown"
  6.  
  7. if (test-Connection -ComputerName $System -BufferSize 16 -Count 1 -ea 0 -Quiet)
  8. {
  9. $ServerStatus = "Online"
  10. $app = Get-WMIObject -Class win32_product -Filter {Name like "Sophos Anti-Virus"} -ComputerName $System
  11.  
  12. if($app) {
  13. $AppStatus = "Present"
  14. } else {
  15. $AppStatus = "Not Present"
  16. }
  17. }
  18.  
  19. if($app) {
  20. $app | Select-Object -Property @{n="ComputerName";e={$System}},@{n="ServerStatus";e={$ServerStatus}},@{n="AppStatuName";e={$AppStatus}},Name,Version
  21. } else {
  22. "" | Select-Object -Property @{n="ComputerName";e={$System}},@{n="ServerStatus";e={$ServerStatus}},@{n="AppStatuName";e={$AppStatus}},Name,Version
  23. }
  24. }
  25.  
  26. $output | Export-csv -NoTypeInformation C:\Output.csv
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement