Make PowerCLI run faster

I came across this article: http://blogs.vmware.com/vipowershell/2011/06/how-to-speed-up-the-execution-of-the-first-powercli-cmdlet.html and decided to test the steps out myself:

[cc lang=”dos”]
REM View the following link for details: http://blogs.vmware.com/vipowershell/2011/06/how-to-speed-up-the-execution-of-the-first-powercli-cmdlet.html

C:\Windows\Microsoft.NET\Framework\v2.0.50727\ngen.exe install “VimService41.XmlSerializers, Version=4.1.0.0, Culture=neutral, PublicKeyToken=10980b081e887e9f”
C:\Windows\Microsoft.NET\Framework\v2.0.50727\ngen.exe install “VimService40.XmlSerializers, Version=4.0.0.0, Culture=neutral, PublicKeyToken=10980b081e887e9f”
C:\Windows\Microsoft.NET\Framework\v2.0.50727\ngen.exe install “VimService25.XmlSerializers, Version=2.5.0.0, Culture=neutral, PublicKeyToken=10980b081e887e9f”

REM If you are running on 64-bit OS, you need to run the following as well:
if %PROCESSOR_ARCHITECTURE% == AMD64 (
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\ngen.exe install “VimService41.XmlSerializers, Version=4.1.0.0, Culture=neutral, PublicKeyToken=10980b081e887e9f”
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\ngen.exe install “VimService40.XmlSerializers, Version=4.0.0.0, Culture=neutral, PublicKeyToken=10980b081e887e9f”
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\ngen.exe install “VimService25.XmlSerializers, Version=2.5.0.0, Culture=neutral, PublicKeyToken=10980b081e887e9f”
)
[/cc]

Running the NGEN.EXE commands made my connect-viserver cmdlet run a bit faster…it now takes 8 seconds the first time instead of 12. Not much savings, but if I had time to waste I wouldn’t be using PowerCLI in the first place!

This entry was posted in Scripting, Virtualization. Bookmark the permalink.

3 Responses to Make PowerCLI run faster

  1. Parag Mehta says:

    I am getting the following error.. any help is highly appreciated

    C:\Users\pmehta>C:\Windows\Microsoft.NET\Framework\v2.0.50727\ngen.exe install ”
    VimService25.XmlSerializers, Version=2.5.0.0, Culture=neutral, PublicKeyToken=10
    980b081e887e9f”
    Microsoft (R) CLR Native Image Generator – Version 2.0.50727.4927
    Copyright (c) Microsoft Corporation. All rights reserved.
    Installing assembly VimService25.XmlSerializers, Version=2.5.0.0, Culture=neutra
    l, PublicKeyToken=10980b081e887e9f
    Compiling assembly mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToke
    n=b77a5c561934e089 …
    mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    Compiling assembly VimService25.XmlSerializers, Version=2.5.0.0, Culture=neu
    tral, PublicKeyToken=10980b081e887e9f …
    WARNING: Cannot hardbind to mscorlib, Version=2.0.0.0, Culture=neutral, PublicKe
    yToken=b77a5c561934e089 because dependency does not have a native image (check F
    usLogVw for reason)

  2. I haven’t seen this error before, but I may have failed to mention something that is identified on the source VMware article: “you need to run the prompt as administrator”. That’s the only thing I can think would cause such an error message.

  3. You can use my PowerShell Install-PowerCLIXmlSerializer function to pre-compile the PowerCLI XML Serializers every time you install a new PowerCLI version:
    http://rvdnieuwendijk.com/2012/02/18/function-to-speed-up-the-execution-of-the-first-powercli-cmdlet/

Leave a Reply

Your email address will not be published.

*

Notify me of followup comments via e-mail. You can also subscribe without commenting.