lara400
lara400

Reputation: 4736

how to amend formatting of output

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

Answers (2)

Shay Levy
Shay Levy

Reputation: 126752

Another way:

$CompDes = Get-WmiObject -Class Win32_OperatingSystem | Foreach-Object {$_.Description}

Upvotes: 0

MikeM
MikeM

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

Related Questions