Problems getting output as String

Hi @ all

I need a way to check via PowerShell if Windows is activated, I’ve found a working solution:
Get-CIMInstance -query “select Name, Description, LicenseStatus from SoftwareLicensingProduct where LicenseStatus=1” | Format-Wide LicenseStatus

But i don’t find a way, to get the Result (the 1 (if activated)) as a simple string, maybe someone has an idea ?

I guess it’s very simple, but i don’t even know what to ask Mr. google in this case.

Thanks in advance

Hi, welcome to the forum :wave:

Use Select-Object

Get-CIMInstance -query "select Name, Description, LicenseStatus from SoftwareLicensingProduct where LicenseStatus=1" | 
    Select-Object -ExpandProperty licenseStatus

By the way, as a note for future posts, when posting code, data, and errors in the forum, please use the </> button to format your post.

How to format code on PowerShell.org

1 Like

Works like a charm, Thanks !