Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 224018

Re: Get-VM | Select-Object question

$
0
0

The command is not that hard to understand and use once you understand what it's doing. Everything up to the @ sign is just selecting those properties to display them to the output. Below is what the rest of that line is doing.

 

@{N="Datastore";E={$_ | Get-Datastore}}

N="Datastore" - This creates another property to display in the output called "Datastore". This can be written longer as Name="Datastore".

E={$_ | Get-Datastore} - So the second part of this is an expression that gives you the value for the property "Datastore" in the output. This particular one takes the input from the pipe, in this case the Get-VM command, and then pipes that into the the Get-Datastore cmdlet which returns the Datastore that the VM resides on. This can be written longer as Expression={$_ | Get-Datastore}.

 

The rest of the brackets and symbols is just syntax stuff. As far as learning this stuff, I would suggest just getting into it using lots of Google and trying to learn by dissecting other people's code to learn neat little tricks to use for what you want to do.


Viewing all articles
Browse latest Browse all 224018

Trending Articles