Windows

Get Windows Activation Status Across The Plant

One of my friends who is working for a retail store company as a sysadmin was seeking my help in finding the windows server activation status across his organization. Of course, there are many ways to fetch the windows activation status and there are plenty of tools are available online. But I have used CIM Instance with WIM class ‘SoftwareLicensingProduct’ to fetch the activation status for the given server list, and here is the code snippet&hellip; Function Get-WinSrvFromInv { &lt;# The purpose of this function is to retrieve the list of servers for which you want to check the Windows Activation status. Write your piece of code to retrieve the servers from your inventory. for example, Get-Content -Path $InvPath\Server.txt #&gt; return @(&#34;Srv2K19&#34;, &#34;Srv2K16&#34;, &#34;Srv2K12&#34;) } Function Get-WindowsActivation { &lt;# This is a PowerShell advanced function to retrieve the Windows Activation Status using CIM classes. It takes one or more servers as an input, and it accepts through pipeline as well This script will check the connectivity, and then checks the activation status It collects the info from all the servers and then return the value of error at once. #&gt; [CmdLetBinding()] Param ( [Parameter(Mandatory=$true,ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string[]] $ComputerName ) Begin {$ActivationStatus = @() } Process { foreach ($CN in$ComputerName) { $PingStatus = Test-Connection -ComputerName$CN -ErrorAction Stop -Count 1 -Quiet $SPL = Get-CimInstance -ClassName SoftwareLicensingProduct -ComputerName$CN -Filter &#34;PartialProductKey IS NOT NULL&#34; -ErrorAction Stop $WinProduct =$SPL | Where-Object Name -like &#34;Windows*&#34; $Status = if ($WinProduct.LicenseStatus -eq 1) { &#34;Activated&#34; } else { &#34;Not Activated&#34; } if ($PingStatus -ne$true) { $PingStatus = &#34;No&#34;$Status = &#34;Error&#34; } else { $PingStatus = &#34;Yes&#34; }$ActivationStatus &#43;= New-Object -TypeName psobject -Property @{ ComputerName = $CN Status =$Status IsPinging = $PingStatus } } } End { return$(\$ActivationStatus | Select-Object -Property ComputerName, IsPinging, Status) } } ## Invoke the functions. Get-WinSrvFromInv | Get-WindowsActivation And you will get the status as below&hellip;