PowerCLI

 View Only
  • 1.  Is it possible to load only needed powercli cmdlets?

    Posted Nov 12, 2012 05:47 PM

    I am wondering if there is way to load only the required powercli cmdlets rather than the entire 'VMware.VimAutomation.Core' pssnapin as this takes approx 20-30 seconds to load?

    I have written some scripts to be used by our monitoring system and it's unacceptable for there to be a 20-30 second delay while powercli is loaded, we need the scripts to execute as quickly as possbile.

    Note I've already disabled 'Check for publisher's certificate revocation' so it is not the the certificate check causing the delay.

    With regular powershell modules it's possible to load only individual cmdlets and not the entire module .E.g  "Import-Module ActiveDirectory -Cmdlet Get-ADUser,Get-ADGroup". But as Powercli is a pssnapin and not a module I can't find an equivalent way of doing this.

    Really all I'm looking to do is speed up the time it takes to load the 'VMware.VimAutomation.Core' pssnapin or find a way to load just the cmdlets I need, whatever will work so I can get powercli to load in less than 5 seconds to be able to execute my scripts.



  • 2.  RE: Is it possible to load only needed powercli cmdlets?

    Posted Nov 12, 2012 05:54 PM

    Afaik that is not possible, in fact this is 1 of the differences between a PSSnapin and a Module.

    A PSSnapin is 1 or more .Net assemblies that need to be loaded, a module has much more metadata, which allow you to do things like the Cmdlet parameter on the Import-Module cmdlet



  • 3.  RE: Is it possible to load only needed powercli cmdlets?

    Posted Nov 12, 2012 06:04 PM

    Thanks for the clarification between pssnapin & module.

    So if I can't load just the cmdlets I need are there any tricks to get the powercli pssnapin to load any quicker? A 20-30 second delay for this to load is just to long for what I'm trying to do.



  • 4.  RE: Is it possible to load only needed powercli cmdlets?

    Posted Nov 12, 2012 06:09 PM


  • 5.  RE: Is it possible to load only needed powercli cmdlets?

    Posted Nov 12, 2012 06:28 PM

    LucD wrote:

    Did you already apply this How to speed-up the execution of the first PowerCLI cmdlet

    Here's the 5.0 and 5.1 version of these commands if you're using a more recent version of PowerCLI.  I forgot about the ngen.exe fix... haven't ever really needed it myself.

    http://vnugglets.com/2011/11/speed-up-first-powercli-5-cmdlet.html



  • 6.  RE: Is it possible to load only needed powercli cmdlets?

    Posted Nov 13, 2012 04:41 PM

    OK I have narrowed down the issue.

    The host I'm running PowerCLI on has no internet access, but it can still get internet name resolution (DNS) and ping hosts on the internet, port 80 to the internet is completely blocked though.

    I've run a Wireshark capture when starting up PowerCLI and you can see that even though 'Check for publisher's certificate revocation' is disabled it is still trying to communicate to something on the internet. The source port is 59338, destination is 193.45.10.136 port 80 and of course this communication fails.

    If I disconnect the network card PowerCLI starts in 3 seconds, with the network card enabled it takes 17 seconds! So there is definitely still some communication being attempted which is causing PowerCLI to take longer to startup, does anybody know what this is and how to disable it?

    I know I could probably workaround this by disabling internet name resolution but doing so for this host only will not be easy, better if I can simply disable whatever is still trying to communicate to the internet when PowerCLI starts.



  • 7.  RE: Is it possible to load only needed powercli cmdlets?

    Posted Nov 13, 2012 04:45 PM

    Did you already try changing the WebOperationTimeoutSeconds through the Set-PowerCLIConfiguration cmdlet ?



  • 8.  RE: Is it possible to load only needed powercli cmdlets?

    Posted Nov 13, 2012 05:03 PM

    Thanks for the suggestion, I've set 'weboperationtimeoutseconds' to 1 (was at default of 300), but the behaviour is still the same. PowerCLI still takes 17 seconds to start.



  • 9.  RE: Is it possible to load only needed powercli cmdlets?

    Posted Nov 14, 2012 05:23 PM

    Are you by any chance running this in a PowerShell v2 engine against .Net 4 (instead of .Net 3.5) ?

    There are some know issues with PS v2 and .Net 4, including slow startup times.



  • 10.  RE: Is it possible to load only needed powercli cmdlets?

    Posted Nov 12, 2012 06:05 PM

    I don't think it's possible.

    Is the system from which you are running PowerCLI disconnected from the internet?  Disabling the certificate check really should only apply in that scenario.  I'm not aware of any other tricks really... it usually only takes a few seconds for me.  On my VM Workstation lab that is not connected to the Internet, it takes less than 10 seconds after disabling the certificate checks.

    Are you running the latest patch for whatever version of PowerCLI you are using?  Same for .Net Framework?