Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Hotfix scan - Existing script but I want to write out to csv

$
0
0

Hello,

I have a working script that reads in a list of computers and scans them to ensure a hotfix was installed.  I want to make a few modifications to this script:

  • Write out to a csv file.
  • How do I scan for more than one hotfix number?  Currently I use the same variable and run the scan twice.  I would like to scan for either hotfix and write out the hotfix that was found..or write out that neither was found.

Please assist with how I would do this using the following script:

$inputFile = "C:\Powershell_Scripts\hotfixes\servers.txt" $report = @() foreach($CheckComputer in (gc -Path $inputFile)){ if(Test-Connection -ComputerName $CheckComputer -Count 1 -ea 0) { # Define Hotfix to check $CheckHotFixKB = "KB2964358"; #$CheckHotFixKB = "KB2964444";

# Lets Query the computers for the HotFix $HotFixQuery = Get-HotFix -ComputerName $CheckComputer | Where-Object {$_.HotFixId -eq $CheckHotFixKB} | Select-Object -First 1; if($HotFixQuery -eq $null) { Write-Host “Hotfix $CheckHotFixKB is not installed on $CheckComputer”; } else { Write-Host “Hotfix $CheckHotFixKB was installed on $CheckComputer on by ” $($HotFixQuery.InstalledBy); } } }

 Thank you.

Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>