Windows OS Hub
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server 2025
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
    • Proxmox
  • PowerShell
  • Linux
  • Home
  • About

Windows OS Hub

  • Windows
    • Windows 11
    • Windows 10
    • Windows Server 2025
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
    • Proxmox
  • PowerShell
  • Linux

 Windows OS Hub / PowerShell / Manage Windows Activation with PowerShell OSLicense: slmgr.vbs Replacement

November 26, 2026

Manage Windows Activation with PowerShell OSLicense: slmgr.vbs Replacement

A new PowerShell module called OSLicense has recently been added to Windows 11. This module allows users to manage product keys, licenses, and to activate the operating system. This module is intended to replace the legacy slmgr.vbs script, which for decades has been the primary tool for admins to manage activation on Windows devices. Given that Microsoft is deprecating VBScript and plans to remove the VBScript engine from future Windows builds within the next few years, administrators should gradually start transitioning to using this PowerShell module

In this article, we’ll look at the main PowerShell cmdlets for managing Windows product keys, licensing, and activation, along with their equivalents from the legacy slmgr.vbs command that they are intended to replace

Contents:
  • PowerShell OSLicense module for Windows
  • OSLicense PowerShell Cmdlets and slmgr.vbs Equivalents

PowerShell OSLicense module for Windows

Check whether the OSLicense module is installed on the machine:

Get-Module -ListAvailable -Name OSLicense

The module should have been installed automatically on all supported versions of Windows 11 as part of the cumulative updates released after August 2026. According to Windows Server, it is planned to be added in the next major release.

Although the module is designed for PowerShell 5.1, it will also work correctly with newer versions of PowerShell Core 7.x (pwsh.exe), if you manually import it:

Import-Module OSLicense

List the cmdlets available in the module. There are currently 11 cmdlets available.

Get-Command -Module OSLicense

OSLicense PowerShell module in Windows 11

Check the current Windows activation status:

Get-OSLicenseInfo

The cmdlet returns a lot of different activation-related information. This is one of the advantages of PowerShell: it returns objects rather than plain text. This allows you to flexibly filter which data (properties) you want to see in the command output. Unlike the results from slmgr, which required additional parsing via scripts

For example, let’s display the Windows version, edition, build, license status, and activation type:

Get-OSLicenseInfo| Select Name,Version,LicenseStatus,Description

Get-OSLicenseInfo

This Windows 11 Pro machine has been activated using a KMS server (VOLUME_KMSCLIENT channel).

Get the details of the KMS server that is in use and the current KMS activation settings on the machine:

Get-KmsLicenseInfo

Get-KmsLicenseInfo

How to Manually Activate Windows Against a KMS Server Using PowerShell

The typical sequence of commands for manually activating a Windows client against a KMS server is as follows:

Install a public Generic Volume License key (also called a KMS client setup key) for the required Windows edition. GVLK is used to configure Windows to activate via a KMS host.

Invoke-OSLicense -InstallProductKey "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX"

Specify the address and port of the target KMS host:

Set-KmsLicenseInfo -ServerName kms1.woshub.com -Port 1688

To activate Windows online or against a KMS server (if specified):

Invoke-OSLicense -ActivateOnline

Check the client’s activation status:

Get-OSLicenseInfo | Select-Object LicenseStatus

Activate Windows on KMS server using PowerShell

If the KMS server is unavailable, an error will appear:

Success : False
Operation : ActivateOnline
ErrorCode : 0xC004F074
ErrorMessage : The Software Licensing Service reported that the product could not be activated. No Key Management Service (KMS) could be contacted. Please see the Application Event Log for additional information.

Windows activation error 0xC004F074 - KMS could be contacted

Offline Windows Activation Using PowerShell

If the computer has no Internet access, you can still activate Windows offline, but you will need another device or smartphone that can be used to enter and retrieve codes through the visualsupport.microsoft.com portal.

Install the product key:

Invoke-OSLicense -InstallProductKey XXXXX-XXXXX-XXXXX-XXXXX-XXXXX

Get the installation ID for your Windows operating system instance:

(Get-OSLicenseInfo).OfflineInstallationId

Specify your installation ID on the portal. Then paste the confirmation ID code that you receive into the following command:

Invoke-OSLicense -ConfirmationID '<Confirmation_ID_Received>'

Unlike slmgr, which can manage activation on remote computers (WMI over DCOM+RPC), the OSLicense cmdlets cannot be used to connect to remote computers over the network. However, this limitation can easily be bypassed using PowerShell Remoting, for example:

Invoke-Command -ComputerName mun-wks123 -ScriptBlock {Get-OSLicenseInfo}

In a domain environment, use the Get-ADLicenseInfo and Invoke-ADLicense cmdlets to manage Windows activation when Active Directory-based activation (ADBA) is enabled.

OSLicense PowerShell Cmdlets and slmgr.vbs Equivalents

The following table provides examples of PowerShell cmdlets from the OSLicense module that can be used for activation management, along with their equivalents in the legacy slmgr.vbs script.

TaskOSLicense module commandLegacy slmgr.vbs command parameter
Display basic license and activation statusGet-OSLicenseInfoslmgr /dli
Displays detailed license and activation information for every Microsoft product installed on a computerGet-OSLicenseInfo -Allslmgr /dlv all
Check the expiration date of the current licenseGet-OSLicenseInfo | Select-Object Name, LicenseStatus, PartialProductKey, GracePeriodRemaining, EvaluationEndDateslmgr /xpr
Install a new Windows product keyInvoke-OSLicense -InstallProductKey XXXXX-XXXXX-XXXXX-XXXXX-XXXXXslmgr /ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
Activate the OS online using the product key currently installed (via the Internet on official Microsoft activation servers or through the specified KMS host)Invoke-OSLicense -ActivateOnlineslmgr /ato
Uninstall the current Windows product keyInvoke-OSLicense -UninstallProductKeyslmgr /upk
Remove the Windows product key from the registry it from being extractedInvoke-OSLicense -ClearProductKeyFromRegistryslmgr /cpky
Reset the grace period timer (to rearm the Windows evaluation )Invoke-OSLicense -Rearmslmgr /rearm
Get your Windows Installation ID for offline activation(Get-OSLicenseInfo).OfflineInstallationIdslmgr /dti
Enter the confirmation IDInvoke-OSLicense -ConfirmationID <ConfirmationID>slmgr /atp <ConfirmationID>
Set the KMS server address and portSet-KmsLicenseInfo -ServerName KMSServerName -Port 1688slmgr /skms KMSServerName:1688
Check the current KMS settingsGet-KmsLicenseInfoslmgr /dlv (under the Key Management Service client information section)
Clear KMS server settingsInvoke-KmsLicense -ClearServer, Invoke-KmsLicense -ClearPortslmgr /ckms
Note. The OSLicense module is intended only for managing Windows activation and cannot be used for managing Microsoft Office products. You should still use the built-in ospp.vbs script for MS Office activation.

Accordingly, if the VBS Feature on Demand component is not installed in Windows, running any slmgr command will result in an error:

Input Error: There is no script engine for file extension ".vbs".

Check whether this feature is installed:

Get-WindowsCapability -Online -Name "VBSCRIPT*"

Missing VBS script engine in Windows

It’s time to update your servicing scripts for managing Windows activation on clients, replacing the legacy slmgr.vbs command with its PowerShell equivalent. Unfortunately, there is still no alternative to slmgr for the WinPE environment.

0 comment
0
Facebook Twitter Google + Pinterest
PowerShellQuestions and AnswersWindows 11
previous post
Managing PowerShell Modules in Windows: Install, Update & Remove

Related Reading

Monitor Windows Log Files in Real Time with...

March 26, 2026

Inactive TS Ports in Windows: Causes and Fixes

July 21, 2026

Backup/Sync to Cloud Storage with Rclone on Windows

October 9, 2026

Pin and Unpin Apps to Taskbar in Windows...

March 26, 2026

Find Computers with Pending Reboot Status Using PowerShell

April 15, 2026

Manage Microsoft Store Apps with Store CLI in...

July 2, 2026

How to Extract Printer Drivers from Windows

March 26, 2026

Windows Installer Folder Too Large? How to Clean...

November 24, 2026

Leave a Comment Cancel Reply

join us telegram channel https://t.me/woshub
Join WindowsHub Telegram channel to get the latest updates!

Recent Posts

  • Managing PowerShell Modules in Windows: Install, Update & Remove

    November 24, 2026
  • Windows Installer Folder Too Large? How to Clean Up Safely

    November 12, 2026
  • Shrink WSL2 and Docker Desktop VHDX Files in Windows

    November 11, 2026
  • We Can’t Sign In to Your Account: Fix Temporary User Profile in Windows

    October 20, 2026
  • Backup/Sync to Cloud Storage with Rclone on Windows

    October 9, 2026
  • Fix Missing “Yes” Button in User Account Control Prompt on Windows

    October 7, 2026
  • Block Specific Keyboard Shortcuts with Keyboard Filter on Windows

    October 3, 2026
  • How to Set Task Priority in Windows Task Scheduler

    September 22, 2026
  • AutoStart Program at RDP Logon in Windows RDS

    September 8, 2026
  • How to Convert Windows Machine into a Proxmox VM

    August 30, 2026

Follow us

  • Facebook
  • Twitter
  • Youtube
  • Telegram
Popular Posts
  • How to Hide (Block) a Specific Windows Update
  • Run Elevated Commands with Sudo on Windows 11
  • Fix: Slow Startup of PowerShell Console and Scripts
  • Automate Software and Settings Deployment with WinGet Configure (DSC)
  • Enable/Disable Random Hardware (MAC) Address for Wi-Fi on Windows
  • Uninstalling Windows Updates via CMD/PowerShell
  • How to Extract Printer Drivers from Windows
Footer Logo

@2014 - 2026 - Windows OS Hub. All about operating systems for sysadmins


Back To Top