# Problems getting output as String

**URL:** <https://forums.powershell.org/t/problems-getting-output-as-string/19503>\
**Category:** PowerShell Help\
**Created:** [June 2, 2022, 2:43pm UTC](https://forums.powershell.org/t/problems-getting-output-as-string/19503 "2022-06-02T14:43:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![asusdk](https://avatars.discourse-cdn.com/v4/letter/a/b5a626/32.png) [@asusdk](https://forums.powershell.org/u/asusdk)\
**Post date:** [June 2, 2022, 2:43pm UTC](https://forums.powershell.org/t/problems-getting-output-as-string/19503/1 "2022-06-02T14:43:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![matt-bloomfield](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@matt-bloomfield](https://forums.powershell.org/u/matt-bloomfield)\
**Post date:** [June 2, 2022, 2:53pm UTC](https://forums.powershell.org/t/problems-getting-output-as-string/19503/2 "2022-06-02T14:53:27Z")

</div>

Hi, welcome to the forum 👋

Use `Select-Object`

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

```

> **[Select-Object (Microsoft.PowerShell.Utility) - PowerShell](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/select-object?view=powershell-7.2)**
>
> The Select-Object cmdlet selects specified properties of an object or set of objects. It can also select unique objects, a specified number of objects, or objects in a specified position in an array. To select objects from a collection, use the...

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](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/2X/b/bee50c628238f2c076c0504efb6b15f2fb11f002.gif)

---

<div class="post-metadata">

**Author:** ![asusdk](https://avatars.discourse-cdn.com/v4/letter/a/b5a626/32.png) [@asusdk](https://forums.powershell.org/u/asusdk)\
**Post date:** [June 2, 2022, 2:57pm UTC](https://forums.powershell.org/t/problems-getting-output-as-string/19503/3 "2022-06-02T14:57:47Z")

</div>

Works like a charm, Thanks !

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:17pm UTC](https://forums.powershell.org/t/problems-getting-output-as-string/19503/4 "2024-05-16T20:17:52Z")

</div>

Closed on May 16, 2024, 8:17pm UTC


