- Windows Server 2016 Automation with PowerShell Cookbook(Second Edition)
- Thomas Lee
- 164字
- 2021-07-02 18:15:53
How it works...
In step 1, you use Get-WsusServer to create the $WSUSServer object and use its properties to define the Windows Update server URL in the $WSUSServerURL variable. This URL is not stored in a single property, so the variable is built with a format string using the Name, PortNumber, and UseSecureConnection properties.
The portion of code that inspects the UseSecureConnection property appends an s to the HTTP of the URL only if the UseSecureConnection property is set to $true. This statement is similar to an if and only if (IIF) function in other languages:

In step 2, you create a new group policy object entitled WSUS Client with New-GPO and link the group policy to the RESKIT.org domain with New-GPLink:

In step 3, you define four registry key values and associate them with the group policy object using Set-GPRegistryValue:

In step 4, you force a group policy update on any Windows computer in the domain and start the Windows Update client immediately:
