Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function Get-LicenseInfo {
  2.  
  3.     Param
  4.     (
  5.         [Parameter(Mandatory=$false,ValueFromPipelineByPropertyName=$true)]
  6.         [String[]]$ComputerName = $env:COMPUTERNAME
  7.     )
  8.  
  9.     #defined initial data
  10.     $LicenseStatus = @("Unlicensed","Licensed","OOB Grace",
  11.     "OOT Grace","Non-Genuine Grace","Notification","Extended Grace")
  12.  
  13.     Foreach($CN in $ComputerName)
  14.     {
  15.         Get-CimInstance -ClassName SoftwareLicensingProduct -ComputerName $ComputerName |`
  16.         Where{$_.PartialProductKey -and $_.Name -like "*Windows*"} | Select `
  17.         @{Expression={$_.PSComputerName};Name="ComputerName"},`
  18.         @{Expression={$_.Name};Name="WindowsName"} ,ApplicationID,`
  19.         @{Expression={$LicenseStatus[$($_.LicenseStatus)]};Name="LicenseStatus"}
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement