Opt-In to Microsoft Update (Services Manager)
https://msdn.microsoft.com/en-us/library/windows/desktop/aa826676(v=vs.85).aspx
Windows Server Update Services > Windows Update Agent API > Using the Windows Update Agent API >
You can opt a computer in to the Microsoft Update service and then register that service with Automatic Updates.
The scripting sample in this topic shows you how to use Windows Update Agent (WUA) to register the Microsoft Update service with Automatic Updates. Alternatively, to register the service, the user can visit Microsoft Update.
Before you attempt to run this sample, verify that the version of WUA that is installed on the computer is version 7.0.6000 or a later version. For more information about how to determine the version of WUA that is installed, see Determining the Current Version of WUA.
Example
The following scripting sample shows you how to use the Windows Update Agent (WUA) to register the Microsoft Update service with Automatic Updates. The sample allows deferred or offline processing if needed.
Important This script is intended to demonstrate the use of the Windows Update Agent APIs, and provide an example of how developers can use these APIs to solve problems. This script is not intended as production code, and the script itself is not supported by Microsoft (though the underlying Windows Update Agent APIs are supported).
VB
Set ServiceManager = CreateObject(“Microsoft.Update.ServiceManager”)
ServiceManager.ClientApplicationID = “My App”
‘add the Microsoft Update Service, GUID
Set NewUpdateService = ServiceManager.AddService2(“7971f918-a847-4430-9279-4a52d1efe18d”,7,””)
In earlier versions of WUA (a minimum WUA version of 7.0.6000), you can simplify the opt-in process by using a registry setting. After the registry key and values are configured, the Microsoft Update opt-in process occurs the next time WUA performs a search. The opt-in process may be triggered by Automatic Updates or by an API caller.
For example, the full path of the registry key and values to set for the opt-in process are as follows:
HKLM\Software\Microsoft\Windows\CurrentVersion\WindowsUpdate\PendingServiceRegistration\7971f918-a847-4430-9279-4a52d1efe18d
ClientApplicationID = My App
RegisterWithAU = 1
Note
The registry key is respected once only when WUA is updated from a version that is earlier than version 7.0.6000 to version 7.0.6000 or to a later version. We recommend discretion when overwriting existing registry values because overwriting the values may change the result of an earlier service registration request.
Creating this registry key requires administrative credentials. For Windows Vista, the caller must create the registry key in an elevated process.
Also See this as well: Powershell ISE Module: Installing PSWindowsUpdate, Script: Provisioning Get-PendingReboot
Enabling and Disabling Microsoft Update in Windows 7 via Script
https://blogs.technet.microsoft.com/danbuche/2010/01/06/enabling-and-disabling-microsoft-update-in-windows-7-via-script/
by Dan Buche January 6, 2010
The Windows Update Feature in Windows 7 allows administrators to configure it to either service Windows only or to extend it to other products from Microsoft Update. In most cases, Windows Update is used by end-users only with no need to automate or script this process, since larger organisations usually utilise other means like System Center Configuration Manager to keep their systems up to date.
In some cases, however, you actually do get into the position where you want (or need) to change this setting for your end users, so scripting it can come in handy.
How to do this is documented here: http://msdn.microsoft.com/en-us/library/aa826676(VS.85).aspx and can be achieved via a simple script:
Set ServiceManager = CreateObject(“Microsoft.Update.ServiceManager”)
ServiceManager.ClientApplicationID = “My App”
‘add the Microsoft Update Service by GUID
Set NewUpdateService = ServiceManager.AddService2(“7971f918-a847-4430-9279-4a52d1efe18d”,7,””)
The reverse step is also possible with a simple alteration:
Set ServiceManager = CreateObject(“Microsoft.Update.ServiceManager”)
ServiceManager.ClientApplicationID = “My App”
‘remove the Microsoft Update Service by GUID
ServiceManager.RemoveService(“7971f918-a847-4430-9279-4a52d1efe18d”)
--------------------------------------
1. Tower Totals: 2xSSD ~512GB, 2xHHD 20 TB, Memory 32GB
SSDs: 6xOS Partitions, 2xW8.1 Main & Test, 2x10.0 Test, Pro, x64
CPU i7 2600 K, SandyBridge/CougarPoint, 4 cores, 8 Threads, 3.4 GHz
Graphics Radeon RX 580, RX 580 ONLY Over Clocked
More perishable
2xMonitors Asus DVI, Sony 55" UHD TV HDMI
1. NUC 5i7 2cores, 4 Thread, Memory 8GB, 3.1 GHz, M2SSD 140GB
1xOS W8.1 Pro, NAS Dependent, Same Sony above.
-----------------