Reputation: 4736
when I do the below I get the format as "@{xxx}"...how do I just get the computer description and none of the the other formatting around it?
$CompDes = Get-WmiObject -Class Win32_OperatingSystem |Select Description
Write-Host "Computer Description $CompDes"
Output:
Computer Description @{Description=TESING_SERVER}
Thanks,
Upvotes: 2
Views: 73
Reputation: 126752
Another way:
$CompDes = Get-WmiObject -Class Win32_OperatingSystem | Foreach-Object {$_.Description}
Upvotes: 0
Reputation: 13631
$CompDes = Get-WmiObject -Class Win32_OperatingSystem | Select -exp Description
Write-Host "Computer Description $CompDes"
-exp
is short for -ExpandProperty
. It gets the value of the specified property.
Upvotes: 2