-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy path1078.ps1
More file actions
54 lines (47 loc) · 1.87 KB
/
Copy path1078.ps1
File metadata and controls
54 lines (47 loc) · 1.87 KB
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
# The Get-HotFix function gets the quick-fix engineering (QFE) updates that have been applied to the local computer or to remote computers and filter those hotfixes named "file 1".
# There is Get-HotFix cmdlet in PowerShell V2. This is an attempt to bring similar functionality to V1.
function Get-HotFix {
param (
[string[]]$ComputerName = ".",
[string]$Id = "",
[string]$Description = "",
$credential
)
if ($credential -is [String] ) {
$credential = Get-Credential $credential
}
if ($id -ne "" -and $Description -eq "") {
$id = $id.Replace("*","%");$filter = "hotfixid LIKE '$id'"
}
elseif ($id -eq "" -and $Description -ne "") {
$Description = $Description.Replace("*","%");$filter = "description LIKE '$Description'"
}
elseif ($id -ne "" -and $Description -ne "") {
Write-Host "WARNING: Use Id or Description parameter." -foregroundcolor yellow ;break
}
else {
$filter = ""
}
if ($credential -eq $null) {
$HotFixes = get-wmiobject Win32_QuickFixEngineering -computerName $ComputerName -filter $filter | where-object {$_.hotfixid -ne "file 1"}
} else {
$HotFixes = get-wmiobject Win32_QuickFixEngineering -computerName $ComputerName -filter $filter -credential $credential | where-object {$_.hotfixid -ne "file 1"}
}
$HotFixes
}
# Examples:
#
# C:\PS>get-hotfix
#
# C:\PS>get-hotfix -Id *929*
#
# C:\PS>get-hotfix | format-table hotfixid,installedon,servicepackineffect,description -auto -wrap
#
# C:\PS>get-hotfix | convertto-html -property hotfixid,description -title "Installed HotFixes" > c:\temp\hotfixes.html
#
# C:\PS>get-hotfix -description Security* -computername Server01 -credential Server01\admin01
#
# C:\PS>get-hotfix -description Security* -computername Server01,Server02 | ft __server,desc*
#
# C:\PS>$a = get-content servers.txt
# $a | foreach { if (!(get-hotfix -id KB958644 -computername $_)) { add-content $_ -path Missing-KB958644.txt }}