locked
Import powercli in powershell at runtime RRS feed

  • Question

  • Hi,

    I am using powershell in my .Net applicatoin with C#. Now I have some operations to do with VMWare for which I have installed powercli as well and fulfilled the purpose. But now I also need to install powercli on the server which I want to avoid. As I went through google I found that we can install powercli module from the command promt as well using  

    "Install-Module -Name VMware.PowerCLI –Scope CurrentUser"

    Just wondering if it is required for me to install powercli on the server as well ? can something be implemented so that I can install powercli module on the runtime and use the methods? 

    Please suggest if I can avoit installing powercli on the server.

    Thanks & Regards,
    Girish Nehte

    Tuesday, June 13, 2017 1:59 PM

Answers

  • Hi Girish,

    there is no way around "storing" the module-files somewhere the server can access and load them. Whether you want to call that installing it is really up to you.

    There is no way to do it in memory, unless you are willing to decompile the binaries ... which'd be fairly pointless to begin with.

    That said, I really recommend providing the module in a regular fashion - all alternatives are a hassle for no real benefit to show for it.

    Cheers,
    Fred


    There's no place like 127.0.0.1

    • Marked as answer by Girish Nehte Thursday, June 22, 2017 10:43 AM
    Tuesday, June 13, 2017 2:32 PM
  • Hi,

    You can use powershell remoting to import module from remote computer:

    $ses=new-pssesion -computername comp_with_module
    Import-module VMware.PowerCLI -PSSession $ses

    Note that all your VMWare commands will be ran in that remote session, so you depends on availability of computer where module is installed.

    Sergei.

    • Proposed as answer by Hello_2018 Thursday, June 22, 2017 6:46 AM
    • Marked as answer by Girish Nehte Thursday, June 22, 2017 10:43 AM
    Tuesday, June 13, 2017 3:27 PM
  • You can usually import a module from anywhere on the network by just using the full path to the psm1 file.

    import-module '\\alpha\d$\scripts\modules\SNMP\1.0.0.1\SNMP.psm1'

    This will only work if the module is designed correctly and all Net prerequisites are installed on the local system.


    \_(ツ)_/

    • Proposed as answer by Hello_2018 Thursday, June 22, 2017 6:46 AM
    • Marked as answer by Girish Nehte Thursday, June 22, 2017 10:43 AM
    Tuesday, June 13, 2017 6:40 PM

All replies

  • Hi Girish,

    there is no way around "storing" the module-files somewhere the server can access and load them. Whether you want to call that installing it is really up to you.

    There is no way to do it in memory, unless you are willing to decompile the binaries ... which'd be fairly pointless to begin with.

    That said, I really recommend providing the module in a regular fashion - all alternatives are a hassle for no real benefit to show for it.

    Cheers,
    Fred


    There's no place like 127.0.0.1

    • Marked as answer by Girish Nehte Thursday, June 22, 2017 10:43 AM
    Tuesday, June 13, 2017 2:32 PM
  • Hi,

    You can use powershell remoting to import module from remote computer:

    $ses=new-pssesion -computername comp_with_module
    Import-module VMware.PowerCLI -PSSession $ses

    Note that all your VMWare commands will be ran in that remote session, so you depends on availability of computer where module is installed.

    Sergei.

    • Proposed as answer by Hello_2018 Thursday, June 22, 2017 6:46 AM
    • Marked as answer by Girish Nehte Thursday, June 22, 2017 10:43 AM
    Tuesday, June 13, 2017 3:27 PM
  • You can usually import a module from anywhere on the network by just using the full path to the psm1 file.

    import-module '\\alpha\d$\scripts\modules\SNMP\1.0.0.1\SNMP.psm1'

    This will only work if the module is designed correctly and all Net prerequisites are installed on the local system.


    \_(ツ)_/

    • Proposed as answer by Hello_2018 Thursday, June 22, 2017 6:46 AM
    • Marked as answer by Girish Nehte Thursday, June 22, 2017 10:43 AM
    Tuesday, June 13, 2017 6:40 PM