VMware Cloud Community
vinay1
Enthusiast
Enthusiast

what is gpm in vmware powercli?

In powerCLI

we use  commands like, get-vmhost, add-vmhost, etc, my concerned is about gpm

gpm add-vmhost

gpm get-vmhost

what is gpm and its role in vmware?

13 Replies
Troy_Clavell
Immortal
Immortal

thread moved to VMware vSphere™ PowerCLI Community

Reply
0 Kudos
Dave_Mishchenko
Immortal
Immortal

Reply
0 Kudos
LucD
Leadership
Leadership

When you encounter one of the cryptic aliases, you can always do a

Get-Alias gpm

to find out which cmdlet or function is behind it.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
vinay1
Enthusiast
Enthusiast

Hi LUCD,

can u please elaborate about gpm in detail. i need to understand clearly.

Reply
0 Kudos
chriswahl
Virtuoso
Virtuoso

GPM details are here: http://halr9000.com/article/507

VCDX #104 (DCV, NV) ஃ WahlNetwork.com ஃ @ChrisWahl ஃ Author, Networking for VMware Administrators
Reply
0 Kudos
TdisalvoOrinoco
Enthusiast
Enthusiast

Hi,

I am just starting off with PowerCLI and I am working though some of the TrainSignal Video training.  What I do not understand is that the gpm commandlet seems like it is auotmatically loaded on the training, but I cannot run it.

I have tried to download the Get-Parameter.ps1 from http://halr9000.com/article/507.  I saved it to the drive.  I made sure that my execution policy was set to allow remote signed and I tried executing it from the PowerCLI 5.0.1 interface with the complete path.

I still get Get-Command cannot validate argument on parameter 'Name"

Even if I am able to get this to run, how do I make it so whenever I am logging into the PowerCLI this Commandlet is already loaded.  I am sorry if this is a total noob question, but I gott start somewhere.  Any 101 places to learn about PowerCLI is apreciated as well.

Thanks

halr9000
Commander
Commander

My bad! I thought I made clear what gpm was and how I used it.

My signature used to be pretty, but then the forum software broked it. vExpert. Microsoft MVP (Windows PowerShell). Author, Podcaster, Speaker. I'm @halr9000
Reply
0 Kudos
TdisalvoOrinoco
Enthusiast
Enthusiast

Hal,

I am sure that it is clear to people who have more PowerShell experince than I do.  I am just getting my feet wet.

It looks like at one point it was a  dot source file and then you updated it to standalone.

Where would I set the paramater to load this as part of what load when PowerCLI is loading?  Would I just add that to the Target of the VMware vSphere PowerCLI Properties?

I am assuming for that to work I would have to be able to run the .ps1 file from a command prompt without a problem.

Reply
0 Kudos
halr9000
Commander
Commander

gpm is a function which I wrote. It fills a gap which I think (and have thought for years) should have been covered with a core PowerShell cmdlet. That gap is this:

- Parameters and parametersets are not as obvious as they should be

To an extent, the PowerShell team has finally listened, and when you see PowerShell v3 (shipping when Windows 8 ships), you will see that the ISE (the graphical console and editor which ships with PowerShell) has a function called Show-Command. It goes a long way towards bridging the gap. If you load up the PowerShell v3 beta, you can see this in action today.

That said, most people won't be on v3 for a long time, and Show-Command only works in the ISE, not in the character-mode console.

I felt so strongly about this gap, that when I wrote my book, and when I published the training videos with TrainSignal, I always included mention of gpm and showed how to use it so that others could quickly see a listing of parameters in a table that shows the relationships between the different sets of parameters. If I were writing my book today, I'd make the same decision again.

That said, I probably should have put more thought into making 'gpm' as self-supporting as possible. More documentation, that sort of thing. Unfortunately, these days, with my job and my family, I hardly have time to participate on these forums like I used to.

What I recommend now, is that you check out this blog post by Shay Levy, another PowerShell MVP: http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2010/05/03/get-parameter-learn-more-about-y...

After reading that, grab the latest version of his function (as of today) which is here: http://poshcode.org/3161

For those interested, my function has also been updated by others, on PoshCode, and that current version is here: http://poshcode.org/2815

The reason that I recommend Shay's version is twofold:

1. It works great

2. He has more time to support it Smiley Happy Leave a comment on his blog if you need help with it.

That said, to get either one working (or my original one), you MUST learn how to use functions. This is a good thing--you'll need to know this to go very far in PowerShell anyways. There are many resources to do so. My current favorite intro book to recommend is Don Jones' Powershell in a Month of Lunches. You can find more about it and some others here: http://powershellbooks.com/. He's also got some free videos up on Youtube, maybe one of them deals with functions, I'm not sure.

Also be sure to read every word of the built-in help topic for functions. You can get to it by typing this into a shell: "help about_functions".

Very long story short:

1. Grab the code for get-parameter

2. Put it in a file named myPowerShellStuff.ps1

3. Dot-source it in your shell, (which means to load it into your current scope) by typing ". .\myPowerShellStuff.ps1"

4. Profit!

Then...learn about modules and how you can put your own functions into a module. Smiley Happy

HTH

My signature used to be pretty, but then the forum software broked it. vExpert. Microsoft MVP (Windows PowerShell). Author, Podcaster, Speaker. I'm @halr9000
Reply
0 Kudos
TdisalvoOrinoco
Enthusiast
Enthusiast

Thanks for the reply, and the direction.  I have a lot of reading to do:-)

Reply
0 Kudos
halr9000
Commander
Commander

Another note: look for Get-Parameter to be included in the next release of PSCX (http://pscx.codeplex.com/). I just arranged for this to happen, so that should make things smoother next time you want to grab it. Plus, PSCX has plenty of other cool stuff in it.

My signature used to be pretty, but then the forum software broked it. vExpert. Microsoft MVP (Windows PowerShell). Author, Podcaster, Speaker. I'm @halr9000
Reply
0 Kudos
dm10169
Contributor
Contributor

Hal,

I'm watching your TrainSignal Videos on PowerCLI and in your video your started used 'gpm' and stated, "I'll show you in a minute how I created that script", but you never did and you continued to use it through-out your lecture.  I have spent 2 hours now trying to figure out how to use gpm.  I've download your version and the other ones you mentioned, but I'm unable to get it work properly within PowerCLI.  I have have tried to dot source it, like you said

. .\name.ps1 but that didn't work, I tried

. ./myPowerShellStuff/ps1

dot space dot forward (tried backwards as wel) dot ps1

Can you please kindly explain to me how I can utilize the gpm inside of PowerCLI, it would be much appreciated.

Step 1 - Get Code

Step 2 - Save to file named gpm.ps1

Step 3 -

Step 4 -

Step 5 -

Thanks

halr9000

Reply
0 Kudos
hari_kotha
Contributor
Contributor

@dm10169

You can try this way and it worked for me.

You have to run the script every time you need to find get parameters and  input the cmdlet you are looking for.

PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> .\myPowershellscript.ps1

cmdlet myPowershellscript.ps1 at command pipeline position 1

Supply values for the following parameters:

CommandName[0]: Get-VMHost

CommandName[1]:

    Command: VMware.VimAutomation.Core/Get-VMHost

    Set:     Default

Name                   Aliases      Position Mandatory Pipeline ByName Provider        Type

----                   -------      -------- --------- -------- ------ --------        ----

Datastore              {da}         Named    False     True     False  All             StorageResource[]

Location               {l}          Named    False     True     False  All             VIContainer[]

Name                   {na}         0        False     False    False  All             String[]

NoRecursion            {no}         Named    False     False    False  All             SwitchParameter

PipelineVariable       {pv, pi}     Named    False     False    False  All             String

Server                 {se}         Named    False     False    False  All             VIServer[]

State                  {st}         Named    False     False    False  All             VMHostState[]

    Command: VMware.VimAutomation.Core/Get-VMHost

    Set:     SecondaryParameterSet

Name                   Aliases      Position Mandatory Pipeline ByName Provider        Type

----                   -------      -------- --------- -------- ------ --------        ----

Datastore              {da}         Named    False     True     False  All             StorageResource[]

Location               {l}          Named    False     True     False  All             VIContainer[]

Name                   {na}         0        False     False    False  All             String[]

NoRecursion            {no}         Named    False     False    False  All             SwitchParameter

PipelineVariable       {pv, pi}     Named    False     False    False  All             String

ResourcePool           {r}          Named    False     False    False  All             ResourcePool[]

Server                 {se}         Named    False     False    False  All             VIServer[]

VM                     {vm}         Named    False     True     False  All             VirtualMachine[]

    Command: VMware.VimAutomation.Core/Get-VMHost

    Set:     DistributedSwitch

Name                   Aliases      Position Mandatory Pipeline ByName Provider        Type

----                   -------      -------- --------- -------- ------ --------        ----

DistributedSwitch      {di}         Named    False     True     False  All             DistributedSwitch[]

Name                   {na}         0        False     False    False  All             String[]

PipelineVariable       {pv, pi}     Named    False     False    False  All             String

Server                 {se}         Named    False     False    False  All             VIServer[]

    Command: VMware.VimAutomation.Core/Get-VMHost

    Set:     ById

Name                   Aliases      Position Mandatory Pipeline ByName Provider        Type

----                   -------      -------- --------- -------- ------ --------        ----

Id                     {i}          Named    False     False    False  All             String[]

PipelineVariable       {pv, pi}     Named    False     False    False  All             String

Server                 {se}         Named    False     False    False  All             VIServer[]

PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI>