# Patch Details

**URL:** <https://forums.powershell.org/t/patch-details/5552>\
**Category:** PowerShell Help\
**Created:** [January 17, 2016, 10:35pm UTC](https://forums.powershell.org/t/patch-details/5552 "2016-01-17T22:35:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![partho-sankar-roy](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/partho-sankar-roy/32/626_2.png) [@partho-sankar-roy](https://forums.powershell.org/u/partho-sankar-roy)\
**Post date:** [January 17, 2016, 10:35pm UTC](https://forums.powershell.org/t/patch-details/5552/1 "2016-01-17T22:35:56Z")

</div>

Hi Guys,

I am trying to create a function which will check for a specific KB on a list of servers and generate the report, I am all done so far, however can someone help me on a validation for checking the servers status, What I am looking for is if the server is online then only the script would run else the it will write an error in the report file. I have tried using test-connection but dunno about array and collection as I am not from a developing back ground.

Below is what I have wrote so far.

function Get-PatchDetails

{

[CmdletBinding()]

Param (

$path,  
$id,  
$reportfile)

$Computers=Get-Content -Path $path

foreach ($c in $Computers)

{

if (Get-HotFix -Id $id -ComputerName $c )

{Add-Content “$c have the patch $id” -Path $reportfile}

else

{(Add-Content “$c doesnt have the patch $id” -Path $reportfile)}

}  
}

---

<div class="post-metadata">

**Author:** ![aaron-miller](https://avatars.discourse-cdn.com/v4/letter/a/a6a055/32.png) [@aaron-miller](https://forums.powershell.org/u/aaron-miller)\
**Post date:** [January 18, 2016, 3:00am UTC](https://forums.powershell.org/t/patch-details/5552/2 "2016-01-18T03:00:40Z")

</div>

Hey, you can use something like this…kind of a skeleton one I use for testing connection/bad access/cant ping’s.

You’ll have to add whatever report building you’d like in each section

```
$svrlist = get-content serverlist.txt

foreach ($svr in $svrlist) {

	if ((test-connection -computername $svr -count 1).StatusCode -eq 0) {
		try
		{
			#works if in here       
        	}
        
       		catch 
		{
        		#Can't Access"
       		 	continue
       		}
	}
	else 
	{
		#Can't Ping"
	}
}
```

---

<div class="post-metadata">

**Author:** ![vincent-k](https://avatars.discourse-cdn.com/v4/letter/v/858c86/32.png) [@vincent-k](https://forums.powershell.org/u/vincent-k)\
**Post date:** [January 18, 2016, 5:32pm UTC](https://forums.powershell.org/t/patch-details/5552/3 "2016-01-18T17:32:13Z")

</div>

Get-PatchDetails Function

> <https://gist.github.com/anonymous/e93f472456fcb83b57c4>

---

<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:43pm UTC](https://forums.powershell.org/t/patch-details/5552/4 "2024-05-16T20:43:10Z")

</div>


