![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=1739014113-tbhU0EX2lml0XJzwK217p1D6rUmavkx5-0-6f88682e63433f9c10e5f1b85b21139b)
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=1739014113-Lxdy8fI0GCpyLjPYkynxc0VoyZjRiYBx-0-1700b95d068a956f9a3a2544730b83a2)
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=1739014113-UKDDlZ4GVkwzDupQLGjAkZeMOYFEW1ff-0-87a7a38d75bd5107d2ade02a81ebd27a)
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=1739014113-WTYgWsdTvmZxKj5CiKcaYupG6sKwJEOD-0-a50740ff3e33dd5d426d0fe254ef0050)