Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select multiple columns in powershell

This is probably a very noob powershell question, but here goes.

I want to select only a few properties for display when using a particular cmdlet, but when I club them using the select statement, only the first one in the select statement is shown.

E.g., the cmdlet I'm interested in is Get-VM

When I execute Get-VM on its own, I get a few default fields:

    Name                   State       CPUUsage(%) MemoryAssigned(M) Uptime     Status
----                   -----       ----------- ----------------- ------     ------
everything             OffCritical 0           0                 00:00:00   Cannot connect to virtual machine configuration storage
SCOrch                 Running     0           1393              1.05:02:16 Operating normally
Server 2012 Base Image Off         0           0                 00:00:00   Operating normally
Server 2012 DC         Off         0           0                 00:00:00   Operating normally

Now, say I want to just display Name and State. I tried Get-VM | select Name,State I only get the Name column returned

Name
----
everything
SCOrch
Server 2012 Base Image
Server 2012 DC

I only get the first argument passed to the select statement returned, it simply ignores the other ones. How can I return only the columns I want?

Thanks in advance

like image 918
NullPointer Avatar asked Mar 27 '13 15:03

NullPointer


1 Answers

I would suspect issue with size of buffer/ window. If buffer is wider than buffer than some columns may become "invisible". State, as an [enum] (read: [int] in disguise) will be always right-aligned by default. Name ([string]) will be aligned left. Suspect you would see everything by simply changing order.

Take a look at this screenshots:

buffer wider than window

buffer matches window width

This is same command, I just changed width of the window to match width of my buffer... Looks familiar?

like image 165
BartekB Avatar answered Oct 13 '22 16:10

BartekB