Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 8583

Trying to understand output

$
0
0

If I run the following command it displays my output in 2 columns like this:

 

collection name          collection ID

collection name          collection ID

 

Get-WmiObject -ComputerName sfrvmsccmcn1 -Namespace "root\SMS\Site_CN1" -Query "Select * from SMS_Collection" | Select-Object -Property Name, CollectionID 

 

BUT.....when I assign this command to a variable and then use Write-Host it changes the format.

 This code:

 

$READ = Get-WmiObject -ComputerName sfrvmsccmcn1 -Namespace "root\SMS\Site_CN1" -Query "Select * from SMS_Collection" | Select-Object -Property Name, CollectionID 

Write-Host $Read

 

will write all data to 1 line.

collection name   collection ID, collection name   collection ID, collection name   collection ID,   etc.....

 

Why?    and how do I make it output to 2 columns?   I've tried the -NewLine switch but it did not help.  

 


Viewing all articles
Browse latest Browse all 8583

Trending Articles