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?

thal0k
  • 35
  • 3
  • 10

1 Answers1

3

Use -Expandproperty instead of property

Get-WmiObject -Class Win32_ComputerSystem |Select-Object -ExpandProperty Manufacturer
Vivek Kumar Singh
  • 3,223
  • 1
  • 14
  • 27