![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=1739396873-6BJZhsH4Ntnoc7uekp9IzA1g6Zf6GY4T-0-b10a4375af83b3135f5e2ab015fb218c)
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=1739396873-MfI9tLn9gLulh9VNpwZZqyo4VYbBXTqp-0-b0a6719ae4f29374ae79a86099d15dd2)
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=1739396873-eQwjugvG3lJL0V7esYvZ3G1IU3G43kGZ-0-2f359e1591afb13a6e1209409a48e12f)
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=1739396873-sbQW3ZGtItGyUtyvt9RQUWCPN7ESuucm-0-6121f0fb03139fbd26dc318784edfca9)