-
Notifications
You must be signed in to change notification settings - Fork 0
/
Get-SHDComputerHotfix.ps1
68 lines (65 loc) · 2.67 KB
/
Get-SHDComputerHotfix.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
function Get-SHDComputerHotfix {
<#
.SYNOPSIS
Gets target computers hot fix information.
.DESCRIPTION
Gets target computers hot fix information.
.PARAMETER ComputerName
Mandatory list of string that target a computer.
.PARAMETER Credential
Optional credentials.
.EXAMPLE
PS C:\Users\dbolding_adm> Get-SHDComputerHotfix -Computername Computer1
Source Description HotFixID InstalledBy InstalledOn PSComputerName
------ ----------- -------- ----------- ----------- --------------
Update KB4578974 NT AUTHORITY\SYSTEM 10/14/2020 12:00:00 AM Computer1
.INPUTS
List of String
.OUTPUTS
PScustomobject
.NOTES
Author: David Bolding
Date: 10/15/2020
.LINK
https://github.com/rndadhdman/PS_Super_Helpdesk
#>
[cmdletbinding()]
param (
[Parameter(
ValueFromPipeline = $True,
ValueFromPipelineByPropertyName = $True,
HelpMessage = "Provide the target hostname",
Mandatory = $true)][Alias('Hostname', 'cn')][String[]]$Computername,
[Parameter(HelpMessage = "Allows for custom Credential.")][System.Management.Automation.PSCredential]$Credential
)
foreach ($computer in $Computername) {
if (Test-Connection -ComputerName $computer -Count 1 -Quiet) {
try {
if ($PSBoundParameters.ContainsKey('Credential')) {
$CIMSession = New-CimSession -ComputerName $Computer -Credential $Credential
Get-CimInstance -ClassName Win32_QuickFixEngineering -CimSession $CIMSession
Remove-CimSession $CIMSession
}
else {
Get-CimInstance -ClassName Win32_QuickFixEngineering -ComputerName $computer
}
}
catch {
try {
if ($PSBoundParameters.ContainsKey('Credential')) {
Get-WmiObject -Class Win32_QuickFixEngineering -ComputerName $Computer -Credential $Credential
}
else {
Get-WmiObject -Class Win32_QuickFixEngineering -computername $computer
}
}
catch {
Write-Warning "Unable to capture Data from $Computer."
}
}
}
else {
Write-Warning "$Computer is offline."
}
}
} #Review - Testing, Documentation