![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=1739006874-FIVbYXEbQ3U3jrIfsPuJylRTT2RiQMx7-0-be76e34813751d6d093a05037c27fc20)
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=1739006874-ngbrZi1l7K0gzx0blgR88Frt0HUrKclZ-0-eaa0d9d419277b5a061a5ee57f03ce1a)
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=1739006874-VoZ97QEJv4BlM6gygPMKsOBWvORg7fh0-0-826451218e6d67c23e64a437a99492d4)
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=1739006874-oHXZoHZFe5CnKwiRHK3nzgxx4QkKE4fU-0-5b676e20f7a500c21000aa8b7b256e02)