Using Powershell Plugin 10 Guide
Using Powershell Plugin 10 Guide
EN-000757-04
Using the vCenter Orchestrator Plug-In for Microsoft Windows PowerShell 1.0.x
You can find the most up-to-date technical documentation on the VMware Web site at:
http://www.vmware.com/support/
The VMware Web site also provides the latest product updates.
If you have comments about this documentation, submit your feedback to:
docfeedback@vmware.com
Copyright 20112013 VMware, Inc. All rights reserved. This product is protected by U.S. and international copyright and
intellectual property laws. VMware products are covered by one or more patents listed at
http://www.vmware.com/go/patents.
VMware is a registered trademark or trademark of VMware, Inc. in the United States and/or other jurisdictions. All other marks
and names mentioned herein may be trademarks of their respective companies.
VMware, Inc.
3401 Hillview Ave.
Palo Alto, CA 94304
www.vmware.com
VMware, Inc.
Contents
Using the vCenter Orchestrator Plug-In for Microsoft Windows PowerShell 1.0.x 5
Updated Information 7
10
VMware, Inc.
Using the vCenter Orchestrator Plug-In for Microsoft Windows PowerShell 1.0.x
Index 27
VMware, Inc.
Using the vCenter Orchestrator Plug-In for Microsoft Windows PowerShell 1.0.x provides information and
instructions about configuring and using the VMware vCenter Orchestrator Plug-In for Microsoft Windows
PowerShell 1.0.x.
Intended Audience
This book is intended for anyone who is installing and configuring the plug-in, using the API of the plug-in,
and using the workflow library. The information in Using the vCenter Orchestrator Plug-In for Microsoft Windows
PowerShell 1.0.x is written for experienced users who are familiar with virtual machine technology, with
Orchestrator workflow development, and with Windows PowerShell.
For more information about Orchestrator, see
http://www.vmware.com/support/pubs/orchestrator_pubs.html.
For more information about Windows PowerShell, see
http://technet.microsoft.com/en-us/library/bb978526.aspx.
VMware, Inc.
Using the vCenter Orchestrator Plug-In for Microsoft Windows PowerShell 1.0.x
VMware, Inc.
Updated Information
Using the vCenter Orchestrator Plug-In for Microsoft Windows PowerShell 1.0.x is updated with each release of the
product or when necessary.
This table provides the update history of Using the vCenter Orchestrator Plug-In for Microsoft Windows PowerShell
1.0.x.
Revision
Description
EN-000757-04
Added a note to Add a PowerShell Host, on page 17 and Configure Kerberos Authentication, on
page 16 that Kerberos authentication requires a FQDN host address.
EN-000757-03
EN-000757-02
Release 1.0.1 of the PowerShell plug-in, which adds support for Kerberos authentication.
n Added information about the new authentication type Kerberos in Add a PowerShell Host, on
page 17.
n Added configuration information about the new authentication type Kerberos in Configure Kerberos
Authentication, on page 16.
n Added troubleshooting information about Kerberos in Troubleshooting, on page 25.
EN-000757-01
Added information about configuring trusted hosts when the WinRM host machine is in an external domain
in Configure WinRM to Use HTTP, on page 11. This information is applicable for the initial 1.0 release
of the plug-in.
EN-000757-00
VMware, Inc.
Using the vCenter Orchestrator Plug-In for Microsoft Windows PowerShell 1.0.x
VMware, Inc.
The PowerShell plug-in (VMware vCenter Orchestrator plug-in for Microsoft Windows PowerShell) allows
interaction between vCenter Orchestrator and Windows PowerShell.
You use the plug-in to call PowerShell scripts and cmdlets from Orchestrator actions and workflows, and to
work with the result. The plug-in contains a set of standard workflows. You can also create custom workflows
that implement the plug-in API.
This chapter includes the following topics:
n
VMware, Inc.
Using the vCenter Orchestrator Plug-In for Microsoft Windows PowerShell 1.0.x
vCenter Server
plug-in
PowerShell
plug-in
WinRM/HTTP(S)
or SSH
Windows
WinRM service or OpenSSH v5.9
PowerShell
PowerCLI (optional)
The plug-in can communicate with Windows PowerShell through the OpenSSH and WinRM communication
protocols. See Supported Communication Protocols, on page 11.
Optionally, you can integrate the PowerShell plug-in with vSphere PowerCLI and vCenter Server. See
PowerCLI Integration with the PowerShell Plug-In, on page 21.
NOTE You can install all components on a local host. The usage, functionality, and communication protocol
requirements of the PowerShell plug-in do not change if vCenter Orchestrator and Windows PowerShell are
installed on the same machine.
10
VMware, Inc.
Chapter 1 Introduction to the VMware vCenter Orchestrator Plug-In for Microsoft Windows PowerShell
Version
OpenSSH
WinRM
Procedure
1
Run the following command to set the default WinRM configuration values.
c:\> winrm quickconfig
VMware, Inc.
11
Using the vCenter Orchestrator Plug-In for Microsoft Windows PowerShell 1.0.x
(Optional) Run the following command 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.
3
Run the following command to allow transfer of unencrypted data on the WinRM service.
c:\> winrm set winrm/config/service @{AllowUnencrypted="true"}
Run the following command to allow transfer of unencrypted data on the WinRM client.
c:\> winrm set winrm/config/client @{AllowUnencrypted="true"}
If the WinRM host machine is in an external domain, run the following command to specify the trusted
hosts.
c:\> winrm set winrm/config/client @{TrustedHosts="host1, host2, host3"}
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
12
VMware, Inc.
Chapter 1 Introduction to the VMware vCenter Orchestrator Plug-In for Microsoft Windows PowerShell
Run mmc.exe.
From the list of available snap-ins, select Certificates and click Add.
Click Finish.
Verify that the certificate is installed in Console Root > Certificates (Local Computer) > Personal >
Certificates and Console Root > Certificates (Local Computer) > Trusted Root Certification
Authorities > Certificates.
If the certificate is not installed in the Trusted Root Certification Authorities and Personal folders, you
must install it manually.
Create an HTTPS listener by using the correct thumbprint and host name.
The following command line contains example syntax for creating an HTTPS listener.
winrm create winrm/config/Listener?Address=*+Transport=HTTPS
@{Hostname="host_name";CertificateThumbprint="certificate_thumbprint"}
vCenter Orchestrator
Verify that you have a running instance of Orchestrator. You can log in to the Orchestrator configuration
interface at http://orchestrator_server:8282. Version 1.0 of the plug-in works with vCenter Orchestrator 4.2.
For information about setting up Orchestrator, see Installing and Configuring VMware vCenter Orchestrator.
Windows PowerShell
Verify that you have access to a Windows PowerShell host. Version 1.0 of the plug-in works with Windows
PowerShell 1.0 and 2.0.
For information, see the Windows PowerShell documentation.
Verify that you are logged in to the Orchestrator configuration interface at http://orchestrator_server:8282.
VMware, Inc.
13
Using the vCenter Orchestrator Plug-In for Microsoft Windows PowerShell 1.0.x
Procedure
1
Click Open.
Click Install.
A message appears after successful installation. The PowerShell plug-in is installed without a tab in the
Orchestrator configuration interface.
14
On the Startup Options tab, click Restart service to complete the plug-in installation.
VMware, Inc.
The PowerShell plug-in workflow library contains workflows that allow you to manage PowerShell hosts and
run custom PowerShell operations.
You can use the Inventory view in the Orchestrator client to manage the available PowerShell resources. You
can use the scripting API of the plug-in to develop custom workflows.
This chapter includes the following topics:
n
Troubleshooting, on page 25
VMware, Inc.
15
Using the vCenter Orchestrator Plug-In for Microsoft Windows PowerShell 1.0.x
Configuration Workflows
The Configuration workflow category contains workflows that allow you to manage PowerShell hosts.
You can access these workflows from Library > PowerShell > Configuration on the Workflows view in the
Orchestrator client.
Workflow Name
Description
Verifies a host URL, and if required, shows a user interaction message for SSL certificates user
approval.
Locations of Key Distribution Centers (KDC) and administration servers for the Kerberos realms of interest
Default values for the current realm and for Kerberos applications
Procedure
u
Path
Windows
your_Orchestrator_installation_folder/jre/lib/security/
Linux
/opt/vmo/jre/lib/security
16
VMware, Inc.
}
[domain_realms]
.yourdomain.com=YOURDOMAIN.COM
yourdomain.com=YOURDOMAIN.COM
NOTE The Kerberos authentication requires a Fully Qualified Domain Name (FQDN) host address.
IMPORTANT When you add or modify the krb5.conf file, you must restart the Orchestrator server service.
In the workflows hierarchical list, select Library > PowerShell > Configuration and navigate to the Add
a PowerShell host workflow.
Right-click the Add a PowerShell host workflow and select Start workflow.
(Optional) In the Port text box, type the port of the host.
Select the PowerShell host type that the plug-in connects to.
a
10
Select the type of session mode that the plug-in uses to connect to the PowerShell host.
Option
Description
Shared Session
The plug-in uses shared credentials to connect to the remote host. You must
provide the PowerShell host credentials for the shared session.
The Orchestrator client retrieves credentials from the user who is logged in.
After the workflow runs successfully, the PowerShell host appears in the Inventory view.
VMware, Inc.
17
Using the vCenter Orchestrator Plug-In for Microsoft Windows PowerShell 1.0.x
Verify that you have a connection to a PowerShell host from the Inventory view.
Procedure
1
In the workflows hierarchical list, select Library > PowerShell and navigate to the Invoke a PowerShell
script workflow.
Right-click the Invoke a PowerShell script workflow and select Start workflow.
In the Script text box, type or paste the PowerShell script that you want to run.
Verify that you have a connection to a PowerShell host from the Inventory view.
Verify that you have acces to other .ps1 files that the script might reference.
Procedure
1
In the workflows hierarchical list, select Library > PowerShell and navigate to the Invoke an external
script workflow.
Right-click the Invoke an external script workflow and select Start workflow.
In the Name text box, type the filename of the external .ps1 script that you want to run.
NOTE If the .ps1 file is not in the default folder, you must type the absolute filepath. You can use system
environment variables to specify script paths. For example, $env:HOMEPATH\test1.ps1.
18
VMware, Inc.
Generating Actions
You can run workflows to generate actions based on a PowerShell script or a PowerShell cmdlet. You can use
the generated actions as building blocks for custom workflows.
Verify that you have a connection to a PowerShell host from the Inventory view.
Procedure
1
In the workflows hierarchical list, select Library > PowerShell > Generate and navigate to the Generate
an action from a PowerShell script workflow.
Right-click the Generate an action from a PowerShell script workflow and select Start workflow.
In the Script text box, type or paste the PowerShell script from which to generate the action.
NOTE You can use {#ParamName#} as a placeholder for user input. If the placeholder is of type string, you
must use double quotes to pass the value of the placeholder to the action.
The following script is an example of how to link the generated action parameter to a script parameter.
param($name={#ParamName#})
echo $name;
In the Name text box, type a name for the action that you want to generate.
Option
Description
Yes
Generates a sample workflow that can run the generated action. You must
select a folder in which to generate the workflow.
NOTE The name of the generated workflow consists of the predefined string
Invoke Script and the name of the generated action.
No
What to do next
You can integrate the generated action in custom workflows.
VMware, Inc.
19
Using the vCenter Orchestrator Plug-In for Microsoft Windows PowerShell 1.0.x
Verify that you have a connection to a PowerShell host from the Inventory view.
Procedure
1
In the workflows hierarchical list, select Library > PowerShell > Generate and navigate to the Generate
an action for a PowerShell cmdlet workflow.
Right-click the Generate an action for a PowerShell cmdlet workflow and select Start workflow.
Select a PowerShell cmdlet to run when using the action that you generate.
In the Name text box, type a name for the action that you want to generate.
Option
Description
Yes
Generates a sample workflow that can run the generated action. You should
select a folder in which to generate the workflow.
NOTE The name of the generated workflow consists of the predefined string
Execute Cmdlet and the name of the generated action.
No
What to do next
You can integrate the generated action in custom workflows.
20
VMware, Inc.
Converter Workflows
You can use the sample workflows from the Converter workflow category to test the integration between the
PowerShell plug-in and PowerCLI. To test the integration, PowerCLI must be installed on the PowerShell host.
The Converter sample workflows demonstrate the conversion functionality available in the plug-in.
NOTE The PowerShell plug-in does not support all types that are available in PowerCLI and the vCenter Server
plug-in. Unsupported types return an exception.
You can access these workflows from Library > PowerShell > Samples > Converter on the Workflows view
in the Orchestrator client.
Workflow Name
Description
Sample Workflows
The Samples workflow category contains workflows that allow you to test basic use cases.
You can access these workflows from Library > PowerShell > Samples on the Workflows view in the
Orchestrator client.
Workflow Name
Description
Demonstrates how to call a PowerShell script through the available scripting API.
Demonstrates how you can run multiple cmdlets arranged into a pipe.
VMware, Inc.
21
Using the vCenter Orchestrator Plug-In for Microsoft Windows PowerShell 1.0.x
Access the API Explorer from either the Orchestrator client or from the Scripting tabs of the workflow,
policy, and action editors.
To access the API Explorer from the Orchestrator client, click Tools > API Explorer in the Orchestrator
client toolbar.
To access the API Explorer from the Scripting tabs of the workflow, policy, and action editors, click
Search API on the left.
To expand the hierarchical list of PowerShell plug-in API objects, double-click the PowerShell module in
the left pane.
What to do next
You can copy code from API elements and paste it into scripting boxes. For more information about API
scripting, see Developing with VMware vCenter Orchestrator.
Description
getErrors()
Returns a list of errors reported by the PowerShell engine during script invocation.
getInvocationState()
getHostOutput()
getResults()
The PowerShell plug-in also provides an object model that wraps the XML result and provides easier access
to particular object properties. The getRootObject() method provides access to the object model. In general,
the getRootObject() method maps the PowerShell types to types available in Orchestrator, by using the
following rules.
22
If the returned object is of a primitive PowerShell type, the object is mapped to the corresponding
Orchestrator primitive type.
VMware, Inc.
var sess;
try {
//Open session to PowerShell host
var sess = host.openSession()
//Set executed script
var result = sess.invokeScript('dir')
//Check for errors
if (result.invocationState == 'Failed'){
throw "PowerShellInvocationError: Errors found while executing script \n" +
result.getErrors();
}
//Show result
System.log( result.getHostOutput() );
} catch (ex){
System.error (ex)
} finally {
if (sess) {
//Close session
host.closeSession( sess.getSessionId() );
}
}
VMware, Inc.
23
Using the vCenter Orchestrator Plug-In for Microsoft Windows PowerShell 1.0.x
24
VMware, Inc.
Troubleshooting
If you encounter problems when running or using PowerShell plug-in, you can use a troubleshooting topic to
understand and solve the problem, if there is a workaround.
Cause
This error might be caused by domain or mapping problems, or because of a DNS problem where the service
principal name is not built correctly. Kerberos authentication does not workwhen the destination is an IP
address.
Solution
When you add a PowerShell host using the Kerberos authentication type a DNS or NetBIOS destination.
Cause
You have provided wrong credentials.
Solution
Provide the correct credentials.
Cause
If the system time on the computers in the environment deffers with more than 5 minutes from the client
computer or from one another, the Kerberos authentication fails.
VMware, Inc.
25
Using the vCenter Orchestrator Plug-In for Microsoft Windows PowerShell 1.0.x
Solution
Synchronize the system times in the environment.
Cause
The default realm is not specified in the Kerberos configuration file krb5.conf neither provided as a part of the
user name.
Solution
Provide a default realm in your Kerberos configuration file or specify the realm in your user name when
authenticating Kerberos.
Cause
The libdefaults and realms sections in the krb5.conf file might be misspelled.
Solution
Verify that the libdefaults and realms sections in your krb5.conf file are spelled correctly.
26
VMware, Inc.
Index
A
action generation 19
adding a PowerShell host 17
API, working with results 22
API access 22
audience 5
authentication, Kerberos 16
C
communication protocol support 11
components 9
configuration 16
E
external script, call 18
F
functional prerequisites 13
G
Generate an action for a PowerShell cmdlet 20
Generate an action from a PowerShell script 19
H
host
configure 16
manage 16
I
installation 13
installation process 13
introduction 9
Inventory 15
invocation result passing 21
Invoke a PowerShell script 18
Invoke an external script 18
O
Orchestrator 10
PowerShell host
adding 17
registering 17
PowerShell scripts
invoke 18
run 18
prerequisites 13
R
registering a PowerShell host 17
S
script, call 18
scripting examples 23
supported communication protocols 11
T
troubleshooting
Kerberos aauthentication 25
Kerberos authentication 25, 26
Key Distribution Center 26
servers not found 25
ticket 25
time difference 25
Troubleshooting
Kerberos Authentication 26
Shared Session 26
U
updated information 7
usage 15
W
Windows PowerShell 10
WinRM
HTTP configuration 11
HTTPS configuration 12
workflows
configuration 16
Converter 21
sample 21
VMware, Inc.
27
Using the vCenter Orchestrator Plug-In for Microsoft Windows PowerShell 1.0.x
28
VMware, Inc.