VMware Cloud Community
DZ1
Hot Shot
Hot Shot
Jump to solution

Really confused about not seeing a parameter

I was trying to use New-PSDrive to create drives for the datastore in my datacenter.  I have created individual drives before, but this time I was going to use a Get-datastore | foreach {}...and create drives for each datastore.  Well, to make a long question short, I looked back at some older discussions, and I saw a -datastore parameter.  The help for New-PSDrive does not show that parameter, the intellisense does not pick it up (I know I can't rely on it) in PowerGUI or the Windows 7 ISE.  How could I have found out via help, that -datastore was a parameter that I could/had to use?

I'm using PowerShell 4.0 with PowerCLI 5.5 R2

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try to execute the Initialize-PowerCLIEnvironment.ps1 script that you find in the PowerCLI installation folder in the Scripts subfolder.


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

View solution in original post

Reply
0 Kudos
7 Replies
LucD
Leadership
Leadership
Jump to solution

I'm not sure where you saw the Datastore parameter, but in the latest PowerCLI build there is a Location parameter that takes a datastore as argument.

There is an example and further info in the User's Guide in Create a New Custom Datastore Drive


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

Reply
0 Kudos
DZ1
Hot Shot
Hot Shot
Jump to solution

I guess it may be more of a PowerShell issue, than PowerCLI.  The post I was looking at is here: performance of VimDatastore PSDrive  Even looking at the help online, I don't see a location parameter, and I had created new PS drives before, but I kept getting an error when I was trying to create a drive in a foreach statement.  I updated my help, but even now, there isn't a mention of parameters for -datacenter or -location.  But the -datastore parameter worked.

Obviously the parameters are there, even if they don't show up in help and the intellisense does not pick them up, but they don't appear as options in Get-Help.  Thanks LucD for the help.  Oh, and thanks for the many years of scripting help.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

When you start your PowerCLI session with the provided shortcut, it will execute an initialisation script.

In there the different PowerCLI pssnapins are loaded.

The core pssnapin also initiates the vimdatastore psprovider.

Together with that provider there are 2 new functions (New-DatastoreDrive and New-VIInventoryDrive).

The vimdatastore provider also intercepts the Datastore parameter on the New-PSDrive cmdlet.

So you can do

$ds = Get-Datastore -Name MyDS

New-PSProvider -Name ds -PSProvider vimdatastore -Location $ds -Root '\'

but also

$ds = Get-Datastore -Name MyDS

New-PSProvider -Name ds -PSProvider vimdatastore -Datastore $ds -Root '\'

But the functions that are added are even easier to use

$ds = Get-Datastore -Name MyDS

New-DatastoreDrive -Name ds -Datastore $ds

And I admit, the documentation on the psproviders and the added functions could be a bit better.


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

Reply
0 Kudos
DZ1
Hot Shot
Hot Shot
Jump to solution

Thanks LucD, this may be beyond what the forums are for, but I don't see New-DatastoreDrive or New-VIInventoryDrive when I load the VM* snap-ins in PowerGUI or the built-in Windows 7 ISE.  I do see them if I go to the actual "VMware vSphere PowerCLI 5.5 Release 2" program.  I ran a Get-Command on both of them, and I see they are functions.  For some reason, they don't load with the ISE, even if I remove and add the VM* snap-in.

It's not that big of an issue, but it is odd. I attached screenshots as well.

Reply
0 Kudos
DZ1
Hot Shot
Hot Shot
Jump to solution

Oh, almost forgot.  Even though I could not see the commands in PowerGUI or the Windows 7 ISE, I did try and run them, but I got the usual "not recognized as the name of a cmdlet, function, etc".  It's not a big deal though, just an odd one.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Try to execute the Initialize-PowerCLIEnvironment.ps1 script that you find in the PowerCLI installation folder in the Scripts subfolder.


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

Reply
0 Kudos
DZ1
Hot Shot
Hot Shot
Jump to solution

Well, as always, you did it again.  You must get bored having so little of a challenge. Smiley Happy  Seriously, thanks again, that loaded the functions.  PowerGUI does not show them in intellisense, but I'm going to try and remove the cache or something that Alan Renouf helped me with in another post.  This is good enough, and I'll make sure I keep that in my notes.  Many, many thanks.

Reply
0 Kudos