![Windows Server 2016 Automation with PowerShell Cookbook(Second Edition)](https://wfqqreader-1252317822.image.myqcloud.com/cover/733/36700733/b_36700733.jpg)
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:
![](https://epubservercos.yuewen.com/7D2E6F/19470404008937606/epubprivate/OEBPS/Images/8e78c2c9-b60e-465d-a59e-42e25410f1c1.png?sign=1739396585-gRyR1yqgJv2E9Q0kzCraSBwd1Bi6qXKz-0-fc3022e64b32d647679c7e3432171a88)
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:
![](https://epubservercos.yuewen.com/7D2E6F/19470404008937606/epubprivate/OEBPS/Images/d0b010b5-288a-435e-90ff-ade0dfc919fc.png?sign=1739396585-xiempWe7LJstehw5N0rkz4KX4WqY7Kty-0-c040e7646c3d366446875cb611da24ed)
In step 3, you define four registry key values and associate them with the group policy object using Set-GPRegistryValue:
![](https://epubservercos.yuewen.com/7D2E6F/19470404008937606/epubprivate/OEBPS/Images/b2c059d1-859d-46e2-b978-866663a5770c.png?sign=1739396585-tT1QCdDAdox6qhZDv2oaSVKwBa36cCRa-0-5344b590863e6c8edac6deec699e68a3)
In step 4, you force a group policy update on any Windows computer in the domain and start the Windows Update client immediately:
![](https://epubservercos.yuewen.com/7D2E6F/19470404008937606/epubprivate/OEBPS/Images/6ee16be1-0e37-4b72-b4c7-ba2526bf8fac.png?sign=1739396585-tZ0NVh8ceauFicZ7fMG4iyVLVrnN5qD5-0-7f6d2a3c8b2fccb53e13b358c1d5232a)