0

I've been utilizing Powershell to query items from a host using the "Get-WmiObject" cmdlet and the associated classes as part of a script. In order to find the Computer Manufacturer I use the following Get-WMIObject command to output the returned property to a variable:

PS C:\temp\PS> $VmPhys = Get-WmiObject -Class Win32_ComputerSystem |Select-Object -Property Manufacturer
PS C:\temp\PS> write-host = $VmPhys
= @{Manufacturer=Dell Inc.}

The issue I have is that when I send the property value to the variable it also includes the property name and not just the value as per the above.

PS C:\temp\PS> Get-WmiObject -Class Win32_ComputerSystem |Select-Object -Property Manufacturer

Manufacturer
------------
Dell Inc.

Is there a way to exclude the property name and only export the value eg "Dell Inc." to the variable?

1 Answer 1

2

Use -Expandproperty instead of property

Get-WmiObject -Class Win32_ComputerSystem |Select-Object -ExpandProperty Manufacturer
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.