0

I want to get a message if Windows not activated

I create gpo that run message on logon

If i run this filter via wmi filter Get-wmiobject -query 'select licensestatus from softwarelicensingproduct where LicenseStatus like 1'

I get the message.

But if run this filter Get-wmiobject -query 'select licensestatus from softwarelicensingproduct where LicenseStatus like 0'

I get message on all the computers - activate and not activate

Is it possible to check all computers where the where LicenseStatus like 1 does not work?

I try to write this with not like

Get-wmiobject -query 'select licensestatus from softwarelicensingproduct where not LicenseStatus like 1'

It is not work. its work like LicenseStatus like 0

yosi
  • 65
  • 6
  • Perhaps [this article](https://devblogs.microsoft.com/scripting/use-powershell-to-check-the-license-status-of-windows-8/) can help, or try `Invoke-Command { (cscript /Nologo "C:\Windows\System32\slmgr.vbs" /xpr) -join '' } -ComputerName xy` – Theo Jun 19 '21 at 15:29

2 Answers2

0

I believe if you're looking for all objects where SoftwareLicensingProduct is NOT 1 then the syntax should be:

Get-WMIObject -Query 'SELECT LicenseStatus FROM SoftwareLicensingProduct WHERE LicenseStatus != 1'
Santiago Squarzon
  • 41,465
  • 5
  • 14
  • 37
  • i try this syntax on powershell and i get all the 0. like not 0. in all computer have 0 and if it active have 1. i need to check whare not have just 1. – yosi Jun 17 '21 at 18:29
  • @yosi not sure I understand what you mean, sorry. – Santiago Squarzon Jun 17 '21 at 18:59
  • when i write "WHERE LicenseStatus != 1" i get all the who's not equal to 1. iI know there is more, I want to check if 1 does not exist. It is possible? – yosi Jun 17 '21 at 20:47
  • To check if there is any object with value of 1 just use `LicenseStatus = 1` instead, if you get a result then you know it exist if you don't get anything then there isn't any object with that value. – Santiago Squarzon Jun 17 '21 at 20:50
  • I want to know if windows activated, if no run script. But in the wmi filter i can run script if i have somting. Then i need to know if LicenseStatus not equal to 1 and any other number – yosi Jun 17 '21 at 21:01
0

I came up with a GPO WMI filter for clients with activation SELECT LicenseStatus FROM SoftwareLicensingProduct WHERE Name LIKE "%Windows%" AND PartialProductKey IS NOT NULL AND LicenseStatus =1 For windows clients without activation SELECT LicenseStatus FROM SoftwareLicensingProduct WHERE Name LIKE "%Windows%" AND PartialProductKey IS NOT NULL AND LicenseStatus !=1