# Get-Hotfix from throws error in the middle

**URL:** <https://forums.powershell.org/t/get-hotfix-from-throws-error-in-the-middle/11825>\
**Category:** PowerShell Help\
**Created:** [December 24, 2018, 5:33pm UTC](https://forums.powershell.org/t/get-hotfix-from-throws-error-in-the-middle/11825 "2018-12-24T17:33:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sugandhakumar](https://avatars.discourse-cdn.com/v4/letter/s/e9a140/32.png) [@sugandhakumar](https://forums.powershell.org/u/sugandhakumar)\
**Post date:** [December 24, 2018, 5:33pm UTC](https://forums.powershell.org/t/get-hotfix-from-throws-error-in-the-middle/11825/1 "2018-12-24T17:33:31Z")

</div>

Hi,

I’m trying to collect all the patches from list of servers which is in notepad. The command i use is **Get-Hotfix -computername (Get-Content C:\users\ssubram4\Desktop\Patching\All\_2016.txt)**

In the file All\_2016.txt, i have 250 servers.If the 10th server is unavailable, iam able to get the hotfix upto 9th server only and i got the below error.

Get-Hotfix : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)  
At line:1 char:1

- Get-Hotfix -computername (Get-Content C:\users\ssubram4\Desktop\Patch …
- 

```auto

```

- CategoryInfo : NotSpecified: (🙂 [Get-HotFix], COMException
- FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.PowerShell.Commands.GetHotFixCom  
mand

I would like to skip the unreachable servers and move on to next server to the hotfix.  
Kindly help me with the **SAME SYNTAX.**

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [December 24, 2018, 5:40pm UTC](https://forums.powershell.org/t/get-hotfix-from-throws-error-in-the-middle/11825/2 "2018-12-24T17:40:05Z")

</div>

So you need to check the availability of each single server before you query the hotfixes. You can do this in a loop with [Test-Connection](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/test-connection?view=powershell-5.1).

```
Test-Connection -ComputerName "ComputerName" -Count 1 Quiet
```

… returns a $true if the target computer is available and a $false if not. 😉

---

<div class="post-metadata">

**Author:** ![kpatnayakuni](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/kpatnayakuni/32/19_2.png) [@kpatnayakuni](https://forums.powershell.org/u/kpatnayakuni)\
**Post date:** [December 24, 2018, 11:15pm UTC](https://forums.powershell.org/t/get-hotfix-from-throws-error-in-the-middle/11825/3 "2018-12-24T23:15:25Z")

</div>

You need to use try/catch block or ping the server before executing the command…

[pre]

$Servers = Get-Content -Path C:\users\ssubram4\Desktop\Patching\All\_2016.txt

foreach ($Server in $Servers)  
{  
Try  
{  
Get-HotFix -ComputerName $Server  
}  
catch  
{  
#Continue  
}  
}

[/pre]

or

[pre]

$Servers = Get-Content -Path C:\users\ssubram4\Desktop\Patching\All\_2016.txt

foreach ($Server in $Servers)  
{  
if (Test-Connection -ComputerName $Server -Count 1 -Quiet)  
{  
Get-HotFix -ComputerName $Server  
}  
}

[/pre]

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:33pm UTC](https://forums.powershell.org/t/get-hotfix-from-throws-error-in-the-middle/11825/4 "2024-05-16T20:33:30Z")

</div>


