8

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

1 Answer 1

14

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?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.