0

In Powershell I run a get-wmiobject on Win32_OperatingSystem, and it returns several properties through the select-object cmdlet. How to I get the values loaded to variables instead of a list,since I need to further process them? I tried several methods without avail. If I can get this accomplished without the select-object cmdlet, that would also work.

get-wmiobject -namespace root\CIMV2 -class Win32_OperatingSystem -computername $servername | Select-Object SystemDirectory,caption,BuildNumber

1 Answer 1

2

It seems you know how to assign variables, so I'm not sure what the hang up is here. You would simply run the GWMI command as the value of a variable such as:

$Results = get-wmiobject -namespace root\CIMV2 -class Win32_OperatingSystem -computername $servername

Then reference the properties of the object you just created such as:

$Results.SystemDirectory
$Results.caption
$Results.BuildNumber
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.