- Windows Server 2016 Automation with PowerShell Cookbook(Second Edition)
- Thomas Lee
- 189字
- 2021-07-02 18:15:54
How it works...
In step 1, you create the $WSUSServer object using Get-WsusServer, then use the CreateInstallApprovalRule method to create a new AutomaticUpdateApprovalRule object, and store them in the $ApprovalRule variable:

In step 2, you define $RuleDeadline, a new AutomaticUpdateApprovalDeadline object, configured to install automatically with a three-day grace period after becoming available and the scheduled installation time of 3 am. You associate this deadline object with your approval rule:

In step 3, you use the GetUpdateClassifications method of the $ApprovalRule object and store the resulting object in the $UpdateClassification variable. The object initially contains no update classifications. You then use the Add method of this object to add in the two desired update classifications filtered by Title and associate these with the $ApprovalRule object using the SetUpdateClassifications method:

In step 4, you define $TargetGroups and set it to contain the computer target group named 'Domain Controllers' using the GetComputerTargetGroups method of $WSUSServer, filtered by Where-Object. You then associate $TargetGroups with the new $ApprovalRule using the SetComputerTargetGroups method:

In step 5, you set the Enabled property of the $ApprovalRule object, and use the Save method to complete the configuration:
