0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

WSUSで少し複雑な自動承認

WSUSには自動承認機能がありますが、
製品別とかでさらに細かい所までは出来ない。

例えば下記のスクリプトは
Edgeの中のStableチャネルと WebView2 Runtimeを承認して、
他(Devチャネルとか)は承認しない、
みたいな事も出来る。

$WSUS = Get-WsusServer
$updates = $WSUS.GetUpdates()
$TgtGrps = $WSUS.GetComputerTargetGroups().where({$_.Name -like 'Group*'}) #対象グループを探す

foreach ($Grp in $TgtGrps){
Write-Host ($Grp.Name+':'+$Grp.Id)
}
foreach($update in ($updates | Where-Object({$_.ProductTitles.Contains('Microsoft Edge') -and $_.IsDeclined -ne $true}))){
    if($update.LegacyName.IndexOf('-Stable-RTM-MicrosoftEdge-') -ge 0 -or $update.LegacyName.IndexOf('-MicrosoftEdge-WV2-Client-') -ge 0){
        Write-Host ($update.Title + 'is approve')
        foreach ($Grp in $TgtGrps){
            $_apprs = $update.GetUpdateApprovals()
            $_appcnt = ($_apprs | ForEach-Object{if(($_.ComputerTargetGroupId -eq $Grp.Id) -and ($_.Action -eq [Microsoft.UpdateServices.Administration.UpdateApprovalAction]::Install)){$_}}).Length
            if($_appcnt -eq 0){
                Write-Output ("「"+($update.Title)+"」を"+$Grp.Name+"に承認しました。")
                $update.Approve([Microsoft.UpdateServices.Administration.UpdateApprovalAction]::Install,$Grp) | Out-Null
            }
        }
    }
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?