Windows 10 Configurations - PowerShell and WMI Bridge vs. Provisioning Packages
In Windows 10 you have the option of creating provisioning packages to apply settings/configurations to a machine. For example upgrading a machine running Windows 10 Professional to Windows 10 Enterprise. Now, to apply a provisioning package, you can either do it automatically in WinPE via DISM.exe, or later in the running Windows operating system by double-clicking the provisioning package and walk through a quick wizard.
For some odd reason, the setup team with Microsoft has purposely crippled DISM.exe in regards to automation support for running provisioning packages in Windows. DISM, when running online, simply don’t support simple automation things like silent installation switches (unattended installs), nor wait for the command to complete, nor allowing you to suppress a reboot.
That’s where PowerShell comes into the picture. Via the WMI Bridge in Windows 10 (which unfortunately only supports a limited set of configurations), you can achieve the same thing; But which much better control, and obviously, better automation. Very Shiny!
As mentioned previously you have two options if you want to automate configurations that provisioning packages set:
- Running DISM.exe in WinPE
- Running PowerShell in full Windows to apply configurations via the WMI Bridge
Running DISM.exe in WinPE
Here is an example where I have create a provisioning package (EditionUpgrade.ppkg), that does a Windows 10 Edition Upgrade, to Windows 10 Enterprise, and then added the DISM command to my task sequence. In this example I’m storing the provisioning package in the ProvPackages folder in my deployment share:
DISM.exe /Image:%OSDISK%\ /Add-ProvisioningPackage /PackagePath:%DEPLOYROOT%\ProvPackages\EditionUpgrade.ppkg
Note: Obviously, if you only want to deploy Windows 10 Enterprise, you should of course just use an Enterprise image, but please see this as just an example on how to apply a provisioning package in WinPE.
A sample task sequence, changing a Windows 10 Pro image into Window 10 Enterprise during deployment.
Running PowerShell in full Windows to apply configurations via the WMI Bridge
Since DISM.exe does not allow for online automation, you can use PowerShell instead. Here is an example that automates the edition upgrade of an existing Windows 10 Pro, to Windows 10 Enterprise. The trick is to run the script as system, so first use the following command to start PowerShell as system (requires psexec from Windows Sysinternals).
C:\Setup\SysinternalsSuite\PsExec.exe -s -i PowerShell.exe
Then you run the below PowerShell script to to the edition upgrade:
$namespaceName = "root\cimv2\mdm\dmmap"
$className = "MDM_WindowsLicensing"
$methodName = "UpgradeEditionWithProductKeyMethod"
# Public KMS Client Key for Windows 10 Enterprise
$ProductKey = "NPPR9-FWDCX-D2C8J-H872K-2YT43"
$session = New-CimSession
$params = New-Object Microsoft.Management.Infrastructure.CimMethodParametersCollection
$param = [Microsoft.Management.Infrastructure.CimMethodParameter]::Create("param", $ProductKey, "String", "In")
$instance = Get-CimInstance -Namespace $namespaceName -ClassName $className -Filter "ParentID='./Vendor/MSFT' and InstanceID='WindowsLicensing'"
$session.InvokeMethod($namespaceName, $instance, $methodName, $params)
write-host $_ | out-string
Running the PowerShell script that runs the edition upgrade via the WMI Bridge.
The machine after upgrading the edition to Windows 10 Enterprise.
Written by Johan Arwidmark