Home > Blogs > VMware vCenter Orchestrator Blog > Monthly Archives: December 2011

Monthly Archives: December 2011

vCO PowerShell plug-in

vCenter Orchestrator + PowerShell plug-in = vCenter Orchestrator on steroids. Windows PowerShell is command-line shell and scripting language designed especially for system administration, as such he has wide-spread industry support. There are PowerShell scripts already written for most of the task you will ever need. Enabling vCO user to use and reuse those scripts is one of the most exiting feature of vCO. In short vCO PowerShell plug-in is used to call PowerShell scripts and cmdlets from Orchestrator actions and workflows, and to work with the result.

PowerShell host configuration

One of the drawbacks of PowerShell is that it is windows dependant. That's why we need a Windows machine with PowerShell instaled on it (PowerShell host). Connection between the PowerShell plug-in and PowerShell host machine is established using WinRM or OpenSSH. To configure PowerShell plugin make sure that winrm service is installed on the PowerShell host and run trough following configuration steps.

Procedure

  • Run the following command to set the default WinRM configuration values.
    c:\> winrm quickconfig
  • (Optional) Run the following command on the WinRM service to check whether a listener is running, and verify the default ports.
    c:\> winrm e winrm/config/listener The default ports are 5985 for HTTP, and 5986 for HTTPS.
  • Enable basic authentication on the WinRM service.
    • Run the following command to check whether basic authentication is allowed.
      c:\> winrm get winrm/config
    • Run the following command to enable basic authentication.
      c:\> winrm set winrm/config/service/auth @{Basic="true"}
  • Run the following command to allow transfer of unencrypted data on the WinRM service.
    c:\> winrm set winrm/config/service @{AllowUnencrypted="true"}
  • Enable basic authentication on the WinRM client.
    • Run the following command to check whether basic authentication is allowed.
      c:\> winrm get winrm/config
    • Run the following command to enable basic authentication.
      c:\> winrm set winrm/config/service/auth @{Basic="true"}
  • Run the following command to allow transfer of unencrypted data on the WinRM client.
    c:\> winrm set winrm/config/client @{AllowUnencrypted="true"}
  • [Updated] Run the following command to enable winrm connections from vCO host.
    c:\> winrm set winrm/config/client @{TrustedHosts ="vco_host"} 
  • Run the following command to test the connection to the WinRM service.
    c:\> winrm identify -r:http://winrm_server:5985 -auth:basic -u:user_name -p:password -encoding:utf-8

Before start working with a PowerShell host you need to register it in vCO.

Add_a_PowerShell_host
Add a PowerShell host validates connection to PowerShell and registers the host only if connection is successful. The difference between shared and not shared mode is which user credentials are used to connect to PowerShel host

  • Shared Mode – in this mode all users are using the same credentials
  • Session Per User – in this mode the currently logged user credentials are used

Invoke a PowerShell script

Having an existing PowerShell script you can invoke it without any modifications. Invoke a PowerShell script workflow is suitable for single invocation of script. The result from execution will be available into vCO log tab. This workflow requires you to specify the target host, and the script to be executed. For example we will invoke following script trough vCO:


# Get set of adapters
$adapters  = [System.Net.NetworkInformation.NetworkInterface]::GetAllNetworkInterfaces()
# For each adapter, print out DNS Server Addresses configured
foreach ($adapter in $adapters) {
    $AdapterProperties = $Adapter.GetIPProperties()
    $dnsServers        = $AdapterProperties.DnsAddresses
    if ($dnsServers.Count -gt 0){
$adapter.Description
foreach ($IPAddress in $dnsServers) {
"  DNS Servers ............................. : {0}" -f $ipaddress.IPAddressToString
}
    }
}

This script first gets all the interface objects, then iterates throught them to get the DNS address(es) configured for each one.

Invoke_a_PowerShell_script

Check script output in Log tab.

Invoke_a_PowerShell_script_results1

Invoke an External PowerShell script

Invoke an external script workflows is suitable for running external “.ps1” scripts available on the host machine (.PS1 being the file extension for Windows PowerShell scripts). Required parameters for this workflow are “Name” and “Argument”. The “Name” parameter can be simply the name of the script for example “test.ps1” (if it is available on host machine “Path”) or full path “c:\SomeDirectory\test.ps1”. Script arguments are provided through “Arguments” parameter and the syntax is the same as the one of PowerShell.exe console.

Invoke_an_External_script
Invoke_an_External_script_results

Generate an action from a PowerShell script

PowerShell plug-in allows you to preserve PowerShell script as an action that could be used later in your custom workflows, and even executed on different PowerShell hosts. To achieve this run “Generate an action from a PowerShell script” workflow providing the script. Script customization can be achieved using placeholders. The syntax for defining a placeholder is {#ParamName#}. For each placeholder corresponding action parameter of type string is created in generated action. During action invocation the placeholder is replaced with actual value provided as action parameter.

Generate_an_action_from_a_PowerSHell_script

Generated action looks like.

Generate_an_action_from_a_PowerShell_script_Action

Sample workflow for running the generated action will be generated if “Generate Workflow” option is “Yes”. The workflow will be generated in provided folder and the name of the workflow will be “Invoke Script ” followed by name of generated action.

Generate_an_action_from_a_PowerShell_script_SampleWorkflow

Generate an action for a PowerShell cmdlet

Another feature of the vCO PowerShell plug-in is the ability to generate action based on PowerShell cmdlet. This way you are able to use functionality that is already available in PowerShell inside vCO. To generate action for given PowerShell cmdlet select the cmdlet from inventory tree, and specify which parameter set will be used during action generation.

Generate_an_action_for_a_PowerShell_CmdLet

 

  • More info about VMware vCenter Orchestrator Plug-In for Microsoft Windows PowerShell: release notes, documentation and download
  •  

     

    VMware Releases Four New VMware vCenter Orchestrator Plug-ins!

    As 2011 comes to an end and the holidays approach quickly… it just felt right to thank the fast-growing vCO user community with a set of new shiny toys.  Not to mention that, like people with children know all too well, we've heard these requests over and over again throughout the year… 😉

    So on this holiday note, we are extremely pleased to release four new plug-ins that should help you achieve your 2012 cloud automation resolutions!

    1. The first one is the VMware vCenter Orchestrator SQL Plug-In.  Who hasn't had a need to automate operations on database tables and records?  Well, now you can do so without actually having to write any SQL statements.

    2. The second is the VMware vCenter Orchestrator Plug-In for vSphere Auto Deploy.  Considering the move to a stateless ESXi architecture?  If so then this plug-in is definitely for you. 

    3. Third is the vCenter Orchestrator Multi-Node Plug-In.  As you increase the scale or geographical reach of your automation solutions, you may need to deploy more vCO server instances.  In that case, this new plug-in makes it a lot easier to manage several vCO instances from a single point.

    4. And last but not least… is the vCenter Orchestrator Plug-In for Microsoft Windows PowerShell!  It lets you leverage your existing PowerShell and PowerCLI scripts and opens up so many new capabilities… that we'll need several postings to tell you all about it 😉   So be on the lookout for additional articles on this topic very soon.  In the meantime, we obviously encourage you to take it for a first spin.

    For additional information on these new plug-ins and to download them, please visit the following sites:

    We hope that these new plug-ins will keep you occupied during the holidays.  Seriously, we'd actually prefer that everyone took a well-deserved break, but we know how hard it is not to play with new technology 😉

    So on this note, the entire vCO team wishes you the very best for the holidays and 2012.

    Cheers!

    PS.  As always, you can find documentation on vCO and all available plug-ins on the vCO Documentation site.