To help you get started with VMware PowerCLI, this documentation provides a set of sample scripts that illustrate basic and advanced tasks in vSphere administration.
■
| To run PowerCLI cmdlets on vSphere and perform administration or monitoring tasks, you must establish a connection to an ESXi host or a vCenter Server system. |
■
| With PowerCLI, you can automate various administration tasks on virtual machines, for example retrieving information, shutting down and powering off virtual machines. |
■
| 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. |
■
| You can set the license key for a host on a vCenter Server system by using the LicenseKey parameter of the Set-VMHost cmdlet. |
■
| 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. |
■
| By using PowerCLI cmdlets, you can automate creating different inventory objects on vSphere. |
■
| You can use a specification provided in an XML file to automate the creation of virtual machines on vCenter Server. |
■
| You can use PowerCLI to create virtual machines templates and convert them to virtual machines on vCenter Server. |
■
| 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. |
■
| You can use the Set-VMResourceConfiguration cmdlet to modify the resource configuration properties of a virtual machine, including memory, CPU shares, and other settings. |
■
| With PowerCLI, you can get information about all available hosts in a data center and view their properties. |
■
| You can modify host configuration, including advanced settings related to virtual machine migration, and apply them to another host. |
■
| You can migrate a virtual machine between vCenter Server hosts by using vSphere vMotion. |
■
| You can migrate a virtual machine between datastores using the VMware Storage vMotion feature of vCenter Server. |
■
| The VMware Host Profiles feature enables you to create standard configurations for ESXi hosts. With PowerCLI, you can automate creation and modifying of host profiles. |
■
| 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. |
■
| You can use the PowerCLI cmdlets to automate tasks for viewing and managing statistics for vCenter Server inventory objects. |
■
| 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. |
■
| With PowerCLI, you can create and manage vApps. |
■
| With PowerCLI, you can start and stop vApps, and modify their properties. |
■
| You can import and export vApps to OVA and OVF files. |
■
| For a host, you can enable iSCSI, add iSCSI targets, and create new host storages. |
■
| You can get information about existing passthrough devices and add new SCSI and PCI devices to virtual machines and hosts. |
■
| 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. |
■
| 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. |
■
| You can apply a custom configuration to a cloned virtual machine by using a customization object. |
■
| You can modify the default NIC mapping object of a customization specification and apply the specification on a newly created virtual machine. |
■
| You can modify multiple NIC mapping objects of a customization specification and apply the specification to an existing virtual machine. |
■
| You can deploy multiple virtual machines with a single network adapter and configure the deployed virtual machines to use static IP addresses by applying a customization specification. |
■
| You can deploy multiple virtual machines with two network adapters each and configure each adapter to use specific network settings by applying a customization specification. |
■
| With PowerCLI, you can automate management of vSphere permissions, roles, and privileges. |
■
| You can see which action triggers are configured for an alarm. |
■
| With PowerCLI, you can create and modify vCenter Server alarm actions and alarm triggers. |
■
| In some cases, you might want to remove obsolete alarm actions and triggers. |
■
| You can customize the behavior of a cluster on a vCenter Server system by creating and modifying custom advanced settings for it. |
■
| You can modify the email configuration settings of a vCenter Server. |
■
| To use SNMP, you must first configure the SNMP settings of the vCenter Server. |
■
| You can use the Get-EsxTop cmdlet to retrieve real-time data for troubleshooting performance problems. |
■
| You can use the Get-View cmdlet to filter vSphere objects before performing various actions on them. |
■
| To save time and efforts, you can use Get-View to retrieve PowerCLI views from previously retrieved view objects. |
■
| You can use the Get-View cmdlet to update server-side objects. |
■
| You can reboot a host by using its corresponding view object. |
■
| You can modify the CPU levels of a virtual machine using a combination of the Get-View and Get-VIObjectByVIView cmdlets. |
■
| You can browse the default inventory drive and view its contents. |
■
| In addition to the default drive, you can create new custom inventory drives by using the New-PSDrive cmdlet. |
■
| You can use the PowerCLI Inventory Provider to browse, modify, and remove inventory objects from inventory drives. |
■
| You can use the PowerCLI Datastore Provider to browse the default datastore drives: vmstore and vmstores. |
■
| You can use the PowerCLI Datastore Provider to create custom datastore drives. |
■
| You can use the PowerCLI Datastore Provider to browse datastores from datastore drives. |
■
| To avoid unexpected timeouts, you can run Set-PowerCLIConfiguration to modify the PowerCLI settings for long-running Web tasks. |
■
| 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. |
■
| The cmdlets provided in the VMware.VimAutomation.VDS module let you manage networking with vSphere distributed switches and port groups. |
■
| You can deploy a virtual machine from a content library template. |
■
| You can deploy a vApp from a content library template. |
■
| You can create a VM-VM DRS affinity rule within a cluster. |
■
| You can create a VM-VMHost DRS rule within a cluster after creating a VM DRS cluster group and a VMHost DRS cluster group. |