Vsphere PowerCLI User's Guide
Vsphere PowerCLI User's Guide
Vsphere PowerCLI User's Guide
This document supports the version of each product listed and supports all subsequent versions until the document is replaced by a new edition. To check for more recent editions of this document, see http://www.vmware.com/support/pubs.
EN-001263-00
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: [email protected]
Copyright 19982013 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 other jurisdictions. All other marks and names mentioned herein may be trademarks of their respective companies.
VMware, Inc.
Contents
Microsoft PowerShell Basics 9 PowerShell Command-Line Syntax 9 PowerShell Pipelines 10 PowerShell Wildcards 10 PowerShell Common Parameters 10 vSphere PowerCLI Concepts 10 vSphere PowerCLI Components and Versioning 12 Interoperability Between the vSphere PowerCLI and vCloud Director PowerCLI Components 12 Selecting Objects in vSphere PowerCLI 14 Providing Login Credentials 15 Running vSphere PowerCLI Cmdlets Asynchronously 15 Managing Default Server Connections 16 Customization Specification Objects in vSphere PowerCLI 16 vSphere PowerCLI Views Cmdlets 16 Using ESXCLI with vSphere PowerCLI 16 vSphere PowerCLI Inventory Provider 17 vSphere PowerCLI Datastore Provider 17 vSphere PowerCLI About Articles 17
Supported Operating Systems 19 Supported VMware Products 20 Prerequisites for Installing and Running vSphere PowerCLI Install vSphere PowerCLI 21 Set the Properties to Support Remote Signing 21 Uninstall vSphere PowerCLI 22
20
Scoped Settings of vSphere PowerCLI 23 Configuring the Scope of the vSphere PowerCLI Settings 23 Priority of Settings Scopes in vSphere PowerCLI 24 vSphere PowerCLI Configuration Files 24 Loading the Script Configuration File of vSphere PowerCLI 25 Load the Script Configuration File in Other PowerShell Tools 25 Customizing vSphere PowerCLI with Script Configuration Files 26 Using Custom Scripts to Extend the Operating System Support for vSphere PowerCLI Cmdlets
26
VMware, Inc.
vSphere PowerCLI Views 27 Set Up the Environment to Develop vSphere PowerCLI .NET Applications 28 Updating the Properties of vSphere PowerCLI Views 28 Creating and Using Filters with VimClient.FindEntityView() or VimClient.FindEntityViews() Saving and Using Server Sessions with vSphere PowerCLI Views 30 Handling Server Errors with vSphere PowerCLI Views 30
29
Connect to a vCenter Server System 34 Manage Virtual Machines on vSphere 35 Add a Standalone Host to a vCenter Server System 35 Activate Maintenance Mode for a Host on vCenter Server 36 Create vSphere Inventory Objects 36 Create Virtual Machines on vCenter Server Using an XML Specification File 37 Manage Virtual Machine Templates on vCenter Server 37 Create and Use Snapshots on vCenter Server 38 Update the Resource Configuration Settings of a Virtual Machine on vCenter Server 39 Get a List of Hosts on a vCenter Server System and View Their Properties 39 Change the Host Advanced Configuration Settings on vCenter Server 40 Move a Virtual Machine to a Different Host Using VMware vSphere vMotion 40 Move a Virtual Machine to a Different Datastore Using VMware vSphere Storage vMotion Create a Host Profile on a vCenter Server System 41 Apply a Host Profile to a Host on vCenter Server 41 Manage Statistics and Statistics Intervals on vCenter Server 42 Modify the Settings of the NIC Teaming Policy for a Virtual Switch 42 Create a vApp on vCenter Server 43 Modify the Properties of a vApp 43 Export or Import vApps 43 Configure a Network Interface 44 Add a Guest Route 44 Create an iSCSI Host Storage 44 Add Passthrough Devices to a Host and Virtual Machine 45 Create a Custom Property Based on an Extension Data Property 45 Create a Script-Based Custom Property for a vSphere Object 46 Apply a Customization Object to a Cloned Virtual Machine 46 Modify the Default NIC Mapping Object of a Customization Specification 47 Modify Multiple NIC Mapping Objects of a Customization Specification 47 Create a vSphere Role and Assign Permissions to a User 48 View the Action Triggers for an Alarm on vCenter Server 48 Create and Modify Alarm Actions and Alarm Triggers on vCenter Server 49 Remove Alarm Actions and Triggers 49 Create and Modify Advanced Settings for a Cluster 50 Modify the vCenter Server Email Configuration 50 Modify the vCenter Server SNMP Configuration 51 Use Esxtop to Get Information on the Virtual CPUs of a Virtual Machine 51 Filter vSphere Objects with Get-View 52 Populate a View Object with Get-View 52 Update the State of a Server-Side Object 52
40
VMware, Inc.
Contents
53 53
Modify the CPU Levels of a Virtual Machine with GetView and GetVIObjectByVIView Browse the Default Inventory Drive 54 Create a New Custom Inventory Drive 54 Manage Inventory Objects Through Inventory Drives 55 Browse the Default Datastore Drives 55 Create a New Custom Datastore Drive 56 Manage Datastores Through Datastore Drives 56 Modify the Timeout Setting for Web Tasks 57
Using Tags 57 Retrieve a Tag and Save It into a Variable 58 Assign a Tag to Virtual Machines 58 Network Management with vSphere Distributed Switches 58 Create a Distributed Switch and Configure Networking 58 Configure a Distributed Switch 59 Migrate Virtual Machine Networking Configuration from a vSphere Standard Switch to a vSphere Distributed Switch 60 Migrate Physical and Virtual NICs to a vSphere Standard Switch 60 Migrate Physical and Virtual NICs to a vSphere Distributed Switch 61 Configure the Traffic Shaping Policy 61 Configure the Security Policy 62
Index
75
VMware, Inc.
VMware, Inc.
The VMware vSphere PowerCLI User's Guide provides information about installing and using the VMware vSphere PowerCLI cmdlets (pronounced commandlets) for managing, monitoring, automating, and handling lifecycle operations for VMware vSphere and vCloud Director components. To help you start with vSphere PowerCLI, this documentation includes descriptions of specific vSphere PowerCLI concepts and features. In addition, this documentation provides a set of usage examples and sample scripts.
Intended Audience
This book is intended for anyone who needs to install and use vSphere PowerCLI. This documentation is written for administrators and developers who are familiar with virtual machine technology and Windows PowerShell:
n
Basic administrators can use cmdlets included in vSphere PowerCLI to manage their vSphere and vCloud Director infrastructure from the command line. Advanced administrators can develop PowerShell scripts that can be reused by other administrators or integrated into other applications. Developers can use vSphere PowerCLI views to create .NET applications for managing vSphere objects.
VMware, Inc.
VMware, Inc.
VMware vSphere PowerCLI contains snap-ins of cmdlets based on Microsoft PowerShell for automating vSphere and vCloud Director administration. It provides C# and PowerShell interfaces to VMware vSphere and vCloud APIs.
n
Microsoft PowerShell Basics on page 9 vSphere PowerCLI is based on Microsoft PowerShell and uses the PowerShell basic syntax and concepts.
vSphere PowerCLI Concepts on page 10 vSphere PowerCLI cmdlets are created to automate VMware environments administration and to introduce some specific features in addition to the PowerShell concepts.
PowerShell Command-Line Syntax on page 9 PowerShell cmdlets use a consistent verb-noun structure, where the verb represents the action and the noun represents the object to operate on.
PowerShell Pipelines on page 10 A pipeline is a series of commands separated by the pipe operator |. PowerShell Wildcards on page 10 PowerShell has a number of pattern-matching operators named wildcards that you can use to substitute one or more characters in a string, or substitute the complete string.
PowerShell Common Parameters on page 10 The Windows PowerShell engine retains a set of parameter names, referred to as common parameters. All PowerShell cmdlets, including the vSphere PowerCLI cmdlets, support them.
VMware, Inc.
All command categories take parameters and arguments. A parameter starts with a hyphen and is used to control the behavior of the command. An argument is a data value consumed by the command. A simple PowerShell command has the following syntax:
command -parameter1 -parameter2 argument1, argument2
PowerShell Pipelines
A pipeline is a series of commands separated by the pipe operator |. Each command in the pipeline receives an object from the previous command, performs some operation on it, and then passes it to the next command in the pipeline. Objects are output from the pipeline as soon as they become available.
PowerShell Wildcards
PowerShell has a number of pattern-matching operators named wildcards that you can use to substitute one or more characters in a string, or substitute the complete string. All wildcard expressions can be used with the vSphere PowerCLI cmdlets. For example, you can view a list of all files with a .txt extension by running dir *.txt. In this case, the asterisk * operator matches any combination of characters. With wildcard patterns you can indicate character ranges as well. For example, to view all files that start with the letter S or T and have a .txt extension, you can run dir [st]*.txt. You can use the question mark ? wildcard to match any single character within a sequence of characters. For example, to view all .txt files with names that consist of string and one more character at the end, run dir string?.txt.
Displays the effects of a command without running it. Prompts for confirmation before running a command that stops a program or service, or deletes data.
vSphere PowerCLI Components and Versioning on page 12 VMware vSphere PowerCLI 5.5 Release 1 consists of two components that users can install and use according to their needs and environments.
10
VMware, Inc.
Interoperability Between the vSphere PowerCLI and vCloud Director PowerCLI Components on page 12 With the RelatedObject parameter of vSphere PowerCLI cmdlets, you can retrieve vSphere inventory objects and vSphere PowerCLI view objects from cloud resources. This interoperability between the vSphere PowerCLI and vCloud Director PowerCLI components expands cloud administration, automation, reporting, and troubleshooting options for provider administrators.
Selecting Objects in vSphere PowerCLI on page 14 In vSphere PowerCLI, you can pass strings and wildcards to all parameters that take inventory objects, datastores, OSCustomizationSpec objects, and VIServer objects as arguments. This vSphere PowerCLI approach is named Object-by-Name (OBN) selection.
Providing Login Credentials on page 15 When you provide login credentials in the command prompt or in a script file, a PowerShell limitation might prevent vSphere PowerCLI from processing non-alphanumeric characters correctly. To prevent login problems, escape the non-alphanumeric characters in your credentials.
Running vSphere PowerCLI Cmdlets Asynchronously on page 15 By default, vSphere PowerCLI cmdlets return an output only after completion of the requested tasks. If you want a cmdlet to return to the command line immediately, without waiting for the tasks to complete, you can use the RunAsync parameter.
Managing Default Server Connections on page 16 By default, vSphere PowerCLI and vSphere PowerCLI cmdlets run on the vCenter Server systems or vCloud Director servers you are connected to, if no target servers can be determined from the provided parameters.
Customization Specification Objects in vSphere PowerCLI on page 16 vSphere PowerCLI provides two types of objects for customization specification: persistent and nonpersistent.
vSphere PowerCLI Views Cmdlets on page 16 The vSphere PowerCLI list of cmdlets includes the Get-View and Get-VIObjectByVIView cmdlets, which enable access to vSphere PowerCLI views from .NET.
Using ESXCLI with vSphere PowerCLI on page 16 vSphere PowerCLI provides you the capability to use ESXCLI through its console. vSphere PowerCLI Inventory Provider on page 17 The Inventory Provider is designed to expose an unfiltered inventory view of the inventory items from a server.
vSphere PowerCLI Datastore Provider on page 17 The Datastore Provider is designed to provide access to the contents of one or more datastores. vSphere PowerCLI About Articles on page 17 You can learn more about some vSphere PowerCLI concepts and features from the built-in help articles named about articles. You can access them through a running vSphere PowerCLI process.
VMware, Inc.
11
VMware vSphere PowerCLI 5.5 Release 1 is the core component of the vSphere PowerCLI package. It contains five snap-ins with cmdlets for managing vSphere 5.5 features. VMware.VimAutomatio n.Core VMware.VimAutomatio n.VDS VMware.VimAutomatio n.License VMware.ImageBuilder VMware.DeployAutoma tion VMware vSphere PowerCLI 5.5 Release 1 provides cmdlets for automated administration of the vSphere environment. VMware vSphere PowerCLI 5.5 Release 1 provides cmdlets for managing vSphere distributed switches and distributed port groups. VMware vSphere PowerCLI 5.5 Release 1 provides the GetLicenseDataManager cmdlet for managing VMware License components. VMware vSphere PowerCLI 5.5 Release 1 provides cmdlets for managing depots, image profiles, and VIBs. VMware vSphere PowerCLI 5.5 Release 1 provides cmdlets that provide an interface to VMware Auto Deploy for provisioning physical hosts with ESXi software.
VMware vCloud Director PowerCLI 5.5 Release 1 is an optional component that you can install during the vSphere PowerCLI installation. It provides one snap-in. VMware.VimAutomatio n.Cloud VMware vCloud Director PowerCLI 5.5 Release 1 provides cmdlets for automating vCloud Director 1.5.1 and vCloud Director 5.1 features. VMware vCloud Director PowerCLI 5.5 Release 1 also provides support for automating vCloud Director 5.1 features against vCloud Director 5.5.
Interoperability Between the vSphere PowerCLI and vCloud Director PowerCLI Components
With the RelatedObject parameter of vSphere PowerCLI cmdlets, you can retrieve vSphere inventory objects and vSphere PowerCLI view objects from cloud resources. This interoperability between the vSphere PowerCLI and vCloud Director PowerCLI components expands cloud administration, automation, reporting, and troubleshooting options for provider administrators. NOTE To use the interoperability feature, you must install the vSphere PowerCLI and vCloud Director PowerCLI components, and connect both to a vCloud Director server and a vCenter Server system.
n
Retrieving vSphere Inventory Objects from Cloud Resources on page 13 Provider administrators can use the RelatedObject parameter of vSphere PowerCLI cmdlets to retrieve vSphere inventory objects from vCloud Director objects. Passing the retrieved objects to the cmdlets of the VMware.VimAutomation.Core and VMware.VimAutomation.VDS snap-ins extends administration options.
Retrieving vSphere PowerCLI Views from vCloud Director PowerCLI Views on page 13 Provider administrators with advanced knowledge and understanding of .NET Framework, vSphere PowerCLI, PowerShell scripting, and vSphere and vCloud APIs can retrieve vSphere PowerCLI views from vCloud Director PowerCLI views with the Get-CIView and Get-View cmdlets.
12
VMware, Inc.
ExternalNetwork
VDPortgroup
VLanPool
DistributedVirtualSwitch
FencePool
DistributedVirtualSwitch
VMware, Inc.
13
Table 12. List of Supported vSphere PowerCLI Views That You Can Retrieve from vCloud Director PowerCLI Views (Continued)
vCloud Director PowerCLI View Object VimServer Retrieved vSphere PowerCLI View Object ServiceInstance Sample Script for Retrieving vSphere PowerCLI View Objects from Cloud Resources $providerVdcView = GetProviderVdc -Name 'MyProviderVdc' | Get-CIView Get-CIView -Id $providerVdcView.VimServer[0].H ref | Get-View $providerVdcView = GetProviderVdc -Name 'MyProviderVdc' | Get-CIView $resourcePoolSet = $providerVdcView.GetResourcePoo ls() $resourcePoolSet.VMWProviderVdc ResourcePool | Get-View Get-CIDatastore -Name 'MyDatastore' -ProviderVdc 'MyProviderVdc' | Get-CIView | Get-View Get-CIVM -Name 'MyVM' | GetCIView | Get-View
VMWProviderVdcResourcePool
ResourcePool
Datastore
Datastore
CIVM
VirtualMachine
NOTE In vSphere PowerCLI, passing strings as pipeline input is not supported. If you provide a non-existing object name, an OBN failure occurs. In such cases, vSphere PowerCLI generates a non-terminating error and runs the cmdlet ignoring the invalid name. For more details about OBN, run help about_OBN.
If the VM2 virtual machine does not exist on either of the selected servers, vSphere PowerCLI generates a non-terminating error and applies the command only on the VM1 and VM3 virtual machines.
14
VMware, Inc.
The command returns no output when all virtual machines stored in the $vmList variable are removed, irrespective of whether they are removed simultaneously.
Remove-VM $vmList -RunAsync
The command returns an output that consists of one or more Task objects immediately.
VMware, Inc.
15
Persistent Customization
Persistent customization specification objects are stored on the vSphere server. All persistent customization specifications created by using vSphere Client or VMware vSphere PowerCLI 4.1 or later are encrypted. Encrypted customization specifications can be applied only by the server that has encrypted them.
Nonpersistent Customization
Nonpersistent customization specification objects exist only inside the current PowerShell process. Nonpersistent customization specification objects are not encrypted, but cloning them to a vSphere server encrypts them.
Through the Get-ESXCli cmdlet, which provides direct access to the ESXCLI namespaces, applications, and commands. Through .NET methods, which you use to create managed objects that correspond to specific ESXCLI applications. To access the ESXCLI, you can call methods on these managed objects. NOTE To call a method of an ESXCLI object, you must provide values for all parameters. If you want to omit a given parameter, pass $null as its argument.
16
VMware, Inc.
LicenseDataManager
Help About_LicenseDataManager
Object-by-Name (OBN)
Help About_OBN
Help About_PowerCLI_Objects
Help About_RunAsync
VMware, Inc.
17
Table 13. Accessing Built-In Help Articles for vSphere PowerCLI (Continued)
Article Title Authenticating with a vCenter Server System or a vCloud Server Command Help About_Server_Authentication Article Description To authenticate with vCenter Server and vCloud Director servers, you can provide a user name and password through the User and Password parameters, or a PSCredential object through the Credential parameter. You can uniquely identify a PowerCLI object on a server or across multiple servers by providing its UID. The Datastore Provider (VimDatastore) provides filesystemstyle view and access to the contents of datastores.
Help About_UID
Help About_VimDatastore
18
VMware, Inc.
VMware vSphere PowerCLI lets you perform managing, monitoring, automating, and handling lifecycle operations on vCenter Server and vCloud Director systems from the command line. You can install VMware vSphere PowerCLI components on all supported Windows operating systems. After installing the package on your machine, you can connect to your vCenter Server or vCloud Director system by providing valid authentication credentials.
n
Supported Operating Systems on page 19 You can install vSphere PowerCLI only on supported Windows operating systems. You can run guest cmdlets only against virtual machines with supported guest operating systems.
Supported VMware Products on page 20 You can use the vSphere PowerCLI components to manage all supported VMware products. Prerequisites for Installing and Running vSphere PowerCLI on page 20 Before installing and running vSphere PowerCLI, verify that you have installed the required software on the same machine.
Install vSphere PowerCLI on page 21 During the installation process, vSphere PowerCLI lets you select the components that you want to install. By selecting to install all available components, you perform a complete installation which requires the most disk space.
Set the Properties to Support Remote Signing on page 21 If you want to run scripts and load configuration files with vSphere PowerCLI, you must set the execution policy of Windows PowerShell to RemoteSigned.
Uninstall vSphere PowerCLI on page 22 You can uninstall vSphere PowerCLI components from your Windows system by using the default uninstall tool of your operating system.
VMware, Inc.
19
OS Type Server
32-Bit
n n
64-Bit
n n n
Windows Server 2008 Service Pack 1 Windows Server 2003 R2 Windows 8 Windows 7 Service Pack 1 Windows XP Service Pack 3
Windows Server 2012 Windows Server 2008 R2 Service Pack 1 Windows Server 2003 R2 Windows 8 Windows 7 Service Pack 1 Windows XP Service Pack 2
Workstation
n n n
n n n
vCenter Server 5.5 VMware ESXi 5.5 vCenter Server 5.1 Update 1 VMware ESXi 5.1 Update 1 vCenter Server 5.0 Update 2 VMware ESXi 5.0 Update 2 vCenter Server 4.1 Update 3 VMware ESX 4.1 Update 3 VMware ESXi 4.1 Update 3 vCenter Server 4.0 Update 4 VMware ESX 4.0 Update 4 VMware ESXi 4.0 Update 4
VMware vCloud Director PowerCLI 5.5 Release 1 is compatible with VMware vCloud Director 1.5.1, VMware vCloud Director 5.1, and VMware vCloud Director 5.5. NOTE You can automate only vCloud Director 5.1 features against vCloud Director 5.5.
20
VMware, Inc.
.NET Framework 2.0 with Service Pack 2 .NET Framework 3.0 or .NET Framework 3.0 with Service Pack 1, or Service Pack 2 .NET Framework 3.5 or .NET Framework 3.5 with Service Pack 1
Before installing vSphere PowerCLI, see Prerequisites for Installing and Running vSphere PowerCLI, on page 20. Verify that you have uninstalled VMware vSphere PowerCLI for Tenants from your system.
Procedure 1 2 Download the latest version of vSphere PowerCLI from the VMware Web site. Navigate to the folder that contains the vSphere PowerCLI installer file you downloaded and doubleclick the executable file. If the installation wizard detects an earlier version of vSphere PowerCLI on your system, it will attempt to upgrade your existing installation. 3 4 5 On the Welcome page, click Next. Accept the license agreement terms and click Next. On the Custom Setup page, select the components that you want to install.
Option vSphere PowerCLI vCloud Director PowerCLI Description Installs a set of cmdlets for managing vSphere features. This vSphere PowerCLI component is mandatory and selected by default. Installs a set of cmdlets for managing vCloud Director features.
6 7 8 9
(Optional) On the Custom Setup page, click Change to select a different location to install vSphere PowerCLI. Click Next. On the Ready to Install the Program page, click Install to proceed with the installation. Click Finish to complete the installation process.
What to do next Enable remote signing. See Set the Properties to Support Remote Signing, on page 21.
VMware, Inc.
21
You can change the execution policy by using the Set-ExecutionPolicy cmdlet. Procedure 1 From your Windows taskbar, select Start > Programs > VMware > VMware vSphere PowerCLI. The vSphere PowerCLI console window opens. 2 In the vSphere PowerCLI console window, run Set-ExecutionPolicy RemoteSigned.
22
VMware, Inc.
To extend and customize the features of VMware vSphere PowerCLI, you can configure the application settings for different users and user groups, modify the script configuration file of VMware vSphere PowerCLI, and add custom scripts. This chapter includes the following topics:
n n n n n
Scoped Settings of vSphere PowerCLI, on page 23 Loading the Script Configuration File of vSphere PowerCLI, on page 25 Load the Script Configuration File in Other PowerShell Tools, on page 25 Customizing vSphere PowerCLI with Script Configuration Files, on page 26 Using Custom Scripts to Extend the Operating System Support for vSphere PowerCLI Cmdlets, on page 26
Configuring the Scope of the vSphere PowerCLI Settings on page 23 Scoped configuration enhances system security and prevents nonadministrator users from introducing global changes to the configuration of vSphere PowerCLI.
Priority of Settings Scopes in vSphere PowerCLI on page 24 vSphere PowerCLI loads the program configuration based on the scope that you select for each setting.
vSphere PowerCLI Configuration Files on page 24 The copies of the PowerCLI_settings.xml file on your system contain User and AllUsers settings for vSphere PowerCLI.
VMware, Inc.
23
User
AllUsers
When started, vSphere PowerCLI tries to load settings with the Session scope first. Session settings override User and AllUsers settings. Session settings are valid for the current vSphere PowerCLI session only. When vSphere PowerCLI cannot detect Session settngs, the program tries to load User settings from the vSphere PowerCLI configuration files. User settings override AllUsers settings. User settings are automatically detected from the vSphere PowerCLI configuration files. When vSphere PowerCLI cannot detect Session and User settings, the program loads AllUsers settings. AllUsers settings do not override Session and User settings. AllUsers settings are automatically detected from the vSphere PowerCLI configuration files.
User
Medium
n n
AllUsers
Low
n n
24
VMware, Inc.
Users with advanced knowledge and understanding of Windows PowerShell and VMware vSphere PowerCLI can manually modify the contents of PowerCLI_settings.xml to change vSphere PowerCLI settings. Modifying PowerCLI_settings.xml might require administrator privileges. NOTE If you modify the contents of PowerCLI_settings.xml manually while vSphere PowerCLI is running, you need to restart vSphere PowerCLI for the changes to take effect.
VMware, Inc.
25
Using Custom Scripts to Extend the Operating System Support for vSphere PowerCLI Cmdlets
Some vSphere PowerCLI features support only Windows 7, Windows Server 2008, Windows XP, Windows Server 2003, and Red Hat Enterprise Linux 5. To add support for other guest operating systems, you can use the scripts that are located in the Scripts folder of the vSphere PowerCLI installation directory or you can add your own custom scripts. When adding new scripts, use the following file naming guidelines:
n
Scripts that extend the operating system support for Get-VMGuestNetworkInterface, SetVMGuestNetworkInterface, Get-VMGuestRoute, New-VMGuestRoute, and Remove-VMGuestRoute must follow the file-naming convention CmdletName_OSIdentifier, where OSIdentifier is the guest family or the guest ID as returned by Get-VMGuest, and CmdletName is the cmdlet name written without a hyphen, for example GetVMGuestRoute. Scripts that extend the operating system support for resizing the hard disk by using Set-HardDisk must follow the file naming convention GuestDiskExpansion_OSIdentifier, where OSIdentifier is the guest family or the guest ID (as returned by Get-VMGuest).
26
VMware, Inc.
You can use .NET to access and use VMware vSphere PowerCLI views. Views are .NET objects that provide C# and PowerShell interface to vSphere APIs. With vSphere PowerCLI views, you can develop .NET applications for creating, customizing, or managing vSphere inventory objects.
n
vSphere PowerCLI Views on page 27 vSphere PowerCLI views are .NET objects that correspond to server-side managed objects. Each operation defined on a server managed object has a corresponding view method.
Set Up the Environment to Develop vSphere PowerCLI .NET Applications on page 28 Before creating and running .NET applications for vSphere PowerCLI, you must set up your developmental environment.
Updating the Properties of vSphere PowerCLI Views on page 28 The properties of a vSphere PowerCLI view contain information about the state of the server-side object at the time the view was created.
Creating and Using Filters with VimClient.FindEntityView() or VimClient.FindEntityViews() on page 29 You can use filters to reduce large sets of output data by retrieving only the objects that correspond to the filter criteria that you provide. You can use vSphere PowerCLI views to define and use filters to select specific objects based on property values.
Saving and Using Server Sessions with vSphere PowerCLI Views on page 30 With vSphere PowerCLI you can save your server session and restore it later. The VimClient class includes several methods for saving and restoring server sessions. This enables you to maintain sessions across applications.
Handling Server Errors with vSphere PowerCLI Views on page 30 Error reporting helps you track and handle server errors. vCenter Server Web Services API server errors are reported as SOAP exceptions that contain a SoapFault object.
It includes properties and methods that correspond to the properties and operations of the server-side managed objects.
VMware, Inc.
27
It is a static copy of a server-side managed object and is not automatically updated when the object on the server changes. It includes additional methods other than the operations offered in the server-side managed object.
Now you can use VimClient and other VMware.Vim namespace classes to manage your vSphere inventory.
The following code example refreshes the power state information of a virtual machine by using
using VMware.Vim; using System.Collections.Specialized; namespace Samples { public class Example2_2 { public void PowerOffVM() { VimClient client = new VimClient(); ... IList<EntityViewBase> vmList = client.FindEntityViews(typeof(VirtualMachine), null, filter, null); // Power off the virtual machines. foreach (VirtualMachine vm in vmList) { // Refresh the state of each view. vm.UpdateViewData(); if (vm.Runtime.PowerState == VirtualMachinePowerState.poweredOn) { vm.PowerOffVM(); Console.WriteLine("Stopped virtual machine: {0}", vm.Name); } else { Console.WriteLine("Virtual machine {0} power state is: {1}", vm.Name, vm.Runtime.PowerState); } } ...
28
VMware, Inc.
VMware, Inc.
29
30
VMware, Inc.
To help you get started with VMware vSphere PowerCLI, this documentation provides a set of sample scripts that illustrate basic and advanced tasks in vSphere administration.
n
Connect to a vCenter ServerSystem on page 34 To run vSphere PowerCLI cmdlets on vSphere and perform administration or monitoring tasks, you must establish a connection to an ESX/ESXi instance or a vCenter Server system.
Manage Virtual Machines on vSphere on page 35 With vSphere PowerCLI, you can automate various administration tasks on virtual machines, for example retrieving information, shutting down and powering off virtual machines.
Add a Standalone Host to a vCenter Server System on page 35 You can add standalone hosts to a vCenter Server system by using the Add-VMHost cmdlet. After adding the hosts, you will be able to manage them through the vCenter Server system.
Activate Maintenance Mode for a Host on vCenter Server on page 36 To complete some specific administration tasks, you might need to activate maintenance mode for a host. On vCenter Server, you can activate maintenance mode by using the Set-VMHost cmdlet.
Create vSphere Inventory Objects on page 36 By using vSphere PowerCLI cmdlets, you can automate creating different inventory objects on vSphere.
Create Virtual Machines on vCenter Server Using an XML Specification File on page 37 You can use a specification provided in an XML file to automate the creation of virtual machines on vCenter Server.
Manage Virtual Machine Templates on vCenter Server on page 37 You can use vSphere PowerCLI to create virtual machines templates and convert them to virtual machines on vCenter Server.
Create and Use Snapshots on vCenter Server on page 38 You can use the Snapshot parameter of Get-VM to take a snapshot of virtual machines and then revert the states of the virtual machines back to the snapshot.
Update the Resource Configuration Settings of a Virtual Machine on vCenter Server on page 39 You can use the Set-VMResourceConfiguration cmdlet to modify the resource configuration properties of a virtual machine, including memory, CPU shares, and other settings.
Get a List of Hosts on a vCenter Server System and View Their Properties on page 39 With vSphere PowerCLI, you can get information about all available hosts in a datacenter and view their properties.
VMware, Inc.
31
Change the Host Advanced Configuration Settings on vCenter Server on page 40 You can modify host configuration, including advanced settings related to virtual machine migration, and apply them to another host.
Move a Virtual Machine to a Different Host Using VMware vSphere vMotion on page 40 You can migrate a virtual machine between vCenter Server hosts by using vSphere vMotion. Move a Virtual Machine to a Different Datastore Using VMware vSphere Storage vMotion on page 40 You can migrate a virtual machine between datastores using the VMware Storage vMotion feature of vCenter Server.
Create a Host Profile on a vCenter Server System on page 41 The VMware Host Profiles feature enables you to create standard configurations for ESX/ESXi hosts. With vSphere PowerCLI, you can automate creation and modifying of host profiles.
Apply a Host Profile to a Host on vCenter Server on page 41 To simplify operational management of large-scale environments, you can apply standard configurations called host profiles to hosts on vCenter Server. If you want to set up a host to use the same host profile as a reference host, you can attach the host to a profile.
Manage Statistics and Statistics Intervals on vCenter Server on page 42 You can use the vSphere PowerCLI cmdlets to automate tasks for viewing and managing statistics for vCenter Server inventory objects.
Modify the Settings of the NIC Teaming Policy for a Virtual Switch on page 42 You can set the NIC teaming policy on a vSwitch. The NIC teaming policy determines the load balancing and failover settings of a virtual switch and lets you mark NICs as unused.
Create a vApp on vCenter Server on page 43 With vSphere PowerCLI, you can create and manage vApps. Modify the Properties of a vApp on page 43 With vSphere PowerCLI, you can start and stop vApps, and modify their properties. Export or Import vApps on page 43 You can import and export vApps to OVA and OVF files. Configure a Network Interface on page 44 You can modify the IP and routing configuration settings of a guest network interface. Add a Guest Route on page 44 You can add new guest routes for virtual machines. Create an iSCSI Host Storage on page 44 For a host, you can enable iSCSI, add iSCSI targets, and create new host storages. Add Passthrough Devices to a Host and Virtual Machine on page 45 You can get information about existing passthrough devices and add new SCSI and PCI devices to virtual machines and hosts.
Create a Custom Property Based on an Extension Data Property on page 45 You can create custom properties to add more information to vSphere objects. Custom properties based on extension data properties correspond directly to the property of the corresponding .NET view object.
Create a Script-Based Custom Property for a vSphere Object on page 46 You can create a custom property by writing a script and providing a name for the property. The script evaluates when the custom property is called for the first time.
32
VMware, Inc.
Chapter 5 Sample Scripts for Managing vSphere with VMware vSphere PowerCLI
Apply a Customization Object to a Cloned Virtual Machine on page 46 You can apply a custom configuration to a cloned virtual machine by using a customization object. Modify the Default NIC Mapping Object of a Customization Specification on page 47 You can modify the default NIC mapping object of a customization specification and apply the specification on a newly created virtual machine.
Modify Multiple NIC Mapping Objects of a Customization Specification on page 47 You can modify multiple NIC mapping objects of a customization specification and apply the specification to an existing virtual machine.
Create a vSphere Role and Assign Permissions to a User on page 48 With vSphere PowerCLI, you can automate management of vSphere permissions, roles, and privileges.
View the Action Triggers for an Alarm on vCenter Server on page 48 You can see which action triggers are configured for an alarm. Create and Modify Alarm Actions and Alarm Triggers on vCenter Server on page 49 With vSphere PowerCLI, you can create and modify vCenter Server alarm actions and alarm triggers. Remove Alarm Actions and Triggers on page 49 In some cases, you might want to remove obsolete alarm actions and triggers. Create and Modify Advanced Settings for a Cluster on page 50 You can customize the behavior of a cluster on a vCenter Server system by creating and modifying custom advanced settings for it.
Modify the vCenter Server Email Configuration on page 50 You can modify the email configuration settings of a vCenter Server. Modify the vCenter Server SNMP Configuration on page 51 To use SNMP, you must first configure the SNMP settings of the vCenter Server. Use Esxtop to Get Information on the Virtual CPUs of a Virtual Machine on page 51 You can use the Get-EsxTop cmdlet to retrieve real-time data for troubleshooting performance problems.
Filter vSphere Objects with Get-View on page 52 You can use the Get-View cmdlet to filter vSphere objects before performing various actions on them. Populate a View Object with Get-View on page 52 To save time and efforts, you can use Get-View to retrieve vSphere PowerCLI views from previously retrieved view objects.
Update the State of a Server-Side Object on page 52 You can use the Get-View cmdlet to update server-side objects. Reboot a Host with Get-View on page 53 You can reboot a host by using its corresponding view object. Modify the CPU Levels of a Virtual Machine with GetView and GetVIObjectByVIView on page 53
VIObjectByVIView cmdlets.
You can modify the CPU levels of a virtual machine using a combination of the Get-View and GetBrowse the Default Inventory Drive on page 54 You can browse the default inventory drive and view its contents.
VMware, Inc.
33
Create a New Custom Inventory Drive on page 54 In addition to the default drive, you can create new custom inventory drives by using the New-PSDrive cmdlet.
Manage Inventory Objects Through Inventory Drives on page 55 You can use the vSphere PowerCLI Inventory Provider to browse, modify, and remove inventory objects from inventory drives.
Browse the Default Datastore Drives on page 55 You can use the vSphere PowerCLI Datastore Provider to browse the default datastore drives: vmstore and vmstores.
Create a New Custom Datastore Drive on page 56 You can use the vSphere PowerCLI Datastore Provider to create custom datastore drives. Manage Datastores Through Datastore Drives on page 56 You can use the vSphere PowerCLI Datastore Provider to browse datastores from datastore drives. Modify the Timeout Setting for Web Tasks on page 57 To avoid unexpected timeout, you can use Set-PowerCLIConfiguration to modify the vSphere PowerCLI settings for long-running Web tasks.
Using Tags on page 57 You can assign tags to different types of objects, such as virtual machines, resource pools, datastores, and vSphere distributed switches. You can use tags to retrieve a specific group of objects.
Network Management with vSphere Distributed Switches on page 58 The cmdlets provided in the VMware.VimAutomation.VDS snap-in let you manage networking with vSphere distributed switches and port groups.
34
VMware, Inc.
Chapter 5 Sample Scripts for Managing vSphere with VMware vSphere PowerCLI
Save the name and the power state properties of the virtual machines in the ResourcePool resource pool into a file named myVMProperties.txt.
$respool = Get-ResourcePool ResourcePool Get-VM -Location $respool | Select-Object Name, PowerState > myVMProperties.txt
Move the virtual machine VM from the Host01 host to the Host02 host.
Get-VM -Name VM -Location Host01 | Move-VM Destination Host02
NOTE If the virtual machine you want to move across hosts is powered on, it must be located on a shared storage registered as a datastore on both the original and the new host.
VMware, Inc.
35
Get the cluster to which Host belongs and save the cluster object as a variable.
$vmhostCluster = Get-Cluster -VMHost $vmhost
Start a task that activates maintenance mode for the Host host and save the task object as a variable.
$updateHostTask = Set-VMHost -VMHost $vmhost -State "Maintenance" -RunAsync
NOTE If the host is not automated or is partially automated and has powered-on virtual machines running on it, you must use the RunAsync parameter and wait until all powered-on virtual machines are relocated or powered off before applying DRS recommendations. 4 Get and apply the recommendations generated by DRS.
Get-DrsRecommendation -Cluster $vmhostCluster | where {$_.Reason -eq "Host is entering maintenance mode"} | Apply-DrsRecommendation
Distributed Resource Scheduler (DRS) is a feature that provides automatic allocation of cluster resources.
36
VMware, Inc.
Chapter 5 Sample Scripts for Managing vSphere with VMware vSphere PowerCLI
Add a host in the cluster by using the Add-VMHost command, and provide credentials when prompted.
$vmhost1 = Add-VMHost -Name 10.23.112.345 -Location (Get-Cluster Cluster1)
The RunAsync parameter indicates that the command runs asynchronously. This means that in contrast to a synchronous operation, you do not have to wait for the process to complete before supplying the next command at the command line.
VMware, Inc.
37
Prerequisites Verify that you are connected to a vCenter Server system. Procedure 1 Create a template from the VM1 virtual machine.
New-Template -VM VM1 -Name VM1Template -Location (Get-Datacenter DC )
Convert the VM1Template template for use by a virtual machine named VM3.
Get-Template VM1Template | Set-Template -ToVM -Name VM3
The Location parameter takes arguments of the VIContainer type, on which Cluster, Datacenter, Folder, ResourcePool, and VMHost object types are based. Therefore, the Location parameter can use
Revert all virtual machines in the MyRP01 resource pool to the InitialSnapshot snapshot.
$VMs = Get-ResourcePool MyRP01 | Get-VM foreach( $vm in $VMs ) { Set-VM -VM $vm Snapshot InitialSnapshot }
38
VMware, Inc.
Chapter 5 Sample Scripts for Managing vSphere with VMware vSphere PowerCLI
Get a List of Hosts on a vCenter Server System and View Their Properties
With vSphere PowerCLI, you can get information about all available hosts in a datacenter and view their properties. Prerequisites Verify that you are connected to a vCenter Server system. Procedure 1 Get a list of all hosts that are part of a datacenter.
Get-Datacenter DC | Get-VMHost | Format-Custom
View the Name and the OverallStatus properties of the hosts in the DC datacenter.
Get-Datacenter DC | Get-VMHost | Get-View | Format-Table -Property Name, OverallStatus AutoSize
View all hosts and their properties, and save the results to a file.
Get-Datacenter DC | Get-VMHost | Format-Custom | Out-File FilePath hosts.txt
VMware, Inc.
39
View a list of the hosts that are in maintenance mode and can be configured for vMotion operations.
Get-VMHost -State maintenance | Get-View | Where-Object -FilterScript { $_.capability -ne $null -and $_.capability.vmotionSupported }
Enable creation of a checksum of the virtual machines memory during the migration.
Get-VMHost ESXHost1 | Set-VmHostAdvancedConfiguration -Name Migrate.MemChksum -Value ( [system.int32] 1 )
Get the VM1 virtual machine and move it to a host named ESXHost2.
Get-VM VM1 | Move-VM -Destination (Get-VMHost ESXHost2)
Move a Virtual Machine to a Different Datastore Using VMware vSphere Storage vMotion
You can migrate a virtual machine between datastores using the VMware Storage vMotion feature of vCenter Server. NOTE You can use Storage vMotion to move a powered-on virtual machine from one datastore to another.
40
VMware, Inc.
Chapter 5 Sample Scripts for Managing vSphere with VMware vSphere PowerCLI
Prerequisites Verify that you are connected to a vCenter Server system. The host on which the virtual machine is running must have access both to the datastore where the virtual machine is located and to the destination datastore. Procedure
u
Get the VM1 virtual machine and move it to a datastore named DS2:
Get-VM VM1 | Move-VM -Datastore DS2
Verify that the Host2 host is compliant with the HostProfile1 profile.
Test-VMHostProfileCompliance -VMHost $vmhost2
The output of this command contains the incompliant settings of the host, if any.
VMware, Inc.
41
The $neededVariables variable contains the names of all required variables and their default or current values, as returned by the server. Otherwise, the $neededVariables variable contains the name of the host on which the profile has been applied.
View the available memory metric types for the Cluster1 cluster.
$cluster = Get-Cluster Cluster1 $statTypes = Get-StatType -Entity $cluster -Interval "past day" -Name mem.*
Modify the Settings of the NIC Teaming Policy for a Virtual Switch
You can set the NIC teaming policy on a vSwitch. The NIC teaming policy determines the load balancing and failover settings of a virtual switch and lets you mark NICs as unused. Prerequisites Verify that you are connected to a vCenter Server system. Procedure 1 Get a list of the physical NIC objects on the host network and store them in a variable.
$pn = Get-VMHost 10.23.123.128 | Get-VMHostNetwork | Select -Property physicalnic
Store the physical NIC objects you want to mark as unused in separate variables.
$pn5 = $pn.PhysicalNic[2] $pn6 = $pn.PhysicalNic[3] $pn7 = $pn.PhysicalNic[0]
Change the policy of the switch to indicate that the $pn5, $pn6, and $pn7 network adapters are unused.
$policy | Set-NicTeamingPolicy -MakeNicUnused $pn5, $pn6, $pn7
42
VMware, Inc.
Chapter 5 Sample Scripts for Managing vSphere with VMware vSphere PowerCLI
Modify the load balancing and failover settings of the virtual switch NIC teaming policy.
$policy | Set-NicTeamingPolicy -BeaconInterval 3 -LoadBalancingPolicy 3 NetworkFailoverDetectionPolicy 1 -NotifySwitches $false -FailbackEnabled $false
Export the OldVApp vApp to a local directory and name the exported appliance WebApp.
Export-VApp -VApp $oldVApp -Name WebApp -Destination D:\vapps\ -CreateSeparateFolder
Import the WebApp vApp from a local directory to the Storage2 datastore.
Import-VApp -Source D:\vapps\WebApp\WebApp.ovf -VMHost (Get-VMHost Host1) -Datastore (GetDatastore -VMHost MyHost01 -Name Storage2)
VMware, Inc.
43
View the existing routes of the guest OS stored in the $guest variable.
Get-VMGuestRoute -VMGuest $guest -GuestUser user -GuestPassword pass2
44
VMware, Inc.
Chapter 5 Sample Scripts for Managing vSphere with VMware vSphere PowerCLI
You can provide the LUN path by using its canonical name beginning with the device name of the iSCSI HBA. 6 Create a new host storage.
New-Datastore -Vmfs -VMHost $vmhost -Path $lunpath.LunPath -Name iSCSI
VMware, Inc.
45
You have created a custom property named ToolsVersion for VirtualMachine objects.
You created a custom script property named NameOfHost for VirtualMachine objects.
Change the NamingPrefix property of the customization object to the name of the virtual machine you want to create.
Set-OSCustomizationSpec -Spec ClientSpec -NamingPrefix VM1
Create a virtual machine named VM1 by cloning the existing VM virtual machine and applying the customization specification.
Get-VM VM | New-VM -VMHost Host -Datastore Storage1 -OSCustomizationSpec ClientSpec -Name VM1
46
VMware, Inc.
Chapter 5 Sample Scripts for Managing vSphere with VMware vSphere PowerCLI
Each customization specification object has one default NIC mapping object. 3 Modify the default NIC mapping object of the Spec customization specification to use static IP.
Get-OSCustomizationNicMapping -Spec Spec | Set-OSCustomizationNicMapping -IpMode UseStaticIP -IpAddress 172.16.1.30 -SubnetMask 255.255.255.0 -DefaultGateway 172.16.1.1 -Dns 172.16.1.1
Create a new virtual machine named VM1 from a template, and apply the static IP settings.
New-VM -Name VM1 -VMHost Host -Datastore Storage1 -OSCustomizationSpec Spec -Template Template
When you apply a customization specification, each network adapter of the customized virtual machine must have a corresponding NIC mapping object. You can correlate network adapters and NIC mapping objects either by their position numbers, or by MAC address. 2 Create a customization specification named Spec.
New-OSCustomizationSpec -Type NonPersistent -Name Spec -OSType Windows -Workgroup Workgroup OrgName Company -Fullname User -ProductKey valid_key -ChangeSid -TimeZone "Central European" -NamingScheme VM
View the NIC mapping objects and verify that two NIC mapping objects are available.
Get-OSCustomizationNicMapping -Spec Spec
The default NIC mapping object is DHCP enabled, and the newly added one uses a static IP address.
VMware, Inc.
47
Associate a network adapter from the VMNetwork network with the NIC mapping object that uses DHCP mode.
$netAdapter = Get-NetworkAdapter VM | where { $_.NetworkName -eq 'VMNetwork' } Get-OSCustomizationNicMapping -Spec Spec | where { $_.IPMode -eq 'UseDHCP' } | SetOSCustomizationNicMapping -NetworkAdapterMac $netAdapter.MacAddress
The Principal parameter accepts both local and domain users and groups if the vCenter Server system is joined in AD. 5 Update the new permission with the custom role.
$permission1 = Set-VIPermission -Permission $permission1 -Role $role1
48
VMware, Inc.
Chapter 5 Sample Scripts for Managing vSphere with VMware vSphere PowerCLI
Procedure 1 Get all vSphere PowerCLI supported alarm actions for the Host Processor Status alarm.
Get-AlarmDefinition -Name "Host Processor Status" | Get-AlarmAction -ActionType "ExecuteScript", "SendSNMP", "SendEmail"
Get all the triggers for the first alarm definition found.
Get-AlarmAction -AlarmDefinition (Get-AlarmDefinition | select -First 1) | GetAlarmActionTrigger
Create and Modify Alarm Actions and Alarm Triggers on vCenter Server
With vSphere PowerCLI, you can create and modify vCenter Server alarm actions and alarm triggers. Prerequisites Verify that you are connected to a vCenter Server system. Procedure 1 For all host alarms, modify the interval after the action repeats.
Get-AlarmDefinition -Entity (Get-VMHost) | foreach { $_ | Set-AlarmDefinition ActionRepeatMinutes ($_.ActionRepeatMinutes + 1)}
Modify the name and the description of a selected alarm definition, and enable the alarm.
Get-AlarmDefinition -Name AlarmDefinition | Set-AlarmDefinition -Name AlarmDefinitionNew Description 'Alarm Definition Description' -Enabled:$true
VMware, Inc.
49
Modify the value of the advanced setting stored in the $setting2 variable.
Get-AdvancedSetting -Entity $cluster -Name 'das.isolationaddress' | Set-AdvancedSetting Value '192.168.10.3' -Confirm:$false
The ` character is used to escape the wildcard characters [ and ] in the advanced setting name.
50
VMware, Inc.
Chapter 5 Sample Scripts for Managing vSphere with VMware vSphere PowerCLI
Get the IDs of all virtual CPUs of the virtual machine and store them in an array.
$gr = Get-EsxTop -TopologyInfo -Topology SchedGroup | %{$_.Entries} | where {$_.GroupId -eq $group.GroupID} $cpuIds = @() $gr.CpuClient | %{$cpuIds += $_.CPUClientID}
Calculate the used and ready for use percentage by using the UsedTimeInUsec and ReadyTimeInUsec stats.
$result = @() $cpuStats | %{ ` $row = "" | select VCPUID, Used, Ready; ` $row.VCPUID = $_.VCPUID; ` $row.Used = [math]::Round(([double]$_.UsedTimeInUsec/[double]$_.UpTimeInUsec)*100, 2); ` $row.Ready = [math]::Round(([double]$_.ReadyTimeInUsec/[double]$_.UpTimeInUsec)*100, 2);` $result += $row }
VMware, Inc.
51
View the used and ready for use percentage for each virtual CPU of the virtual machine.
$result | Format-Table AutoSize
Get a list of the virtual machines by using the created filter and call the ShutdownGuest method for each virtual machine in the list.
Get-View -ViewType "VirtualMachine" -Filter $filter | foreach{$_.ShutdownGuest()}
XP. The Get-View cmdlet then initiates shutdown for each guest operating system in the list.
The filter gets a list of the powered-on virtual machines whose guest OS names contain the string Windows
52
VMware, Inc.
Chapter 5 Sample Scripts for Managing vSphere with VMware vSphere PowerCLI
The power state is not updated yet because the virtual machine property values are not updated automatically. 5 Update the view object.
$vm2.UpdateViewData()
Call the reboot method of the host view object to reboot the host.
$vmhostView.RebootHost()
Modify the CPU Levels of a Virtual Machine with GetView and Get VIObjectByVIView
You can modify the CPU levels of a virtual machine using a combination of the Get-View and GetVIObjectByVIView cmdlets. Prerequisites Verify that you are connected to a vCenter Server system.
VMware, Inc.
53
Procedure 1 Get the VM2 virtual machine, shut it down, and pass it to the Get-View cmdlet to view the virtual machine view object.
$vmView = Get-VM VM2 | Stop-VM | Get-View
Create a VirtualMachineConfigSpec object to modify the virtual machine CPU levels and call the
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec; $spec.CPUAllocation = New-Object VMware.Vim.ResourceAllocationInfo; $spec.CpuAllocation.Shares = New-Object VMware.Vim.SharesInfo; $spec.CpuAllocation.Shares.Level = "normal"; $spec.CpuAllocation.Limit = -1; $vmView .ReconfigVM_Task($spec)
Get the virtual machine object by using the Get-VIObjectByVIView cmdlet and start the virtual machine.
$vm = Get-VIObjectByVIView $vmView | Start-VM
Prerequisites Verify that you are connected to a vCenter Server system. Procedure 1 Get the root folder of the server.
$root = Get-Folder -NoRecursion
54
VMware, Inc.
Chapter 5 Sample Scripts for Managing vSphere with VMware vSphere PowerCLI
NOTE You can use the New-InventoryDrive cmdlet, which is an alias of New-PSDrive. This cmdlet creates a new inventory drive using the Name and Datastore parameters. For example: Get-Folder NoRecursion | New-VIInventoryDrive -Name myVi.
This command returns the virtual machines and the root resource pool of the host. 3 View only the virtual machines on the host.
Get-VM
When called within the inventory drive, Get-VM gets a list only of the virtual machines on the current drive location. 4 Delete a virtual machine named VM1.
del VM1
Start all virtual machines with names that start with VM.
dir VM* | Start-VM
VMware, Inc.
55
NOTE You can use the New-PSDrive cmdlet, which is an alias of New-DatastoreDrive. It creates a new datastore drive using the Name and Datastore parameters. For example: Get-Datastore Storage1 | NewDatastoreDrive -Name ds.
Rename a file by running the Rename-Item cmdlet or its alias ren. For example, to change the name of the vmware-3.log file to vmware-3old.log, run:
ren vmware-3.log vmware-3old.log
All file operations apply only on files in the current folder. 4 Delete a file by running the Remove-Item cmdlet or its alias del. For example, to remove the vmware-3old.log file from the XPVirtualMachine folder, run:
del ds:\VirtualMachines\XPVirtualMachine\vmware-2.log
56
VMware, Inc.
Chapter 5 Sample Scripts for Managing vSphere with VMware vSphere PowerCLI
Copy a file to another datastore by running the Copy-Item cmdlet or its alias copy.
copy ds:\Datacenter01\Datastore01\XPVirtualMachine\vmware-1.log ds:\Datacenter01\Datastore02\XPVirtualMachine02\vmware.log
Create a new folder by running the New-Item cmdlet or its alias mkdir.
mkdir -Path ds:\VirtualMachines -Name Folder01 -Type Folder
Download a file from the datastore drive to the local machine by running the Copy-DatastoreItem cmdlet.
Copy-DatastoreItem ds:\VirtualMachines\XPVirtualMachine\vmware-3.log C:\Temp\vmware-3.log
Upload a file from the local machine by running the Copy-DatastoreItem cmdlet.
Copy-DatastoreItem C:\Temp\vmware-3.log ds:\VirtualMachines\XPVirtualMachine\vmware-3new.log
Store the value of the timeout setting for the current session in the $initialTimeout variable.
$initialTimeout = (Get-PowerCLIConfiguration -Scope Session).WebOperationTimeoutSeconds
Run your Web task. For example, run an esxcli command to install a software profile.
$esxcli.software.profile.install("http://mysite.com/publish/proj/index.xml",$null,$null, $null,$null,$null,$true,"proj-version",$null)
Revert the timeout setting for the current session to the initial value.
Set-PowerCLIConfiguration -Scope Session -WebOperationTimeoutSeconds $initialTimeout
Using Tags
You can assign tags to different types of objects, such as virtual machines, resource pools, datastores, and vSphere distributed switches. You can use tags to retrieve a specific group of objects. NOTE The tagging functionality requires vCenter Server 5.1 or later.
VMware, Inc.
57
What to do next Assign the saved tag to a group of virtual machines. See Assign a Tag to Virtual Machines, on page 58.
58
VMware, Inc.
Chapter 5 Sample Scripts for Managing vSphere with VMware vSphere PowerCLI
The distributed switch is created with no port groups. 4 Add the hosts in your datacenter to the distributed switch.
Add-VDSwitchVMHost -VDSwitch $myVDSwitch -VMHost $vmHosts
Add the physical network adapter to the distributed switch that you created.
Add-VDSwitchPhysicalNetworkAdapter -VMHostNetworkAdapter $hostsPhysicalNic DistributedSwitch $myVDSwitch
Create a new distributed port group with 1000 ports and add it to the distributed switch.
$myVDPortGroup = New-VDPortgroup -Name "MyVMsPortGroup" -VDSwitch $myVDSwitch -NumPorts 1000
Connect all virtual machines running on the hosts in your datacenter to the distributed port group.
$vmHosts | Get-VM | Get-NetworkAdapter | Set-NetworkAdapter -PortGroup $myVDPortGroup
What to do next Adjust the settings of the distributed switch. See Configure a Distributed Switch, on page 59.
VMware, Inc.
59
Migrate Virtual Machine Networking Configuration from a vSphere Standard Switch to a vSphere Distributed Switch
To manage virtual machine networks on a datacenter level, you might need to migrate existing networks from vSphere standard switches to vSphere distributed switches. Prerequisites Verify that you are connected to a vCenter Server system. Procedure 1 Get the source vSphere standard switch from which you want to migrate the virtual machine networking.
$virtualSwitch = Get-VirtualSwitch -Name 'MyVirtualSwitch'
Get the source standard port group to which the virtual machines are connected.
$vmsPortGroup = $virtualSwitch | Get-VirtualPortGroup -Name 'VM Network'
Get the target vSphere distributed switch to which you want to migrate the virtual machine networking.
$vdSwitch = Get-VDSwitch -Name 'MyTargetVDSwitch'
Get the target port group to which you want to connect the virtual machines.
$vdPortGroup = Get-VDPortGroup -VDSwitch $vdSwitch -Name 'DPortGroup'
Get the virtual machine network adapters connected to the source port group.
$vmsNetworkAdapters = Get-VM -RelatedObject $vmsPortGroup | Get-NetworkAdapter | where { $_.NetworkName -eq $vmsPortGroup.Name }
Disconnect the retrieved network adapters from the standard port group and connect them to the distributed port group.
Set-NetworkAdapter -NetworkAdapter $vmsNetworkAdapters -PortGroup $vdPortGroup
Get the vSphere standard switch to which you want to migrate the network adapters.
$vSwitch = Get-VirtualSwitch -VMHost $vmhost -Name vSwitch0
60
VMware, Inc.
Chapter 5 Sample Scripts for Managing vSphere with VMware vSphere PowerCLI
Get the port groups corresponding to the virtual network adapters that you want to migrate to the vSphere distributed switch.
$vdPortgroupManagement = Get-VDPortgroup -VDSwitch $vds -Name 'Management Network' $vdPortgroupvMotion = Get-VDPortgroup -VDSwitch $vds -Name 'vMotion Network'
You migrated the $vNicManagement network adapter to the Management Network port group and the $vNicvMotion network adapter to the vMotion Network port group.
VMware, Inc.
61
62
VMware, Inc.
Sample Scripts for Managing vCloud Director with VMware vCloud Director PowerCLI
To help you get started with VMware vCloud Director PowerCLI, this documentation provides a set of scripts that illustrate basic and advanced tasks in cloud administration.
n
Connect to a vCloud Director Server on page 64 To run cmdlets on a vCloud Director server and perform administration or monitoring tasks, you must establish a connection to the server.
Create and Manage Organizations on page 65 Organizations provide resources to a group of users and set policies that determine how users can consume those resources. Create and manage organizations for each group of users that requires its own resources, policies, or both.
Create and Manage Organization Virtual Datacenters on page 65 To allocate resources to an organization, you need to create an organization virtual datacenter (vDC). When the demands of the organization change, you can modify or remove the organization vDC.
Create and Manage Organization Networks on page 66 To define how the virtual machines in an organization connect to each other and access other networks, you must create an organization network. To address multiple networking scenarios for an organization, you can create multiple organization networks.
Filter and Retrieve Organization Networks on page 67 To generate reports about organization networks, you need to retrieve the respective organization networks. You can use search criteria to filter the results returned by Get-OrgNetwork.
Import a vApp Template from the Local Storage on page 67 To make an OVF package from your local storage available to other cloud users, you can import the package and save it as a vApp template in a catalog.
Create a vApp Template from a vApp on page 67 Creating vApp templates from vApps in the cloud might minimize future efforts for cloning vApps. You can use the templates later to create new vApps that are based on the source vApp.
Import a vApp from vSphere on page 68 To make a virtual machine from the underlying vSphere infrastructure available to your vCloud Director server, you can import it and save it as a vApp.
Create and Modify a vApp on page 68 You can use vApp templates to instantiate vApps. After creating the vApp, you can modify its settings to minimize the consumption of computing and storage resources.
VMware, Inc.
63
Manage Virtual Machines with vApps on page 69 For a large-scale approach to administration, you can start, stop, or restart virtual machines or their guest operating systems by running cmdlets on the associated vApps.
Manage Virtual Machines and Their Guest Operating Systems on page 69 For a targeted approach to administration, you can use the CIVM and CIVMGuest cmdlets to handle lifecycle operations for one or more virtual machines.
Retrieve a List of the Internal and External IP Addresses of Virtual Machines in vApps on page 70 When managing vApps in the cloud, you might need to obtain information about the NIC settings of the associated virtual machines.
Create and Manage Access Control Rules on page 71 By defining access control rules you can assign levels of access to separate users, user groups, or everyone in the organization. You can define access control rules for catalogs and vApps.
Filter and Retrieve vApp Networks on page 71 To generate reports about vApp networks, you need to retrieve the respective vApp networks. You can use search criteria to filter the results returned by Get-CIVAppNetwork.
Create vApp Networks for a Selected vApp on page 72 To define how the virtual machines in a vApp connect to each other and access other networks, you need to create a vApp network. When creating the vApp network, you can select the settings for the network, or adopt them from an organization policy.
Modify or Remove vApp Networks on page 73 Based on the type of the vApp network, you can configure various network settings, such as DNS, static IP pools, and firewalls. If you no longer need a vApp network, you can remove it.
64
VMware, Inc.
Chapter 6 Sample Scripts for Managing vCloud Director with VMware vCloud Director PowerCLI
Add a new organization on the server and provide a name and a full name for it.
New-Org -Name 'MyOrg1' -FullName 'My Organization 1'
By default, the new organization is enabled. Enabling the organization lets users log in. 3 Add a description for the new organization.
Get-Org -Name 'MyOrg1' | Set-Org -Description "This organization provides resources to John Doe."
Verify that you are connected to a vCloud Director server as a provider administrator. Verify that at least one enabled provider vDC is available on the server.
Procedure 1 Create a new organization vDC using the Pay As You Go model for resource allocation.
$myOrg = Get-Org -Name 'MyOrg1' $myPVdc = Get-ProviderVdc -Name 'MyProvidervDC' New-OrgVdc -Name 'MyOrgvDC' -AllocationModelPayAsYouGo -Org $myOrg -ProviderVdc $myPVdc VMCPUCoreMHz 1000
To create the organization vDC, vCloud Director PowerCLI uses a default configuration based on the selected resource allocation model.
n n n n n n
VMMaxCount is set to 100 NetworkMaxCount is set to 1024 The vDC is automatically enabled Thin provisioning is disabled Fast provisioning is disabled NicMaxCount is set to $null (unlimited)
VMware, Inc.
65
n n
Modify the vCPU speed setting for the virtual machines in the organization vDC.
Get-OrgVdc -Name 'MyOrgVdc' | Set-OrgVdc -VMCpuCoreMhz 2000
Enable fast provisioning for the virtual machines in the organization vDC.
Get-OrgVdc -Name 'MyOrgVdc' | Set-OrgVdc -UseFastProvisioning $true
Get the external network to which you want to connect your organization networks.
$myExternalNetwork = Get-ExternalNetwork -Name 'MyExternalNetwork'
Get the network pool that will allocate network resources for your organization networks.
$myNetworkPool = Get-NetworkPool -Name 'MyNetworkPool'
66
VMware, Inc.
Chapter 6 Sample Scripts for Managing vCloud Director with VMware vCloud Director PowerCLI
Get all organization networks that are connected to the external network named MyExternalNetwork.
Get-OrgNetwork -ExternalNetwork 'MyExternalNetwork'
Get the organization network that is named MyInternalOrgNetwork and is connected to the network pool named MyNetworkPool.
Get-NetworkPool -Name 'MyNetworkPool' | Get-OrgNetwork -Name 'MyInternalOrgNetwork'
Retrieve the organization virtual datacenter (vDC) to which you want to add the imported vApp template.
$myOrgVdc = Get-OrgVdc -Name 'MyOrgVdc'
Import a virtual machine from your local storage and save it as a vApp template in the cloud.
Import-CIVAppTemplate -SourcePath 'C:\OVFs\WindowsXP\WindowsXP.ovf' -Name 'MyWindowsXPVAppTemplate' -OrgVdc $myOrgVdc -Catalog $myCatalog
VMware, Inc.
67
Procedure 1 Retrieve the source vApp for the vApp template that you want to create.
$myVApp = Get-CIVApp -Name 'MyVApp'
Retrieve the catalog to which you want to add the new vApp template.
$myCatalog = Get-Catalog -Name 'MyCatalog'
Retrieve the organization vDC to which you want to add the new vApp template.
$myOrgVdc = Get-OrgVdc -Name 'MyOrgVdc'
What to do next Create a vApp from the template and modify the vApp. SeeCreate and Modify a vApp, on page 68.
Verify that you are connected to a vCloud Director server as a provider administrator. Verify that you are connected to a vCenter Server system.
Procedure 1 Retrieve the vSphere virtual machine that you want to import.
$myVm = Get-VM -Name 'MyVMToImport'
Retrieve the organization vDC to which you want to import the virtual machine.
$myOrgVdc = Get-OrgVdc -Name 'MyOrgVdc'
68
VMware, Inc.
Chapter 6 Sample Scripts for Managing vCloud Director with VMware vCloud Director PowerCLI
Procedure 1 Retrieve the organization vDC to which you want to add the new vApp.
$myOrgVdc = Get-OrgVdc -Name 'MyOrgVdc'
By default, the vApp is powered off. 4 Renew the runtime lease for the new vApp and set it to 12 hours.
Set-CIVApp -VApp $myVApp -RuntimeLease "12:0:0" RenewLease
To set leases, you can use the days.hours:minutes:seconds syntax. 5 Start the new vApp.
Start-VApp -VApp $myVApp
Suspend all virtual machines in all vApps with names starting with YourVApp.
Get-CIVapp -Name 'YourVApp*' | Suspend-CIVApp
Shut down the guest operating systems of all virtual machines in the vApp named MyVApp2.
Get-CIVapp -Name 'MyVApp2' | Stop-CIVAppGuest
Restart the guest operating systems of all virtual machines in the vApp named MyVApp3.
Get-CIVapp -Name 'MyVApp3' | Restart-CIVAppGuest
VMware, Inc.
69
Procedure 1 Retrieve all virtual machines with names starting with MyVM and power them on.
Get-CIVM -Name 'MyVM*' | Start-CIVM
Shut down the guest operating system of the virtual machine named MyVM2.
Get-CIVM -Name 'MyVM2' | Stop-CIVMGuest
Restart the guest operating system of the virtual machine named MyVM3.
Get-CIVM -Name 'MyVM3' | Restart-CIVMGuest
Retrieve a List of the Internal and External IP Addresses of Virtual Machines in vApps
When managing vApps in the cloud, you might need to obtain information about the NIC settings of the associated virtual machines. Prerequisites Verify that you are connected to a vCloud Director server. Procedure 1 Retrieve the organization for which you want to generate the report.
$myOrg = Get-Org -Name 'MyOrg'
70
VMware, Inc.
Chapter 6 Sample Scripts for Managing vCloud Director with VMware vCloud Director PowerCLI
$vAppNetworkAdapters += $vAppNicInfo } } }
Running this script retrieves the names of the virtual machines and their associated vApp, the IDs of the NICs of the virtual machines, and external, and internal IP addresses of the NICs. 4 Display the report on the screen.
$vAppNetworkAdapters
All users in the organization have read-only access to the vApp. 2 Modify the access rule for a trusted user who needs full control over MyVApp.
New-CIAccessControlRule -Entity 'MyVApp' -User "MyAdvancedUser" -AccessLevel "FullControl"
Remove the custom rule that you created earlier for MyAdvancedUser.
$accessRule | Remove-CIAccessControlRule
Get all vApp networks of connection type direct and direct fenced.
Get-CIVAppNetwork -ConnectionType Direct, DirectFenced
VMware, Inc.
71
Get all direct vApp networks that connect to the organization network named MyOrgNetwork.
Get-OrgNetwork -Name 'MyOrgNetwork' | Get-CIVAppNetwork -ConnectionType Direct
Create an Isolated vApp Network on page 72 When you do not want the virtual machines in a vApp to connect to objects outside the vApp, you must create an isolated vApp network.
Create an NAT Routed vApp Network on page 72 To provide a vApp network with DHCP, firewall, NAT, and VPN services, you must create it as an NAT routed vApp network.
Create a Direct vApp Network on page 73 To establish a network connection between the virtual machines in a vApp and an organization network, you need to create a direct vApp network.
Create the new vApp network with a selected gateway and network mask.
New-CIVAppNetwork -VApp $myVApp -Name 'MyVAppInternalNetwork' -Routed -Gateway '192.168.2.1' -Netmask '255.255.255.0' -ParentOrgNetwork $null
Retrieve the organization network to which you want to connect the vApp network.
$myOrgNetwork = Get-OrgNetwork -Name 'MyOrgNetwork'
72
VMware, Inc.
Chapter 6 Sample Scripts for Managing vCloud Director with VMware vCloud Director PowerCLI
Create the new vApp network with a gateway and network mask, defined pool of static IP addresses, and a disabled firewall.
New-CIVAppNetwork -VApp $myVApp -ParentOrgNetwork $myOrgNetwork -Name 'MyVAppInternalNetwork' -Routed -Gateway '192.168.2.1' -Netmask '255.255.255.0' DisableFirewall -StaticIPPool "192.168.2.100 - 192.168.2.199"
If you do not run New-CIVAppNetwork with the DisableFirewall parameter, the new vApp network has an enabled firewall by default.
Create a direct vApp network that connects to the selected organization network.
New-CIVAppNetwork -VApp $myVapp -Direct -ParentOrgNetwork $myOrgNetwork
Modify the settings for DNS and static IP pool for the vApp network named MyVAppNetwork.
Get-CIVAppNetwork -VApp $myVApp -Name 'MyVAppNetwork' | Set-CIVAppNetwork -PrimaryDns 10.17.0.94 -SecondaryDns 10.17.0.95 -DnsSuffix 'my.domain.com' -StaticIPPool "10.151.168.1 10.151.169.240"
(Optional) Remove all isolated vApp networks for the vApp named MyVapp.
$myVApp | Get-CIVAppNetwork -ConnectionType Isolated | Remove-CIVAppNetwork
VMware, Inc.
73
The operation disables the firewall and NAT routing for all vApp networks that are connected to MyOrgNetwork1.
74
VMware, Inc.
Index
Symbols
.NET, environment 28
A
access control rule 71 advanced settings cluster 50 host 40 vCenter Server email configuration 50 vCenter Server SNMP configuration 51 alarms actions 48, 49 actions remove 49 triggers 48, 49 triggers remove 49 API access cmdlets CPU levels modify 53 filter objects 52 asynchronously running cmdlets 15
customization specification apply 46 default NIC mapping 47 modify 47 multiple NIC mappings 47 nonpersistent 16 persistent 16
D
datastore drives browse 55 create 56 manage 56 datastore provider browse datastore drives 55 create datastore drives 56 manage datastores 56 distributed switches configure 59 create 58 migrate networking 60 migrate virtual machines 60 modify 58 distributed port groups, create 58
C
cluster, advanced settings 50 common parameters 10 configure 23 configuring security 62 configuring traffic shaping 61 connect vCenter Server 34 vCloud Director server 64 create access control rule 71 datastore drives 56 distributed port groups 58 distributed switches 58 inventory drives 54 inventory objects 36 organization network 66 vApp 43, 68 vApp template 67 vApp network 72 custom properties create 45, 46 custom properties based on extension data 45 script custom properties 46
E
ESXCLI 16 esxtop 51 examples vCloud Director 63 vSphere 31
F
fence network 70
G
Get-View filter objects 52 interoperability 13 populate objects 52 reboot host 53 server-side objects update 52 guest network interface, configure 44 guest route add 44 create 44
VMware, Inc.
75
H
host adding to a server 35 maintenance mode 36 host profiles apply 41 attach 41 create 41 modify 41 test 41 host storage, iSCSI 44 hosts advanced settings 40 properties 39
physical NICs to a vSphere standard switch 60 virtual NICs to a vSphere distributed switch 61 virtual NICs to a vSphere standard switch 60 virtual machine networking 60
N
NAT routing 72 network, guest network interface 44 network configuration, migration 60 networking, distributed switches 58 networks, manage 58 NIC external and internal IP addresses 70 teaming policy 42 non-alphanumeric characters 15
I
install allow running scripts 21 complete installation 21 custom installation 21 prerequisites 20 set remote signing 21 supported operating systems 19 supported VMware products 20 installation prerequisites 20 introduction PowerCLI specifics 9 PowerShell 9 inventory drives browse 54 create 54 default 54 manage 55 inventory objects, create 36 inventory provider browse 54 create inventory drives 54 default inventory drive 54 manage 55 iSCSI HBA 44 iSCSI target 44
O
OBN, OBN failure 14 organization create 65 manage 65 network 66 organization network create 66 manage 66 retrieve 67 organization vDC create 65 manage 65 OS support extend 26 OVA 43 OVF 43
P
passthrough devices add 45 PCI 45 SCSI 45 view 45 PCI 45 permissions 48 physical NIC migrating to a vSphere distributed switch 61 migrating to a vSphere standard switch 60 policies security 62 traffic shaping 61 port groups, distributed 58 PowerCLI snap-ins 12 PowerCLI components 12 PowerCLI specifics about articles 17 customization specification 16
M
maintenance mode, activate 36 manage datastore drives 56 inventory 55 networks 58 organization 65 organization network 66 organization vDC 65 migrate physical NICs to a vSphere distributed switch 61
76
VMware, Inc.
Index
datastore provider 17 default vCenter Server connections 16 default vCloud Director connections 16 interoperability 12 inventory provider 17 login credentials 15 non-alphanumeric characters 15 OBN 14 OBN failure 14 running cmdlets asynchronously 15 scoped settings 23 script configuration files 25, 26 special characters 15 specifying objects 14 starting PowerCLI 25 using ESXCLI 16 views cmdlets 16 PowerShell cmdlet syntax 9 common parameters 10 non-alphanumeric characters 15 pipeline 10 special characters 15 wildcards 10
Session 23 User 23 snapshots create 38 use 38 special characters 15 statistics, statistics intervals 42 Storage vMotion 40 supported operating systems 19 supported VMware products 20 switches, distributed 58
T
tagging assigning 58 retrieving 58 using variables 58 templates, manage 37
U
uninstall 22
V
vApp configure 68 create 43, 68 export 43 guest operating system 69 import 43, 68 manage 69 modify 68 network 72 properties 43 runtime lease 68 start 43 stop 43 VM 69 vApp network create 72 direct 73 isolated 72 modify 73 NAT routed 72 redirect 73 remove 73 retrieve 71 routed 72 vApp template create 67 import 67 vCenter Server connect 34 default connections 16
R
RelatedObject, Get-View 13 remote signing 21 retrieving tags 58 roles create 48 privileges 48
S
script configuration files custom 25, 26 default 25, 26 extend the OS support 26 loading 25 loading manually 25 SCSI 45 server connection default vCenter Server connections 16 default vCloud Director connections 16 server-side objects 52 settings modify 57 timeout 57 settings scopes AllUsers 23 configuration files 24 priority 24
VMware, Inc.
77
email configuration 50 SNMP configuration 51 vCloud Director default connections 16 examples 63 view objects 53 views characteristics 27 error handling 30 filters 29 populate 52 retrieve 13 server sessions 30 update 28 virtual machine, migrating network configuration 60 virtual machine networking, migrating 60 virtual machines create 37 guest operating systems 69 migrate between datastores 40 migrate between hosts 40 move 35 power off 35, 69 power on 69 resource configuration 39 start 35 Storage vMotion 40 suspend 69 vMotion 40 xml specification 37 virtual NIC migrating to a vSphere distributed switch 61 migrating to a vSphere standard switch 60 virtual switch NIC teaming policy 42 settings 42 vMotion 40 vSphere, examples 31 vSphere distributed switches 58
W
wildcards 10
X
xml specification 37
78
VMware, Inc.