A Microsoft infographic outlines migrating Windows activation automation from legacy VBScript to PowerShell using the OSLicense module.
Windows admins have relied on slmgr.vbs for years to install product keys and run activation from the command line. VBScript is being deprecated, so that script now has a replacement: the OSLicense PowerShell module. Its cmdlets can check activation status, install a product key, request online activation and configure Key Management Service (KMS) clients. They return PowerShell objects you can filter and test, so scripts no longer need to scrape text from a pop-up or console window.

This guide covers each task, which Windows builds include the module, and the mistakes most likely to cause problems.

A Microsoft infographic outlines migrating Windows activation automation from legacy VBScript to PowerShell using the OSLicense module. Why this matters now​

Microsoft's Windows IT Pro Blog post on keeping activation automation working with PowerShell was published September 10, 2026 and updated October 19. It tells organizations that automate activation with slmgr.vbs to find those dependencies and prepare to move to PowerShell, because VBScript is deprecated and will eventually be removed.

That does not mean slmgr.vbs has stopped working. As 4sysops puts it, "slmgr.vbs still works normally." Born's IT and Windows Blog expects admins to use slmgr.vbs and the OSLicense cmdlets side by side for some time. In practice, you have time to migrate, but scripts that still run cscript slmgr.vbs /ato should be on a migration list.

Summary: slmgr.vbs still works today, but it is on its way out. OSLicense is Microsoft's PowerShell replacement for it.

Which Windows versions have OSLicense?​

Reports do not agree on the exact update that introduced the module, so it is worth being precise.

  • Windows 11: Microsoft Learn's reference pages for Get-OSLicenseInfo, Invoke-OSLicense, Get-KmsLicenseInfo and Set-KmsLicenseInfo all say the cmdlet is available in the September 2026 security update for Windows 11, KB5124008. Some outlets name the August 27, 2026 preview update, KB5120998, as the starting point. 4sysops notes that Microsoft's blog post lists the earlier preview update KB5120998 from August 27, 2026, as the release where the module first appeared. Prepaid-host.com summarized reader reports that several readers say they have not found it yet after the preview update KB5120998. Microsoft Learn's module overview also says the KB number for module availability still needs confirmation.
  • Build numbers: EndpointWeekly lists the module as available on Windows 11 builds 26100.9278 / 26200.9278 and later (September 2026 update).
  • Windows Server: Microsoft documents support only in Windows Server vNext Preview Build 29651. 4sysops says Windows Server support is limited to preview builds. Current Windows Server releases still depend on slmgr.vbs.
  • Recovery environments: 4sysops also reports that the OSLicense module is not available in Windows Preinstallation Environment (WinPE) or Windows Recovery Environment (Windows RE). Imaging or recovery workflows that activate from WinPE need a different approach.
  • Runtime: The module requires Windows PowerShell 5.1 and ships with Windows on supported systems. Microsoft does not document a separate download or install command.

The safe rule: Target the September 2026 security update (KB5124008) or later, and run the availability check below before assuming a device has the module. Most production fleets don't deploy optional preview updates anyway.

Step 1: Check that OSLicense is available​

Open Start, search for Windows PowerShell, and choose Run as administrator. Make sure you open Windows PowerShell 5.1, not PowerShell 7. Then run:

Get-Module -ListAvailable -Name OSLicense

If the module is listed, import it and list its commands:

Code:
Import-Module OSLicense
Get-Command -Module OSLicense

Microsoft Learn's module overview lists these cmdlets:

CmdletPurpose
Get-OSLicenseInfoRead Windows licensing information
Invoke-OSLicensePerform an OS licensing operation (key install, activation, and more)
Set-OSLicenseInfoSet the volume activation type
Get-KmsLicenseInfoRead KMS client/host settings
Set-KmsLicenseInfoChange KMS client/host settings
Invoke-KmsLicenseClear selected KMS configuration overrides
Get-ADLicenseInfo / Invoke-ADLicenseActive Directory-based activation
Get-SubscriptionLicenseInfo / Invoke-SubscriptionLicense / Set-SubscriptionLicenseInfoSubscription licensing

LazyAdmin also notes that the module loads automatically when you call any of its cmdlets. You can usually skip Import-Module in day-to-day use, although it is a useful test when troubleshooting.

If nothing is returned, the device most likely does not have the required update. See Step 6.

Step 2: Check Windows activation status​

This is the replacement for slmgr.vbs /dlv. Run:

Get-OSLicenseInfo

According to Microsoft Learn, the cmdlet queries the local software licensing CIM classes. With no parameters, it returns the first primary Windows OS product that has a partial product key and is not an add-on license. To show only the fields you usually need, use the pattern from Microsoft's own example:

Code:
Get-OSLicenseInfo |
    Select-Object Name, ActivationID, LicenseStatus, PartialProductKey,
        GracePeriodRemaining, EvaluationEndDate

Things to know about the output:

  • PartialProductKey is only part of the key. The full product key is not displayed.
  • LicenseStatus is a localized string. A script that compares it with an English word may fail on a German or Japanese system. Match carefully or test against other properties.
  • LicenseStatusReason appears as a hexadecimal error code when it is set, which helps when looking up activation failures.
  • Unset values come back as $null. Some licensing placeholder values appear as text such as Unlimited, N/A or Not Set.
  • No output at all means the cmdlet found no matching licensing data or the CIM query failed. It does not mean the system is activated.

To see every licensing product rather than just the primary Windows license:

Get-OSLicenseInfo -All

Microsoft notes that -All can return products other than the primary Windows license, so the list may be longer than you expect. The cmdlet also accepts -ActivationID to query one specific product, plus -TokenBasedLicenses and -TokenBasedCertificates for token-based activation.

Because the output is made of objects, you can export it with standard PowerShell, for example Get-OSLicenseInfo -All | Export-Csv -Path C:\Temp\license.csv -NoTypeInformation. This uses ordinary PowerShell piping, not a special OSLicense feature. If you get an "access denied" error, write to a folder your account can write to.

Summary: Get-OSLicenseInfo is read-only and safe to run. It shows the primary Windows license by default and every licensing product with -All.

Step 3: Install a product key​

This replaces slmgr.vbs /ipk. From an elevated session:

Code:
$result = Invoke-OSLicense -InstallProductKey 'XXXXX-XXXXX-XXXXX-XXXXX-XXXXX'
$result | Select-Object Success, Operation, ErrorCode, ErrorMessage

Replace the placeholder with a 25-character key you are licensed to use. Microsoft's documentation makes three points:

  1. Installing a key does not activate Windows. Activation is a separate step.
  2. The result object contains the full key. ProductKey holds the value you supplied. Microsoft warns against writing that property to logs or anywhere unauthorized users can read it. If your script uses transcripts or sends results to a central log, remove ProductKey first. The command line itself can also end up in PowerShell history, so treat it as sensitive.
  3. Check the result object instead of the console text. Failures are caught and returned as objects with Success set to $false, plus ErrorCode (a Windows HRESULT when one is available) and ErrorMessage.

Afterwards, run Get-OSLicenseInfo again and check that PartialProductKey matches the last five characters of the key you installed.

Step 4: Activate Windows online​

This replaces slmgr.vbs /ato. With the device connected to the network:

Code:
$result = Invoke-OSLicense -ActivateOnline
$result | Select-Object Success, Operation, ActivationID, ProductName, ErrorCode, ErrorMessage

A Success value of $true means the operation succeeded. Then run Get-OSLicenseInfo to confirm the new LicenseStatus.

On machines with more than one licensing product, the command picks a target the same way Get-OSLicenseInfo does: without -ActivationID, it selects the first primary Windows product with a partial key that is not an add-on. To target a specific product, get its ID from Get-OSLicenseInfo -All, then:

Invoke-OSLicense -ActivateOnline -ActivationID '<activation-id-from-Get-OSLicenseInfo>'

A failed run does not mean the cmdlet is faulty. Activation depends on your licensing setup. The PowerShell Is Fun blog tried the command on a test system and suspected the error came from having no KMS server on the network. That is the expected result when a volume-licensed image has no KMS host available.

Invoke-OSLicense also covers other slmgr.vbs tasks: -UninstallProductKey, -ClearProductKeyFromRegistry, -Rearm, -ReinstallSystemLicenses, offline activation with -ConfirmationID, and token activation. Microsoft notes that a successful rearm returns RestartRequired as $true.

Step 5: Check and configure KMS activation​

First, record the current configuration. This step is read-only and it gives you a backup:

Code:
Get-KmsLicenseInfo |
    Select-Object KeyManagementServiceMachine, KeyManagementServicePort,
        KeyManagementServiceLookupDomain, KeyManagementServiceHostCaching

The cmdlet reports KMS client and host settings, the activation and renewal intervals, the KMS host it discovered, and request counts. Count fields show N/A when no data is available. Microsoft recommends saving this output before you change anything.

To point a client at your organization's KMS host:

Set-KmsLicenseInfo -ServerName 'kms.example.com' -Port 1688

Replace the example hostname with your own authorized KMS server. Microsoft's reference documents these behaviors:

  • Setting a specific host turns off autodiscovery. The client stops looking up the KMS host in DNS. If your environment relies on DNS SRV records, setting a fixed host may not be what you want.
  • Port 1688 is the documented default KMS port.
  • Only the parameters you specify are changed. Any setting you leave out stays as it was.
  • The cmdlet also manages host settings: -DnsPublishing, -HostCaching, -Priority (Normal or Low), -ListeningPort, -ActivationInterval and -RenewalInterval. Defaults are a 120-minute activation interval and a 10,080-minute (seven-day) renewal interval. KMS accepts values from 15 to 43,200 minutes.
  • Range checking is done by the licensing service, not the cmdlet. If you enter an invalid interval, the failure shows up in the result object, so check Success.

Once the client points at the right host, run Invoke-OSLicense -ActivateOnline to request activation. Set-KmsLicenseInfo only changes configuration. It does not activate anything.

Microsoft warns that host-side changes can affect KMS discovery and activation across the whole environment. Test them in a lab first.

Step 6: Fix "Get-OSLicenseInfo is not recognized"​

If PowerShell says the term Get-OSLicenseInfo is not recognized:

  1. Check the patch level. Open Settings > Windows Update and install the latest cumulative update. Aim for KB5124008 or later; EndpointWeekly lists builds 26100.9278 and 26200.9278 as the starting point.
  2. Restart the PC.
  3. Open Windows PowerShell 5.1 as administrator. The module requires 5.1.
  4. Run Get-Module -ListAvailable -Name OSLicense, then Import-Module OSLicense.
  5. Check where you are running it. On current Windows Server releases, WinPE or WinRE, the module will not appear. Keep using slmgr.vbs there for now.

If the module is present but state-changing commands fail, confirm the session is elevated. Microsoft says Invoke-OSLicense and Set-KmsLicenseInfo must run from an elevated session.

Quick slmgr.vbs translation table​

Taskslmgr.vbsOSLicense
Detailed license info/dlvGet-OSLicenseInfo
Install key/ipk <key>Invoke-OSLicense -InstallProductKey <key>
Activate online/atoInvoke-OSLicense -ActivateOnline
Uninstall key/upkInvoke-OSLicense -UninstallProductKey
Clear key from registry/cpkyInvoke-OSLicense -ClearProductKeyFromRegistry
Rearm/rearmInvoke-OSLicense -Rearm
Reinstall system licenses/rilcInvoke-OSLicense -ReinstallSystemLicenses

The /upk, /cpky, /rearm and /rilc mappings come from LazyAdmin's comparison table. The OSLicense side of each row matches parameters documented on Microsoft Learn.

Should you migrate now?​

Most of the change is an improvement. Results come back as objects with a Success property, so scripts can check outcomes directly instead of matching text in the output. Errors come with real HRESULT codes. Microsoft's documentation also includes guidance on protecting keys and PINs in logs and history, which slmgr.vbs never had.

There are gaps. The module requires current Windows 11 builds, server support exists only in preview builds, and WinPE is not supported, so most mixed environments will need both tools for a while. Localized LicenseStatus strings can also break scripts that run across languages.

A reasonable plan for now:

  1. List scripts, scheduled tasks and Intune remediations that call slmgr.vbs.
  2. Test the OSLicense equivalents on a patched Windows 11 pilot group.
  3. Add checks so scripts use OSLicense where the module exists and fall back to slmgr.vbs elsewhere.
  4. Remove product keys from logs before rollout.

slmgr.vbs still works for now, but VBScript is deprecated, so moving Windows 11 automation to OSLicense on your own timetable is the safer option.

 

References

  1. PowerShell OSLicense Guide: Check Activation, Install Keys, and Manage KMS Windows Report 2026-11-16T08:04:38+00:00
  2. How to activate Windows: OSLicense PowerShell module replaces slmgr.vbs 4sysops.com
  3. slmgr.vbs Is Being Deprecated: Replace Windows Activation… — EndpointWeekly endpointweekly.com