VMware PowerCLI User's Guide

[Pages:15]VMware PowerCLI User's Guide

VMware PowerCLI 12.3.0

VMware PowerCLI User's Guide

You can find the most up-to-date technical documentation on the VMware website at:

VMware, Inc. 3401 Hillview Ave. Palo Alto, CA 94304

Copyright ? 1998-2021 VMware, Inc. All rights reserved. Copyright and trademark information.

VMware, Inc.

2

Contents

VMware PowerCLI User's Guide 9

1 Introduction to VMware PowerCLI 10

Microsoft PowerShell Basics 10 PowerShell Command-Line Syntax 11 PowerShell Pipelines 11 PowerShell Wildcards 11 PowerShell Common Parameters 11

PowerCLI Concepts 12 PowerCLI Modules 13 Interoperability Between the PowerCLI and VMware Cloud Director PowerCLI Modules 14 Selecting Objects in PowerCLI 16 Providing Login Credentials 16 Running PowerCLI Cmdlets Asynchronously 17 Managing Default Server Connections 17 Customization Specification Objects in PowerCLI 18 Using ESXCLI with PowerCLI 18 PowerCLI Inventory Provider 18 PowerCLI Datastore Provider 19 PowerCLI About Articles 19

2 Installing VMware PowerCLI 21

Supported Operating Systems 22 Supported VMware Products 22 Supported PowerShell Versions 22 Install PowerCLI 22 Install PowerCLI Offline 23 Allow Execution of Local Scripts 24 Update PowerCLI 24 Uninstall PowerCLI 25

3 Configuring VMware PowerCLI 26

Configuring PowerCLI Response to Untrusted Certificates 26 Configure the PowerCLI Response to Untrusted Certificates 26 PowerCLI Trusted Certificate Store 27

Scoped Settings of vSphere PowerCLI 28 Configuring the Scope of the PowerCLI Settings 28 Priority of Settings Scopes in PowerCLI 28

VMware, Inc.

3

VMware PowerCLI User's Guide

PowerCLI Configuration Files 29

4 Configuring Customer Experience Improvement Program 31

Categories of Information That VMware Receives 31 Join the Customer Experience Improvement Program in PowerCLI 31

5 Sample Scripts for Managing vSphere with VMware PowerCLI 32

Connect to a vCenter Server System 37 Manage Virtual Machines on vSphere 37 Add a Standalone Host to a vCenter Server System 38 Set the License Key for a Host on vCenter Server 39 Activate Maintenance Mode for a Host on vCenter Server 39 Create vSphere Inventory Objects 40 Create Virtual Machines on vCenter Server Using an XML Specification File 41 Manage Virtual Machine Templates on vCenter Server 42 Create and Use Snapshots on vCenter Server 43 Update the Resource Configuration Settings of a Virtual Machine on vCenter Server 43 Get a List of Hosts on a vCenter Server System and View Their Properties 44 Change the Host Advanced Configuration Settings on vCenter Server 45 Move a Virtual Machine to a Different Host Using VMware vSphere vMotion 45 Move a Virtual Machine to a Different Datastore Using VMware vSphere Storage vMotion 46 Move a Virtual Machine to a Different vCenter Server System 46 Create a Host Profile on a vCenter Server System 47 Apply a Host Profile to a Host on vCenter Server 47 Manage Statistics and Statistics Intervals on vCenter Server 48 Modify the Settings of the NIC Teaming Policy for a Virtual Switch 49 Create a vApp on vCenter Server 49 Modify the Properties of a vApp 50 Export or Import vApps 50 Create an iSCSI Host Storage 51 Add Passthrough Devices to a Host and Virtual Machine 51 Create a Custom Property Based on an Extension Data Property 52 Create a Script-Based Custom Property for a vSphere Object 52 Apply a Customization Object to a Cloned Virtual Machine 53 Modify the Default NIC Mapping Object of a Customization Specification 54 Modify Multiple NIC Mapping Objects of a Customization Specification 54 Create Multiple Virtual Machines that Use Static IP Addresses 55 Create Multiple Virtual Machines with Two Network Adapters 56 Create a vSphere Role and Assign Permissions to a User 58 View Actions and Triggers for an Alarm on vCenter Server 59 Create Alarm Definitions on vCenter Server 59

VMware, Inc.

4

VMware PowerCLI User's Guide

Modify Alarm Definitions on vCenter Server 60 Create Alarm Actions and Triggers on vCenter Server 60 Remove Alarm Definitions and Actions 61 Create and Modify Advanced Settings for a Cluster 61 Modify the vCenter Server Email Configuration 62 Modify the vCenter Server SNMP Configuration 62 Use Esxtop to Get Information on the Virtual CPUs of a Virtual Machine 63 Filter vSphere Objects with Get-View 64 Populate a View Object with Get-View 64 Update the State of a Server-Side Object 65 Reboot a Host with Get-View 66 Modify the CPU Levels of a Virtual Machine with Get?View and Get?VIObjectByVIView 66 Browse the Default Inventory Drive 67 Create a New Custom Inventory Drive 67 Manage Inventory Objects Through Inventory Drives 68 Browse the Default Datastore Drives 68 Create a New Custom Datastore Drive 69 Manage Datastores Through Datastore Drives 69 Modify the Timeout Setting for Web Tasks 70 Using Tags 71

Retrieve a Tag and Save It into a Variable 71 Retrieve a Tag Category and Save It into a Variable 72 Create a Tag Category and a Tag 72 Assign a Tag to Virtual Machines 73 Retrieve Objects by Tag 73 Generate Tags Automatically by Using a Script 73 Add an Entity Type to a Tag Category 74 Retrieve Tag Assignments 74 Network Management with vSphere Distributed Switches 75 Create a Distributed Switch and Configure Networking 75 Configure a Distributed Switch 76 Migrate Virtual Machine Networking Configuration from a vSphere Standard Switch to a

vSphere Distributed Switch 76 Migrate Physical and Virtual NICs to a vSphere Standard Switch 77 Migrate Physical and Virtual NICs to a vSphere Distributed Switch 78 Configure the Traffic Shaping Policy 78 Configure the Security Policy 79 Create a Local Content Library 79 Create a Subscribed Content Library 80 Create a Content Library Item 80 Create a Virtual Machine from a Content Library Item 80 Create a vApp from a Content Library Item 81

VMware, Inc.

5

VMware PowerCLI User's Guide

Export Content Library Item's Files to a Local Machine 81 Create a New VM-VM DRS Rule 82 Create a New VM-VMHost DRS Rule 82

6 Sample Scripts for Managing vSphere Policy-Based Storage with VMware PowerCLI 84

Create a Tag-Based Storage Policy 84 Create a Capability-Based Storage Policy 85 Associate a Storage Policy with a Virtual Machine and Its Hard Disk 86 Disassociate a Storage Policy Associated with a Virtual Machine and Its Hard Disk 87 Remove a Storage Policy 87 Edit a Storage Policy 88 Export and Import a Storage Policy 88 Create a Virtual Machine in a Datastore Compatible with Storage Policy 89 Create a vSAN Datastore 90 Modify a vSAN Datastore 92 Create a vSAN Stretched Cluster 92 Enable a vSAN File Service 93 Create a vSAN File Service Domain 94 Create a vSAN File Share 95 Create an NFS 4.1 Datastore 95 Add a VASA Provider and Create a Policy 96 Invoke a Planned Failover on a Replication Group and Reverse the Replication 97 Attach a Flat VDisk to a Virtual Machine 99

7 Sample Scripts for Managing VMware Site Recovery Manager with VMware PowerCLI 101

Connect to an SRM Server 101 Protect a Virtual Machine 102 Create a Report of the Protected Virtual Machines 103 Create a Report of the Virtual Machines Associated with All Protection Groups 104

8 Sample Scripts for Managing the vSphere Automation API with VMware PowerCLI 105

Connect to a vSphere Automation API Server 105 Back up a vCenter Server Instance 106 Create a Local Content Library on an Existing Datastore 107

9 Sample Scripts for Managing VMware Cloud Director with VMware PowerCLI 109

Connect to a VMware Cloud Director Server 110 Create and Manage Organizations 111 Create and Manage Organization Virtual Data Centers 112

VMware, Inc.

6

VMware PowerCLI User's Guide

Filter and Retrieve Organization Virtual Data Center Networks 113 Import a vApp Template from the Local Storage 113 Create a vApp Template from a vApp 114 Import a vApp from vSphere 114 Create and Modify a vApp 115 Manage Virtual Machines with vApps 116 Manage Virtual Machines and Their Guest Operating Systems 116 Retrieve a List of the Internal and External IP Addresses of Virtual Machines in vApps 117 Create and Manage Access Control Rules 118 Filter and Retrieve vApp Networks 119 Create vApp Networks for a Selected vApp 119

Create an Isolated vApp Network 120 Create an NAT Routed vApp Network 120 Create a Direct vApp Network 121 Modify or Remove vApp Networks 121

10 Sample Scripts for Managing vSphere Update Manager with VMware PowerCLI 123

Connect to a vCenter Server System 123 Create Patch Baselines 124 Attach and Detach Baselines 125 Scan a Virtual Machine 125 Check Virtual Machine Baseline Status 126 Stage Patches 126 Remediate a Virtual Machine 127 Upgrade Virtual Machine Hardware 127 Remediate a Cluster 128 Remediate a Host 128 Download Patches and Scan Objects 129

11 Sample Scripts for Managing vRealize Operations Manager with VMware PowerCLI 130

Connect to a vRealize Operations Manager Server 130 Check Memory Waste Levels 131 Get Remediation Recommendations 132 Change Alert Ownership 132 Create a Report for Problematic Hosts 133

12 Sample Scripts for Managing VMware Cloud on AWS with VMware PowerCLI 134

Connecting to VMware Cloud on AWS 134 Connect to VMware Cloud on AWS by Using an API Token 134

VMware, Inc.

7

VMware PowerCLI User's Guide

Connect to VMware Cloud on AWS by Using an OAuth Security Context 135 Connect to a vCenter Server System Running in VMware Cloud on AWS 135 Connect to a vCenter Server System by Using an OAuth 2.0 Authentication 136 Connect to a Specific Instance of VMware Cloud on AWS 136 View the Available Software-Defined Data Centers 137 Create a Software-Defined Data Center 137

13 Help and Support for VMware PowerCLI 138

Generate a PowerCLI Support Bundle 139

VMware, Inc.

8

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download