Using hotfix in for each loop

Welcome Forums General PowerShell Q&A Using hotfix in for each loop

Viewing 1 reply thread
  • Author
    • #187018
      Topics: 22
      Replies: 58
      Points: 178
      Rank: Participant

      Good morning experts!
      Looking for some help to use hotfix to grab servername, kb number and date into one file so I can compare them. Here is what we have so far

      $Servers=Get-Content C:\WVUS\SQL_Servers.txt
      ForeEach ($Server in $Servers) {
      Invoke-Command -ComputerName $Server -ScriptBlock { "$(Get-HotFix)" } -Credential $admin | Out-File -filepath c:\Temp\SQL_SERVERS_KB_$date.txt -Append

      Thanks in advance for your input


    • #187021
      Senior Moderator
      Topics: 8
      Replies: 1154
      Points: 4,014
      Helping Hand
      Rank: Community Hero

      a generic advice,

      Just write code to get hotfix from the localmachine in the desired output format. Once ready, then us Invoke-Command to target multiple computers.

      PS: Get-Hotfix do have a -ComputerName parameter, using that'll will be better here.

      Get-HotFix -ComputerName (Get-Content -Path ) | Export-CSV  -NoTypeInformation
Viewing 1 reply thread
  • You must be logged in to reply to this topic.