esxcli of vCO using PowerShell plugin

Hello

I tried to come up with a workflow to run esxicli on an ESXi host commands, I am aware of the different solutions out there including one that uses the vMA as an SSH server, but I would like to give it a try with the plugin from PowerShell. So far, I can connect the vCenter, get the crowd and not even the subject of esxcli by using different examples already on the PowerShell plugin library.

But my problem is that after I get the object esxcli is on the PowerShellRemotePSObject format and I don't know how to work with it.

var sess;
try {
  sess = host.openSession()
  sess.addCommandFromString("Add-PSSnapin VMware.VimAutomation.Core -ErrorAction  SilentlyContinue");
  var invResult = sess.invokePipeline();
  //Show result
  System.log( invResult.getHostOutput() );
  sess.addCommandFromString('Connect-VIServer '+vcenter+' -User user@domain -Password "passw0rd" -Force');
  var invResult = sess.invokePipeline();
  //Show result
  System.log( invResult.getHostOutput() );
  // Get PowerShellRemotePSObject
  sess.addCommandFromString('Get-VMHost -Name '+esxi+' -Server '+vcenter);
  var invResult = sess.invokePipeline();
  //Show result
  System.log( invResult.getHostOutput() );
  var psObject = invResult.getResults();
  if (invResult.invocationState  == 'Failed'){
  System.error(invResult.getErrors());
  }
  else {
  var cmd = sess.addCommandFromString('Get-EsxCli')
  cmd.addParameter('Server', vcenter);
  cmd.addParameter('VMHost', psObject);
  var sessionId = sess.getSessionId();
  var esxcli = System.getModule("com.vmware.library.powershell").invokeCommand(host,sessionId);
  System.log(esxcli);
  }


} catch ( ex ) {
  System.log (ex);
} finally {
  if (sess) {
  host.closeSession( sess.getSessionId());
  }
}


The esxcli object is accessible as $esxcli.software.vib.list () in PowerShell I don't know how to use the PowerShellPSObject to access information or execute methods on it.

Any help is appreciated.

Thank you

Juan.

Hi Juan,

I'm not sure you can call methods from PowerShellPsObjects returned by VCO.  In the meantime, they were serialzed in XML format from the PowerShell script then resérialisé in VCO.  I'm sure that you lose all methods when this happens.

What I've done for similar purposes, use the WF model who calls a PowerShell script externally.  I put all my my logical calls and method in the external PoSH script and at the end pass back the final results to the VCO.  I'm much better with PoSH as VCO, so I put as much intelligence in the PoSH as possible.

Tags: VMware

Similar Questions

  • vCO Appliance Powershell Plugin

    I set up a server of powershell using the following Web page:

    vCO PowerShell plugin | VMware vCenter Orchestrator Blog - VMware Blogs

    I am able to run the final winrm identify command on my desktop (no server powershell). Ute, r I get a nullpointer exception when I try to add the PowerShell host to vCO. I know that this may be due to the fact that my vCO is a device (Linux). Is there a guide somewhere could detail how to set up properly?

    The igaydajiev in the post response: https://communities.vmware.com/message/2308763#2308763 solves the problem.

  • vCO + host Powershell - little doubt

    Good evening everyone,

    I work in my company with automation. We use the vCO to automate tasks.

    Today, we can remotely running scripts and command-line inside the machine virtual linux.

    When a machine virtual linux is supplied at a distance, I can execute a command for puppets or run the bash script, for example.

    I want to run remote commands as on windows server.

    According to my research, it is possible using PowerShell. Right? Is there another way?

    As an example, I want to run the command as follows:

    -install puppets (msiexec /qn /i puppet.msi PUPPET_MASTER_SERVER = 192.168.0.10/l * v log_install.txt)

    -run any bat script;

    Resume my doubts:

    -L' PowerShell host is the same target Windows virtual machine created recently? or it is another virtual machine between the vCO and target VM?

    See you soon!

    Well, technically you can use the Powershell plugin and dynamically configure each virtual newly deployed as the target host computer (temporarily).

    However, if you just need to call a few commands, which seems to be a bit of an overdose.

    Alternatives:

    -Use the powershell plugin, to a "midwife" powershell static host, which then calls the new virtual machines via psexec or remote powershell

    -Use the SSH plugin (in which case you can have a SSH server in the windows model)

    -Use the operations of comments (if you only need vmware tools installed on the Windows machine). Check the package to "get comfortable": comments script package manager

    See you soon,.

    Joerg

  • vCO with Powershell and causing VMware.VimAutomation.Extensions to workflows to hang

    Environment:

    vSphere Version: 5.5

    vCO Version: 5.5.0 build 1281930

    PowerShell Plugin: PowerShell 1.0.3.304


    I have successfully instantiated several Powershell commands in by vCO in the past, including commands PowerCLI. However, when I use the

    "import-module VMware.VimAutomation.Extensions.

    command, the workflow seems to stop. I need this module in order to obtain information of vSAN.


    I know that the module is supposed to be implicitly imported without the need of the declaration when running in a PowerShell command prompt, but I've also had instances where I know that the line is necessary, especially when a Powershell script requires that the module is called from the command line.


    It seems to be the case here because removing the line causes an error "unknown cmdlet", when it tries to parse the command "Get-VsanDiskGroup".




    Any help would be greatly appreciated! Thank you.

    Solution:

    Add: ' Get-childitem | unlock file "before:"

    import-module VMware.VimAutomation.Extensions

  • How to return your hypervisor IPv6 address using powershell?

    Hello

    I'm trying to use powershell to return the IPv6 address of my host esx 5.5 Update 2.  I used powercli 6.0, but when I try to run either:


    Get-VMHostNetworkAdapter | Select VMhost, Name, IP


    or


    Get-VMhost | Get-View | Select Name, @{N = 'IP address'; E = {($_.Config.Network.Vnic |?)} {$_. Device - eq "vmk0"}). Spec.Ip.IpAddress}}

    they all return two empty fields for the IP address.  PowerShell is not able to return to the IPv6 address?

    Thanks in advance.

    Did you try you alreade with Get-EsxCli , and then

    $esxcli.network.ip.interface.ipv6.address.list)

  • PowerShell Plugin and HTTPS domain credentials

    Someone been able to make this work?

    I have configured WinRM on my powershell host and it seems to work fine.  I can connect via negotiate and kerberos very well via HTTPS w / domain credentials.  However, I can't see the powershell plugin to authenticate with a domain service account, it will only connect w / basic authentication enabled by using the local credentials to the host of powershell.

    I tried the following syntax for the username:

    User domain\username

    username@domain

    I happened to notice that I can't connect to the host PowerShell forcing basic authentication using the enter-pssession cmdlet either which brings me to the conclusion that basic authentication cannot make the domain credentials.

    Any ideas would be appreciated.

    > basic authentication cannot field identification information.

    Yes. The first version of the plugin supports basic authentication only and not with the credentials of domain.

    The good news is that in about 2 weeks, an update of the plugin version would be released that would provide support for kerberos.

    Thank you.

  • Typos in Powershell-Plugin objects!

    Hello!

    While testing the new powershell plugin for vCO, I found a misspelled object: PowerShellAutorizationMode should be... AutHorizationMode!

    and in GROUP Action, there is one more in the logging chain: successfully should be successfully at the end...

    Not to be pedantic, but especially misspelling the names of objects causes difficulties to find in the box search and other inconveniences while developing.

    See you soon,.

    Joerg

    powershellplugintypo.jpg

    I pushed this issue within VMware - and I heard that VMware is working on a fix that will be accompanied by an update. I can't share the details, however. Stay tuned.

  • Create the web icon using BlackBerry plugin for Microsoft Visual Studio

    Hi all...

    I am very new to the blackberry application development...

    I want to create web icon on blackberry. I use BlackBerry plugin for Microsoft Visual Studio

    Please give any link sample code or reference on how to create a web icon using BlackBerry plugin for Microsoft Visual Studio.

    Please its urgent.

    Thanks in advance.

    There are two ways that you can do with a BlackBerry.

    (1) you can push an icon on the desktop of users using push of BES or the new WebSignals.  This method requires no code peripheral side, but it requires the code side Server integrated with the BlackBerry Enterprise Server (BES) or our WebSignals public service

    (2) you can create a small Java application that is installed on the device that launches the browser to a specific URL.  You will need to Java plug-in for Eclipse to get there.

  • Querying a database of Oracle9i Enterprise Edition Release 9.2.0.7.0 using PowerShell

    Hi all

    I want to run a query on an Oracle database using powershell and I expect some tips. The Oracle version is Oracle9i Enterprise Edition Release 9.2.0.7.0

    What would be the best way to do this? Can I do this using ODP.Net or something similar, can anyone recommend a resource that détaillerait how to proceed?

    See Powershell - ORA-03111: Break received on the communication channel

  • my app stopped Android location using geolocation plugin detection

    my app stopped Android location using geolocation plugin detection.

    Plugin - < gap: plugin name = "org.apache.cordova.geolocation" / > "

    The code works correctly in the browser, but in the android device, it doesn't.

    {getDeviceCordinate:function()}

    navigator.geolocation.getCurrentPosition (position.onSuccess, position.onError);

    navigator.geolocation.watchPosition (position.onSuccess, position.onError);

    },

    {onSuccess:function(pos)}

    position.LAT = pos.coords.latitude;

    position.LNG = pos.coords.longitude;

    Alert (position.lat, position.lng);

    position. Tim = pos.timestamp;

    position. Status = "success";

    },

    {onError:function(error)}

    position. Reset();

    position. Status = "failed";

    position. Error = error.code;

    position. ErrorCode = error.code;

    }

    Please help me...

    1. do not use the ancient plugin in the repo of deprecated BMPs. Use the latest version of the plugin of NPM, rather

    2. make sure that you wait for the deviceready event before attempting to get a Geolocation.

  • How to use the plugin Cordova customized with AEM Mobile?

    Hello

    I explored the basics of the AEM Mobile over the last days and also tried to use some plugins Cordova mentioned in the Plugins to the application tab. Now, I would like to know how to use a custom Cordova plugin or plugin other than those mentioned in this list in my application.

    Is it possible to achieve today? If Yes, please provide me with the markets / pointers to all documentation which explains the same thing.

    Custom plugins support is not yet available, but on the road map

  • How to use Phonegap Plugin?

    I am a new mobile developer.

    I can make mobile app but I don't use the plugin in dreamweaver. How should I use?
    Can you explain step by step?
    I couldn't find the source on this subject on the internet

    Thank you.

    Dreamweaver CS5.5 and CS6 had built-in support for PhoneGap, but this has been abandoned since Dreamweaver CC because frequent updates to PhoneGap made it impossible for Dreamweaver keep pace. If you want to use PhoneGap, you can create your mobile application in Dreamweaver, but you must download the files Adobe PhoneGap build to compile them.

  • PowerShell Plugin only supports version 2.0 of Powershell?

    I'm looking, and it seems that the PowerShell Plugin only supports version 2.0 of Powershell.   Microsoft is currently at version 5.0.  What is the problem?  VMware has renounced this Plugin?  I'm wrong and it really supports a newer version of Powershell?

    See here: Technical preview of VMware vCenter Powershell plugin 1.0.x version

    We supported until PowerShell 4.0 since the 1.0.4 version of the plug-in

  • Import of groups of ports in vDS using powershell and

    I have a VCenter 5.5 with a 5.5 vDS. I'm trying to import several groups of ports in the vDS using powershell. The script is below. I'm under problems in trying to put the "Teaming and Failover" option to 'Route based on a physical load' by default 'Route based on originating virtual port' for the Group of individual ports, I know that I can do from the client, but I would like if possible do it with a script. Someone point me in the right direction? Port groups to import very well with all the correct settings, that I put, but I can't seem to find how to set the load balancing policy.

    to connect-viserver 'myvcenter '.

    $vds = Get VDSwitch -name "my Switch VD"

    Import-Csv c:\temp\vdsportgroup.csv | % {New-VDPortgroup -VDSwitch $vds -Name $_. Name -VlanId $_. {VlanId -NumPorts $_.ports}







    Edit: Scratch that I wrote earlier, it was with the older VDS cmdlets. This should work:

    Get-VDPortgroup MyVdPg | Get-VDUplinkTeamingPolicy | Game-VDUplinkTeamingPolicy - LoadBalancingPolicy LoadBalanceLoadBased

    You can simply direct the Group of newly created port directly object to cmdlets like this:

    Import-Csv c:\temp\vdsportgroup.csv | % {New-VDPortgroup - VDSwitch $vds - name $_.} Name - VlanId $_. VlanId - NumPorts $_.ports | Get-VDUplinkTeamingPolicy | Game-VDUplinkTeamingPolicy - LoadBalancingPolicy LoadBalanceLoadBased}

  • decrease the RAM on vsphere 5.5 clients using powershell

    Hello

    I have client vsphere with 4 GB ram deployed and the wish to reduce this amount to 1 GB, they are held in w8.1

    can I do this using the powershell cli software and the script?

    I can do what everyone turned off, then decreasing RAM within the interface of vsphere and then power it back on, but I need a better and faster way

    and if we can do this using powershell is a ready to use script, I can use or change?

    Thank you

    Hello

    With PowerCLI you can use cmdlets Set - VM with something MemoryGB parameter like below:

    Get - VM VM1. Set-VM - MemoryGB 2

    or

    Get - VM $VMName | Set-VM - MemoryGB $memorysize - confirm: $false

    If you want to feed off the coast of the first virtual machine, you can do

    Get - VM $VMName | Stop-VM - confirm RunAsync: $false

    #or

    Get - VM $VMName | Stop-VMGuest-confirm: $false

    #set memory in GB

    Get - VM $VMName | Set-VM - MemoryGB $memorysize - confirm: $false

    #then light

    Get - VM $VMName | Start-VM - confirm RunAsync: $false

    References:

    vSphere PowerCLI reference Set - VM: vSphere 5.5 Documentation Center

    VMware KB: Management of the virtual machines using PowerCLI

    Thank you

    Bayu

Maybe you are looking for