-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwsus.html
More file actions
36 lines (27 loc) · 865 Bytes
/
wsus.html
File metadata and controls
36 lines (27 loc) · 865 Bytes
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
<!DOCTYPE html>
<html>
<Title> Powershell for WSUS</title>
<body>
<code>
$WsussServer = get-wsusserver
$GroupName = "Production"
$GroupID = ($WsussServer.GetComputerTargetGroups() | ?{$_.name -eq $GroupName}).id
$AllComputer = $WsussServer.GetComputerTargets() | ?{$_.ComputerTargerGroupIDs -contains $GroupID}
$AllPatch =@()
foreach ($Computer in $AllComputer)
{
$ComputerPatch = $Computer.GetUpdateInstallationInfoperupdate() |?{$_.Updateinstallationstate -eq "Notinstall"}| ?{$_.updaterApprovalAction -eq "NotApproved"}
$AllPatch += $ComputerPatch
}
foreach($patch in $AllPatch)
{
$tmp = get-wsusupdate -updateid $patch.updateid
if($tmp.Classification -eq "Security Updates")
{
$tmp | approve-wsusupdate -targetGroupName $GroupName -Action Install
Write-host "$($patch.updateid) Had been approved on $GroupName."
}
}
</code>
</body>
</html>