vmware powercli 6.5 release 1 reference poster · vmware powercli 6.5 release 1 reference poster...

1
Get-Catalog Get-CIAccessControlRule New-CIAccessControlRule Remove-CIAccessControlRule Set-CIAccessControlRule Add-CIDatastore Get-CIDatastore Get-CINetworkAdapter Set-CINetworkAdapter Get-CIRole Connect-CIServer Disconnect-CIServer Get-CIUser Get-CIVApp Import-CIVApp New-CIVApp Remove-CIVApp Restart-CIVApp Set-CIVApp Start-CIVApp Stop-CIVApp Suspend-CIVApp Restart-CIVAppGuest Stop-CIVAppGuest Suspend-CIVAppGuest Get-CIVAppNetwork New-CIVAppNetwork Remove-CIVAppNetwork Set-CIVAppNetwork Get-CIVAppStartRule Set-CIVAppStartRule Get-CIVAppTemplate Import-CIVAppTemplate New-CIVAppTemplate Remove-CIVAppTemplate Set-CIVAppTemplate Get-CIView Get-CIVM New-CIVM Restart-CIVM Start-CIVM Stop-CIVM Suspend-CIVM Restart-CIVMGuest Stop-CIVMGuest Get-CIVMTemplate Search-Cloud Get-CloudCommand Get-ExternalNetwork Get-Media Get-NetworkPool Get-Org New-Org Remove-Org Set-Org Get-OrgNetwork New-OrgNetwork Remove-OrgNetwork Set-OrgNetwork Get-OrgVdc New-OrgVdc Remove-OrgVdc Set-OrgVdc Get-OrgVdcNetwork Cloud http://blogs.vmware.com/PowerCLI/ Copyright © 2017 VMware, Inc. All rights reserved. @PowerCLI @vmwarepowercli @PowerCLI VMware PowerCLI 6.5 Release 1 Reference Poster Get-PowerCLIConfiguration Set-PowerCLIConfiguration Get-PowerCLIDocumentation Get-PowerCLIVersion Get-PowerCLICommunity Get-PowerCLIHelp PowerCLI Settings Get-NfsUser New-NfsUser Remove-NfsUser Set-NfsUser Get-SpbmCapability Get-SpbmCompatibleStorage Get-SpbmEntityConfiguration Set-SpbmEntityConfiguration Get-SpbmFaultDomain Start-SpbmReplicationFailover Get-SpbmReplicationGroup Sync-SpbmReplicationGroup Get-SpbmReplicationPair Start-SpbmReplicationPrepareFailover Start-SpbmReplicationReverse New-SpbmRule New-SpbmRuleSet Export-SpbmStoragePolicy Get-SpbmStoragePolicy Import-SpbmStoragePolicy New-SpbmStoragePolicy Remove-SpbmStoragePolicy Set-SpbmStoragePolicy Get-VAIOFilter New-VAIOFilter Remove-VAIOFilter Set-VAIOFilter Get-VasaProvider New-VasaProvider Remove-VasaProvider Get-VasaStorageArray Copy-VDisk Get-VDisk Move-VDisk New-VDisk Remove-VDisk Set-VDisk Storage Operations Switch-ActiveDeployRuleSet Get-AutoDeployCommand Export-AutoDeployState Import-AutoDeployState Repair-DeployImageCache Get-DeployOption Set-DeployOption Add-DeployRule Copy-DeployRule Get-DeployRule New-DeployRule Remove-DeployRule Set-DeployRule Get-DeployRuleSet Set-DeployRuleSet Repair-DeployRuleSetCompliance Test-DeployRuleSetCompliance Apply-ESXImageProfile Set-ESXImageProfileAssociation Add-ProxyServer Get-ProxyServer Remove-ProxyServer Add-ScriptBundle Get-ScriptBundle Get-VMHostAttributes Get-VMHostImageProfile Get-VMHostMatchingRules AutoDeploy Move-Cluster New-Cluster Remove-Cluster Set-Cluster Get-DrmInfo Apply-DrsRecommendation Get-DrsRecommendation Invoke-DrsRecommendation Get-DrsRule New-DrsRule Remove-DrsRule Set-DrsRule Get-ResourcePool Move-ResourcePool New-ResourcePool Remove-ResourcePool Set-ResourcePool Cluster Operations Attach-Baseline Detach-Baseline Get-Baseline Remove-Baseline Get-Compliance Test-Compliance Update-Entity Add-EntityBaseline Remove-EntityBaseline Remediate-Inventory Scan-Inventory Copy-Patch Download-Patch Get-Patch Stage-Patch Sync-Patch Get-PatchBaseline New-PatchBaseline Set-PatchBaseline Update Manager Compare-EsxImageProfile Export-EsxImageProfile Get-EsxImageProfile New-EsxImageProfile Remove-EsxImageProfile Set-EsxImageProfile Add-EsxSoftwareDepot Get-EsxSoftwareDepot Remove-EsxSoftwareDepot Add-EsxSoftwarePackage Get-EsxSoftwarePackage Remove-EsxSoftwarePackage Get-ImageBuilderCommand Image Builder Connect-SrmServer Disconnect-SrmServer SRM Connect-HVServer Disconnect-HVServer Horizon View Get-OMAlert Set-OMAlert Get-OMAlertDefinition Get-OMAlertSubType Get-OMAlertType Get-OMRecommendation Get-OMResource Connect-OMServer Disconnect-OMServer Get-OMStat Get-OMStatKey Get-OMUser vR Ops Apply-VMHostProfile Export-VMHostProfile Get-VMHostProfile Import-VMHostProfile Invoke-VMHostProfile New-VMHostProfile Remove-VMHostProfile Set-VMHostProfile Test-VMHostProfileCompliance Get-VMHostProfileRequiredInput Host Profiles Get-Tag New-Tag Remove-Tag Set-Tag Get-TagAssignment New-TagAssignment Remove-TagAssignment Get-TagCategory New-TagCategory Remove-TagCategory Set-TagCategory Tag Operations Get-Log Get-LogType Get-Stat Get-StatInterval New-StatInterval Remove-StatInterval Set-StatInterval Get-StatType Get-ErrorReport Get-VIEvent Logging and Statistics Export-VApp Get-VApp Import-VApp Move-VApp New-VApp Remove-VApp Set-VApp Start-VApp Stop-VApp VApp Get-VsanClusterConfiguration Set-VsanClusterConfiguration Test-VsanClusterHealth Get-VsanDisk New-VsanDisk Remove-VsanDisk Get-VsanDiskGroup New-VsanDiskGroup Remove-VsanDiskGroup Get-VsanFaultDomain New-VsanFaultDomain Remove-VsanFaultDomain Set-VsanFaultDomain Update-VsanHclDatabase Test-VsanNetworkPerformance Get-VsanResyncingComponent Get-VsanSpaceUsage Test-VsanStoragePerformance Test-VsanVMCreation vSAN Operations Dismount-Tools Mount-Tools Update-Tools Wait-Tools Get-VMGuest Restart-VMGuest Shutdown-VMGuest Stop-VMGuest Suspend-VMGuest Copy-VMGuestFile Get-VMGuestNetworkInterface Set-VMGuestNetworkInterface Get-VMGuestRoute New-VMGuestRoute Remove-VMGuestRoute Invoke-VMScript Guest OS Remove-VDSwitchPrivateVlan Add-VDSwitchVMHost Remove-VDSwitchVMHost Get-VDTrafficShapingPolicy Set-VDTrafficShapingPolicy Get-VDUplinkLacpPolicy Set-VDUplinkLacpPolicy Get-VDUplinkTeamingPolicy Set-VDUplinkTeamingPolicy Set-VDVlanConfiguration Get-VirtualPortGroup New-VirtualPortGroup Remove-VirtualPortGroup Set-VirtualPortGroup Get-VirtualSwitch New-VirtualSwitch Remove-VirtualSwitch Set-VirtualSwitch Get-SecurityPolicy Set-SecurityPolicy Add-VirtualSwitchPhysicalNetworkAdapter Remove-VirtualSwitchPhysicalNetworkAdapter Get-VDBlockedPolicy Set-VDBlockedPolicy Get-VDPort Set-VDPort Export-VDPortGroup Get-VDPortgroup New-VDPortgroup Remove-VDPortGroup Set-VDPortgroup Get-VDPortgroupOverridePolicy Set-VDPortgroupOverridePolicy Get-VDSecurityPolicy Set-VDSecurityPolicy Export-VDSwitch Get-VDSwitch New-VDSwitch Remove-VDSwitch Set-VDSwitch Add-VDSwitchPhysicalNetworkAdapter Remove-VDSwitchPhysicalNetworkAdapter Get-VDSwitchPrivateVlan New-VDSwitchPrivateVlan Network Get-Datastore Move-Datastore New-Datastore Remove-Datastore Set-Datastore Get-ESX Get-EsxCli Get-EsxTop Get-HAPrimaryVMHost Get-IScsiHbaTarget New-IScsiHbaTarget Remove-IScsiHbaTarget Set-IScsiHbaTarget Get-NicTeamingPolicy Set-NicTeamingPolicy Add-PassthroughDevice Get-PassthroughDevice Remove-PassthroughDevice Get-ScsiController New-ScsiController Set-ScsiController Get-ScsiLun Set-ScsiLun Get-ScsiLunPath Set-ScsiLunPath Add-VirtualSwitchPhysicalNetworkAdapter Remove-VirtualSwitchPhysicalNetworkAdapter Add-VMHost Get-VMHost Move-VMHost Remove-VMHost Restart-VMHost Set-VMHost Start-VMHost Stop-VMHost Suspend-VMHost Get-VMHostAccount New-VMHostAccount Remove-VMHostAccount Set-VMHostAccount Get-VMHostAdvancedConfiguration Set-VMHostAdvancedConfiguration Get-VMHostAuthentication Set-VMHostAuthentication Get-VMHostAvailableTimeZone Get-VMHostDiagnosticPartition Set-VMHostDiagnosticPartition Get-VMHostDisk Format-VMHostDiskPartition Get-VMHostDiskPartition Get-VMHostFirewallDefaultPolicy Set-VMHostFirewallDefaultPolicy Get-VMHostFirewallException Set-VMHostFirewallException Get-VMHostFirmware Set-VMHostFirmware Get-VMHostHardware Get-VMHostHba Set-VMHostHba Get-VMHostModule Set-VMHostModule Get-VMHostNetwork Set-VMHostNetwork Get-VMHostNetworkAdapter New-VMHostNetworkAdapter Remove-VMHostNetworkAdapter Set-VMHostNetworkAdapter Add-VMHostNtpServer Get-VMHostNtpServer Remove-VMHostNtpServer Get-VMHostPatch Install-VMHostPatch Get-VMHostPciDevice Get-VMHostRoute New-VMHostRoute Remove-VMHostRoute Set-VMHostRoute Get-VMHostService Restart-VMHostService Set-VMHostService Start-VMHostService Stop-VMHostService Get-VMHostSnmp Set-VMHostSnmp Test-VMHostSnmp Get-VMHostStartPolicy Set-VMHostStartPolicy Get-VMHostStorage Set-VMHostStorage Get-VMHostSysLogServer Set-VMHostSysLogServer Get-VMStartPolicy Set-VMStartPolicy ESXi Host Operations Get-AdvancedSetting New-AdvancedSetting Remove-AdvancedSetting Set-AdvancedSetting Get-AlarmAction New-AlarmAction Remove-AlarmAction Get-AlarmActionTrigger New-AlarmActionTrigger Remove-AlarmActionTrigger Get-AlarmDefinition Set-AlarmDefinition Get-Annotation Set-Annotation Connect-CisServer Disconnect-CisServer Get-CisService Get-Cluster Get-ContentLibraryItem Get-CustomAttribute New-CustomAttribute Remove-CustomAttribute Set-CustomAttribute Get-Datacenter Move-Datacenter New-Datacenter Remove-Datacenter Set-Datacenter Get-DatastoreCluster New-DatastoreCluster Remove-DatastoreCluster Set-DatastoreCluster New-DatastoreDrive Copy-DatastoreItem Get-Folder Move-Folder New-Folder Remove-Folder Set-Folder Get-Inventory Move-Inventory Remove-Inventory Get-LicenseDataManager Get-OSCustomizationNicMapping New-OSCustomizationNicMapping Remove-OSCustomizationNicMapping Set-OSCustomizationNicMapping Get-OSCustomizationSpec New-OSCustomizationSpec Remove-OSCustomizationSpec Set-OSCustomizationSpec Get-OvfConfiguration Get-Task Stop-Task Wait-Task Get-VIAccount Get-VICommand Get-VICredentialStoreItem New-VICredentialStoreItem Remove-VICredentialStoreItem Get-View New-VIInventoryDrive Get-VIObjectByVIView Get-VIPermission New-VIPermission Remove-VIPermission Set-VIPermission Get-VIPrivilege Get-VIProperty New-VIProperty Remove-VIProperty Get-VIRole New-VIRole Remove-VIRole Set-VIRole Connect-VIServer Disconnect-VIServer vSphere VMware PowerCLI Update Manager vRealize Operations vCloud Air Cloud Infrastructure vSphere Core Auto Deploy Image Builder vCloud High Availability Horizon View License Manager Storage Distributed Switch Mirage UEM Get-CDDrive New-CDDrive Remove-CDDrive Set-CDDrive Get-FloppyDrive New-FloppyDrive Remove-FloppyDrive Set-FloppyDrive Copy-HardDisk Get-HardDisk Move-HardDisk New-HardDisk Remove-HardDisk Set-HardDisk Get-NetworkAdapter New-NetworkAdapter Remove-NetworkAdapter Set-NetworkAdapter Add-PassthroughDevice Get-PassthroughDevice Remove-PassthroughDevice Get-Snapshot New-Snapshot Remove-Snapshot Set-Snapshot Get-Template Move-Template New-Template Remove-Template Set-Template Get-UsbDevice Remove-UsbDevice Export-VM Get-VM Move-VM New-VM Remove-VM Restart-VM Set-VM Start-VM Stop-VM Suspend-VM Open-VMConsoleWindow Answer-VMQuestion Get-VMQuestion Set-VMQuestion Get-VMResourceConfiguration Set-VMResourceConfiguration VM Operations To list all the snapshots for all virtual machines: Get-VM | Get-Snapshot To snapshot a VM: New-Snapshot -VM "XP SP2" -Name BeforePatch1 To remove a snapshot: Remove-Snapshot -Snapshot $snapshot1 –RemoveChildren Snapshot Operations Top 5 VM memory allocation: Get-VM | Sort-Object -Property MemoryGB -Descending | Select -First 5 Total memory available on all ESXi: Get-VMHost | Measure-Object -Property MemoryTotalGB -Sum | Select -ExpandProperty Sum Report on NumCPU and number of VM: Get-VM | Group-Object -Property NumCpu | Select @{N="NumCpu";E={$_.Name}},@{N="Number of VM";E={$_.Count}} Most API methods require parameters. You create those with New-Object: $vm = Get-VM -Name MyVM $spec = New-Object VMware.Vim.VirtualMachineConfigSpec $spec.latencySensitivity = New-Object VMware.Vim.LatencySensitivity $spec.LatencySensitivity.Level = [VMware.Vim.LatencySensitivitySensitivityLevel]::high $vm.ExtensionData.reReconfigVM($spec) Quick Helpful Commands To list all resource pools on the connected VMware vSphere server and some of their properties: Get-ResourcePool To create a new resource pool: $clusterRootRP = Get-ResourcePool -Location (Get-Cluster ResearchAndDevelopmentCluster) -Name Resources New-ResourcePool -Location $clusterRootRP -Name DevelopmentResources -CpuExpandableReservation $true -CpuReservationMhz 500 -CpuSharesLevel high -MemExpandableReservation $true -MemReservationMB 500 -MemSharesLevel high Resource Pool Operations To list all tasks for a VMware vSphere server and some of their properties: Get-Task To stop a task (example: stops the task of removing the VM): Stop-Task -Task (Remove-VM -VM "Lync-Edge-03" -Confirm -RunAsync) To wait until a task is completed before continuing: Wait-Task -Task (Remove-VM -VM "Lync-Edge-03" -Confirm -RunAsync) Task Information Invoke-VMScript allows BIN, BASH, and Powershell Commands to be invoked remotely Invoke-VMScript -VM LABTEST1 -ScriptText "dir" -GU Administrator -GP "VMware1!" Invoke Commands in Virtual Machines Create a tag category: New-TagCategory -Name "Owner" -Cardinality Single -EntityType VirtualMachine Remove-TagCategory "Owner" Create a tag: $myTag = New-Tag -Name "jSmith" -Category "Owner" Assign a tag: Get-VM -Name "Lync-Edge-*" | New-TagAssignment -Tag $myTag Get-VM -Tag "jSmith" Tag Operations Using OVFConfiguration to deploy vApps: $ovfconfig = get-OvfConfiguration myOvfTemplate.ovf$ovfconfig.ToHashtable() Use a hashtable: $ovfconfig = @{ "vami.DNS.VMware_vCenter_Log_Insight" = "10.144.99.5"; "vami.gateway.VMware_vCenter_Log_Insight" = "10.144.99.1"; "vami.ip0.VMware_vCenter_Log_Insight" = "10.144.99.30"; "vami.netmask0.VMware_vCenter_Log_Insight" = "255.255.255.0"; "vm.rootpw" = "VMware1!";} Or populate an object: $ovfconfig.NetworkMapping.Network.Value = “Network 1$ovfconfig.vami.VM_1.ip0.Value = “10.144.99.30$ovfPath = “c:\temp\myOvfTemplate.ovfImport-Vapp $ovfPath -OvfConfiguration $ovfConfig -VMHost $vmHost -Name VM_OVFOVF Configuration Returns a VMware vSphere.Net view object by specified search criteria. $vm = Get-View -ViewType VirtualMachine -Filter @{"Name" = "MS Win XP SP2"} $hostView = Get-View -ID $vm.Runtime.Host $hostView.Summary.Runtime Another example: (Get-View (Get-VMHost 'ESX1' | getview). ConfigManager.VmotionSystem).SelectVnc('vmk0') API Reference: https://www.vmware.com/support/developer/vc-sdk/ API Operations To list all of the VSAN disks groups for an ESXi host: Get-VsanDiskGroup -VMHost (Get-VMHost | select -first 1) To list all of the disks within a VSAN disk group for an ESXi host: $vmhost = Get-VMHost | select -First 1 $vsanDiskGroup = Get-VsanDiskGroup -VMHost $vmhost Get-VsanDisk -VsanDiskGroup $vsanDiskGroup To create a new VSAN disk group for an ESXi host $vmhost = Get-VMHost | select -First 1 $ssd = Get-ScsiLun -VmHost $vmhost | where {$_.extensiondata.ssd -eq $true -and $_.ExtensionData.LocalDisk -eq $true} $datadisk = Get-ScsiLun -VmHost $vmhost | where {$_.extensiondata.ssd -eq $false - and $_.ExtensionData.LocalDisk -eq $true} New-VsanDiskGroup -VMHost $vmhost -SsdCanonicalName $ssd.CanonicalName - DataDiskCanonicalName $datadisk.CanonicalName To remove a disk from a VSAN disk group: $vmhost = Get-VMHost | select -First 1 $vsanDiskGroup = Get-VsanDiskGroup -VMHost $vmhost $vsanDisk = Get-VsanDisk -VsanDiskGroup $vsanDiskGroup | select -first 1 Remove-VsanDisk -VsanDisk $vsanDisk vSAN Operations To list all virtual switches attached to a VM and some of their properties, use: Get-VirtualSwitch -VM (Get-VM -Name "Lync-Edge-03") To create a new virtual switch: New-VirtualSwitch -VMHost (Get-VMHost -Name 192.168.0.10) -Name Switch02 To remove a virtual switch: $vs = Get-VirtualSwitch -VMHost 192.168.0.10 -Name VS23 Remove-VirtualSwitch -VirtualSwitch $vs To change the configuration of a virtual switch: $vs = New-VirtualSwitch -Host 192.168.0.10 -Name VirtSwitch Set-VirtualSwitch -VirtualSwitch $vs -MTU 500 Virtual Switch Operations Get-AlarmDefinition # Returns all the defined alarms on the servers you’re connected to. Get-AlarmDefinition -Name "virtual machine*" -Enabled $false # Returns all the disabled alarm definitions with names starting with “virtual machine.” Get-VMHost hostname | Get-AlarmDefinition # Returns all alarms that apply to the host “hostname”. Includes alarms defined on this host and alarms inherited from the parent entity, or from any ancestors in the inventory hierarchy. Modify an alarm definition: Get-AlarmDefinition "Host memory status" | Set-AlarmDefinition -Name "Host memory" -Enabled $false # This will rename the alarm to “Host memory” and disable it. Events and Alarms To list all the port groups and some of their properties: $vs = Get-VirtualSwitch -VMHost 192.168.0.10 -Name Switch02 Get-VirtualPortGroup -VirtualSwitch $vs To add a new port group to a virtual switch: $vs = Get-VirtualSwitch -VMHost 192.168.0.10 -Name Switch02 $vpg = New-VirtualPortGroup -VirtualSwitch $vs -Name VPG1 Other cmdlets include: Remove-VirtualPortGroup Set-VirtualPortGroup Port Group Operations To connect to a VMware vSphere server. Start a new session or reestablish a previous session with a VMware vSphere server. $srv = Connect-VIServer –Server 192.168.0.10 -User Admin -Password Pass01 To disconnect from the connected vSphere server: Disconnect-VIServer -Server $srv -Confirm:$false How to Connect to vCenter Server or ESXi Utilizing the Get-ESXCLI cmdlet with new -V2 parameter to perform two pings from an ESXi host: $esxcli2 = Get-ESXCLI -VMHost (Get-VMhost | Select -first 1) -V2 $arguments = $esxcli2.network.diag.ping.CreateArgs() $arguments.count = 2 $arguments.host = “10.0.0.8” $esxcli2.network.diag.ping.Invoke($arguments) Utilizing the Get-ESXCLI cmdlet with new -V2 parameter to perform two pings from an ESXi host: $esxcli2 = Get-ESXCLI -VMHost (Get-VMhost | Select -first 1) -V2 $arguments = $esxcli2.storage.vmfs.unmap.CreateArgs() $arguments.volumelabel = “Datastore1” $esxcli2.storage.vmfs.unmap.Invoke($arguments) ESXCLI V2 Operations The VMware PowerCLI Community Repository is a central location where anyone can contribute their own resources. The repository features a Principles of Operations document to help guide contributors along the process of using, creating, and updating resources which are contained within the repository. Link: https://github.com/vmware/PowerCLI-Example-Scripts Featured Modules: - Horizon View Helper - VM Encryption - vCenter High Availability Featured Scripts: - Home Lab Deployment - Affinity Rule Creation - LUN Path Report PowerCLI Community Repository Method to not have to input credentials every time you connect to vCenter: New-VICredentialStoreItem -Host vCSA.lab.local -User Root -Password "VMware1!" To remove credentials: Remove-VICredentialStoreItem -Host vCSA.lab.local -Confirm How to Store vCenter Credentials PowerCLI Community Get-EsxTop –Counter # View the fields available for vCPU counter: (Get-EsxTop –Counter –CounterName VCPU).Fields Get-EsxTop –TopologyInfo # View the entries of a specific topology: (Get-EsxTop –TopologyInfo –Topology SchedGroup).Entries | FT # Retrieve the counter values for “VCPU” and “SchedGroup" counters: Get-EsxTop –CounterName VCPU | FT * -AutoSize Get-EsxTop –CounterName SchedGroup | FT * -AutoSize ESXTOP through PowerCLI Files can be copied between user’s local machine and a VM Copy from a VM to the Local Machine: Copy-VMGuestFile -VM LABTEST1 -GuestUser Administrator -GuestPassword "VMware1!" -GuestToLocal -Source c:\temp\logfile.txt -Destination c:\temp\ Copy Files To/From VM Connect to vCenter Server first Connect-SrmServer -SrmServerAddress 10.144.99.6 -User "administrator" -Password "myPassword" Disconnect-SrmServer -Server 10.144.99.6 How to Connect to SRM Connect to the Horizon View Server: $hvserver = Connect-HVServer -Server view connection.fqdn -User administrator -Password VMware1! -Domain domain.local Access the Horizon View API: $hvapi = $global:defaultHVservers[0] .ExtensionData View the health of the Horizon View Connection Servers: $hvapi.connectionserverhealth .connectionserverhealth_list() View the Horizon View Session Data: $hvapi.connectionserverhealth .connectionserverhealth_list(). ConnectionData View connected vCenter Servers: $hvapi. VirtualCenter.VirtualCenter_List() Horizon View API Reference: http://developercenter.vmware.com/web /dp/explorer-apis/4595/view Horizon View Operations Official PowerCLI Blog - http://blogs.vmware.com/PowerCLI/ Documentation - http://vmware.com/support/developer/PowerCLI/index.html VMware PowerCLI Community - http://vmware.com/go/powercli Twitter - https://twitter.com/PowerCLI LinkedIn - http://www.linkedin.com/groups/PowerCLI-Users-162324 Facebook - https://www.facebook.com/vmwarepowercli Slack - https://code.vmware.com/web/code/join VMware Education Course: Data Center Automation with vRealize Orchestrator and vSphere PowerCLI - https://mylearn.vmware.com/mgrreg/courses.cfm?a=one&id_subject=71972 Third-Party PowerCLI training from Pluralsight - http://www.pluralsight.com PowerCLI Sites VMware Flings featuring PowerCLI - https://labs.vmware.com/flings/?product=PowerCLI PowerCLI Core - Enable users of Linux, Mac and Docker to now use the same cmdlets which were previously only available on Windows. PowerActions for vSphere Web Client - PowerActions integrates the vSphere Web Client and PowerCLI to provide complex automation solutions from within the standard vSphere management client. Onyx for the Web Client - Onyx for the Web Client is a Fling that translates actions taken in the vSphere Web Client to PowerCLI.Net code. PowerCLI Extensions - PowerCLI Extensions gives PowerCLI users early access to functionality by extending the core PowerCLI cmdlets to include new experimental features and gives PowerCLI users the ability to provide early feedback. PowerCLI Based Flings What is PowerCLI? VMware PowerCLI is a powerful, easy-to-use scripting interface to manage the vSphere platform. Administrators can leverage more than 360 cmdlets to simplify everyday tasks. PowerCLI Info VMware PowerCLI frequently asked questions (FAQs) link: http://communities.vmware.com/docs/DOC-13700 To find out what cmdlets are available: Get-VICommand To show documentation for all available cmdlets: Get-PowerCLIDocumentation For help with a cmdlet: Get-Help cmdlet-name –Full Getting Started

Upload: truongkhue

Post on 10-Apr-2018

280 views

Category:

Documents


8 download

TRANSCRIPT

Page 1: VMware PowerCLI 6.5 Release 1 Reference Poster · VMware PowerCLI 6.5 Release 1 Reference Poster ... Test-DeployRuleSetCompliance ... or from any ancestors in the inventory hierarchy

Get-CatalogGet-CIAccessControlRule

New-CIAccessControlRuleRemove-CIAccessControlRule

Set-CIAccessControlRuleAdd-CIDatastoreGet-CIDatastore

Get-CINetworkAdapterSet-CINetworkAdapter

Get-CIRoleConnect-CIServer

Disconnect-CIServerGet-CIUser

Get-CIVAppImport-CIVApp

New-CIVAppRemove-CIVAppRestart-CIVApp

Set-CIVAppStart-CIVAppStop-CIVApp

Suspend-CIVAppRestart-CIVAppGuest

Stop-CIVAppGuestSuspend-CIVAppGuest

Get-CIVAppNetworkNew-CIVAppNetwork

Remove-CIVAppNetworkSet-CIVAppNetwork

Get-CIVAppStartRuleSet-CIVAppStartRuleGet-CIVAppTemplate

Import-CIVAppTemplateNew-CIVAppTemplate

Remove-CIVAppTemplateSet-CIVAppTemplate

Get-CIViewGet-CIVM

New-CIVMRestart-CIVM

Start-CIVMStop-CIVM

Suspend-CIVMRestart-CIVMGuest

Stop-CIVMGuestGet-CIVMTemplate

Search-CloudGet-CloudCommandGet-ExternalNetwork

Get-MediaGet-NetworkPool

Get-OrgNew-Org

Remove-OrgSet-Org

Get-OrgNetworkNew-OrgNetwork

Remove-OrgNetworkSet-OrgNetwork

Get-OrgVdcNew-OrgVdc

Remove-OrgVdcSet-OrgVdc

Get-OrgVdcNetwork

Cloud

http://blogs.vmware.com/PowerCLI/Copyright © 2017 VMware, Inc. All rights reserved. @PowerCLI @vmwarepowercli @PowerCLI

VMware PowerCLI 6.5 Release 1 Reference Poster

Get-PowerCLIConfigurationSet-PowerCLIConfiguration

Get-PowerCLIDocumentationGet-PowerCLIVersion

Get-PowerCLICommunityGet-PowerCLIHelp

PowerCLI Settings

Get-NfsUserNew-NfsUser

Remove-NfsUserSet-NfsUser

Get-SpbmCapabilityGet-SpbmCompatibleStorageGet-SpbmEntityConfigurationSet-SpbmEntityConfiguration

Get-SpbmFaultDomainStart-SpbmReplicationFailover

Get-SpbmReplicationGroupSync-SpbmReplicationGroup

Get-SpbmReplicationPairStart-SpbmReplicationPrepareFailover

Start-SpbmReplicationReverseNew-SpbmRule

New-SpbmRuleSetExport-SpbmStoragePolicy

Get-SpbmStoragePolicyImport-SpbmStoragePolicy

New-SpbmStoragePolicyRemove-SpbmStoragePolicy

Set-SpbmStoragePolicyGet-VAIOFilter

New-VAIOFilterRemove-VAIOFilter

Set-VAIOFilterGet-VasaProvider

New-VasaProviderRemove-VasaProviderGet-VasaStorageArray

Copy-VDiskGet-VDisk

Move-VDiskNew-VDisk

Remove-VDiskSet-VDisk

Storage Operations

Switch-ActiveDeployRuleSetGet-AutoDeployCommand

Export-AutoDeployStateImport-AutoDeployState

Repair-DeployImageCacheGet-DeployOptionSet-DeployOption

Add-DeployRuleCopy-DeployRule

Get-DeployRuleNew-DeployRule

Remove-DeployRuleSet-DeployRule

Get-DeployRuleSetSet-DeployRuleSet

Repair-DeployRuleSetComplianceTest-DeployRuleSetCompliance

Apply-ESXImageProfileSet-ESXImageProfileAssociation

Add-ProxyServerGet-ProxyServer

Remove-ProxyServerAdd-ScriptBundleGet-ScriptBundle

Get-VMHostAttributesGet-VMHostImageProfile

Get-VMHostMatchingRules

AutoDeploy

Move-ClusterNew-Cluster

Remove-ClusterSet-Cluster

Get-DrmInfoApply-DrsRecommendation

Get-DrsRecommendationInvoke-DrsRecommendation

Get-DrsRuleNew-DrsRule

Remove-DrsRuleSet-DrsRule

Get-ResourcePoolMove-ResourcePoolNew-ResourcePool

Remove-ResourcePoolSet-ResourcePool

Cluster Operations

Attach-BaselineDetach-Baseline

Get-BaselineRemove-BaselineGet-ComplianceTest-Compliance

Update-EntityAdd-EntityBaseline

Remove-EntityBaselineRemediate-Inventory

Scan-InventoryCopy-Patch

Download-PatchGet-Patch

Stage-PatchSync-Patch

Get-PatchBaselineNew-PatchBaselineSet-PatchBaseline

Update Manager

Compare-EsxImageProfileExport-EsxImageProfile

Get-EsxImageProfileNew-EsxImageProfile

Remove-EsxImageProfileSet-EsxImageProfile

Add-EsxSoftwareDepotGet-EsxSoftwareDepot

Remove-EsxSoftwareDepotAdd-EsxSoftwarePackageGet-EsxSoftwarePackage

Remove-EsxSoftwarePackageGet-ImageBuilderCommand

Image Builder

Connect-SrmServerDisconnect-SrmServer

SRM

Connect-HVServerDisconnect-HVServer

Horizon View

Get-OMAlert

Set-OMAlert

Get-OMAlertDefinition

Get-OMAlertSubType

Get-OMAlertType

Get-OMRecommendation

Get-OMResource

Connect-OMServer

Disconnect-OMServer

Get-OMStat

Get-OMStatKey

Get-OMUser

vR Ops

Apply-VMHostProfileExport-VMHostProfile

Get-VMHostProfileImport-VMHostProfileInvoke-VMHostProfile

New-VMHostProfileRemove-VMHostProfile

Set-VMHostProfileTest-VMHostProfileCompliance

Get-VMHostProfileRequiredInput

Host Profiles

Get-TagNew-Tag

Remove-TagSet-Tag

Get-TagAssignmentNew-TagAssignment

Remove-TagAssignmentGet-TagCategory

New-TagCategoryRemove-TagCategory

Set-TagCategory

Tag Operations

Get-LogGet-LogType

Get-StatGet-StatInterval

New-StatIntervalRemove-StatInterval

Set-StatIntervalGet-StatType

Get-ErrorReportGet-VIEvent

Logging and Statistics

Export-VAppGet-VApp

Import-VAppMove-VAppNew-VApp

Remove-VAppSet-VApp

Start-VAppStop-VApp

VApp

Get-VsanClusterConfigurationSet-VsanClusterConfiguration

Test-VsanClusterHealthGet-VsanDisk

New-VsanDiskRemove-VsanDisk

Get-VsanDiskGroupNew-VsanDiskGroup

Remove-VsanDiskGroupGet-VsanFaultDomain

New-VsanFaultDomainRemove-VsanFaultDomain

Set-VsanFaultDomainUpdate-VsanHclDatabase

Test-VsanNetworkPerformanceGet-VsanResyncingComponent

Get-VsanSpaceUsageTest-VsanStoragePerformance

Test-VsanVMCreation

vSAN Operations

Dismount-ToolsMount-Tools

Update-ToolsWait-Tools

Get-VMGuestRestart-VMGuest

Shutdown-VMGuestStop-VMGuest

Suspend-VMGuestCopy-VMGuestFile

Get-VMGuestNetworkInterfaceSet-VMGuestNetworkInterface

Get-VMGuestRouteNew-VMGuestRoute

Remove-VMGuestRouteInvoke-VMScript

Guest OS

Remove-VDSwitchPrivateVlanAdd-VDSwitchVMHost

Remove-VDSwitchVMHostGet-VDTra�cShapingPolicySet-VDTra�cShapingPolicy

Get-VDUplinkLacpPolicySet-VDUplinkLacpPolicy

Get-VDUplinkTeamingPolicySet-VDUplinkTeamingPolicy

Set-VDVlanConfigurationGet-VirtualPortGroup

New-VirtualPortGroupRemove-VirtualPortGroup

Set-VirtualPortGroupGet-VirtualSwitch

New-VirtualSwitchRemove-VirtualSwitch

Set-VirtualSwitchGet-SecurityPolicySet-SecurityPolicy

Add-VirtualSwitchPhysicalNetworkAdapterRemove-VirtualSwitchPhysicalNetworkAdapter

Get-VDBlockedPolicySet-VDBlockedPolicy

Get-VDPortSet-VDPort

Export-VDPortGroupGet-VDPortgroup

New-VDPortgroupRemove-VDPortGroup

Set-VDPortgroupGet-VDPortgroupOverridePolicySet-VDPortgroupOverridePolicy

Get-VDSecurityPolicySet-VDSecurityPolicy

Export-VDSwitchGet-VDSwitch

New-VDSwitchRemove-VDSwitch

Set-VDSwitchAdd-VDSwitchPhysicalNetworkAdapter

Remove-VDSwitchPhysicalNetworkAdapterGet-VDSwitchPrivateVlan

New-VDSwitchPrivateVlan

Network

Get-DatastoreMove-DatastoreNew-Datastore

Remove-DatastoreSet-Datastore

Get-ESXGet-EsxCli

Get-EsxTopGet-HAPrimaryVMHost

Get-IScsiHbaTargetNew-IScsiHbaTarget

Remove-IScsiHbaTargetSet-IScsiHbaTarget

Get-NicTeamingPolicySet-NicTeamingPolicy

Add-PassthroughDeviceGet-PassthroughDevice

Remove-PassthroughDeviceGet-ScsiController

New-ScsiControllerSet-ScsiController

Get-ScsiLunSet-ScsiLun

Get-ScsiLunPathSet-ScsiLunPath

Add-VirtualSwitchPhysicalNetworkAdapterRemove-VirtualSwitchPhysicalNetworkAdapter

Add-VMHostGet-VMHost

Move-VMHostRemove-VMHostRestart-VMHost

Set-VMHostStart-VMHostStop-VMHost

Suspend-VMHostGet-VMHostAccount

New-VMHostAccountRemove-VMHostAccount

Set-VMHostAccountGet-VMHostAdvancedConfigurationSet-VMHostAdvancedConfiguration

Get-VMHostAuthenticationSet-VMHostAuthentication

Get-VMHostAvailableTimeZoneGet-VMHostDiagnosticPartitionSet-VMHostDiagnosticPartition

Get-VMHostDiskFormat-VMHostDiskPartition

Get-VMHostDiskPartition

Get-VMHostFirewallDefaultPolicySet-VMHostFirewallDefaultPolicy

Get-VMHostFirewallExceptionSet-VMHostFirewallException

Get-VMHostFirmwareSet-VMHostFirmwareGet-VMHostHardware

Get-VMHostHbaSet-VMHostHba

Get-VMHostModuleSet-VMHostModule

Get-VMHostNetworkSet-VMHostNetwork

Get-VMHostNetworkAdapterNew-VMHostNetworkAdapter

Remove-VMHostNetworkAdapterSet-VMHostNetworkAdapter

Add-VMHostNtpServerGet-VMHostNtpServer

Remove-VMHostNtpServerGet-VMHostPatch

Install-VMHostPatchGet-VMHostPciDevice

Get-VMHostRouteNew-VMHostRoute

Remove-VMHostRouteSet-VMHostRoute

Get-VMHostServiceRestart-VMHostService

Set-VMHostServiceStart-VMHostServiceStop-VMHostService

Get-VMHostSnmpSet-VMHostSnmp

Test-VMHostSnmpGet-VMHostStartPolicySet-VMHostStartPolicy

Get-VMHostStorageSet-VMHostStorage

Get-VMHostSysLogServerSet-VMHostSysLogServer

Get-VMStartPolicySet-VMStartPolicy

ESXi Host Operations

Get-AdvancedSettingNew-AdvancedSetting

Remove-AdvancedSettingSet-AdvancedSetting

Get-AlarmActionNew-AlarmAction

Remove-AlarmActionGet-AlarmActionTrigger

New-AlarmActionTriggerRemove-AlarmActionTrigger

Get-AlarmDefinitionSet-AlarmDefinition

Get-AnnotationSet-Annotation

Connect-CisServerDisconnect-CisServer

Get-CisServiceGet-Cluster

Get-ContentLibraryItemGet-CustomAttribute

New-CustomAttributeRemove-CustomAttribute

Set-CustomAttributeGet-Datacenter

Move-DatacenterNew-Datacenter

Remove-DatacenterSet-Datacenter

Get-DatastoreClusterNew-DatastoreCluster

Remove-DatastoreClusterSet-DatastoreClusterNew-DatastoreDriveCopy-DatastoreItem

Get-FolderMove-FolderNew-Folder

Remove-FolderSet-Folder

Get-InventoryMove-Inventory

Remove-InventoryGet-LicenseDataManager

Get-OSCustomizationNicMappingNew-OSCustomizationNicMapping

Remove-OSCustomizationNicMappingSet-OSCustomizationNicMapping

Get-OSCustomizationSpecNew-OSCustomizationSpec

Remove-OSCustomizationSpecSet-OSCustomizationSpec

Get-OvfConfiguration

Get-TaskStop-TaskWait-Task

Get-VIAccountGet-VICommand

Get-VICredentialStoreItemNew-VICredentialStoreItem

Remove-VICredentialStoreItemGet-View

New-VIInventoryDriveGet-VIObjectByVIView

Get-VIPermissionNew-VIPermission

Remove-VIPermissionSet-VIPermission

Get-VIPrivilegeGet-VIProperty

New-VIPropertyRemove-VIProperty

Get-VIRoleNew-VIRole

Remove-VIRoleSet-VIRole

Connect-VIServerDisconnect-VIServer

vSphere

VMware PowerCLI

UpdateManager

vRealizeOperations vCloud Air Cloud

Infrastructure

vSphere Core Auto Deploy Image Builder vCloud HighAvailability

Horizon View LicenseManager Storage Distributed

Switch Mirage

UEM

Get-CDDriveNew-CDDrive

Remove-CDDriveSet-CDDrive

Get-FloppyDriveNew-FloppyDrive

Remove-FloppyDriveSet-FloppyDrive

Copy-HardDiskGet-HardDisk

Move-HardDiskNew-HardDisk

Remove-HardDiskSet-HardDisk

Get-NetworkAdapterNew-NetworkAdapter

Remove-NetworkAdapterSet-NetworkAdapter

Add-PassthroughDeviceGet-PassthroughDevice

Remove-PassthroughDeviceGet-Snapshot

New-SnapshotRemove-Snapshot

Set-SnapshotGet-Template

Move-TemplateNew-Template

Remove-TemplateSet-Template

Get-UsbDeviceRemove-UsbDevice

Export-VMGet-VM

Move-VMNew-VM

Remove-VMRestart-VM

Set-VMStart-VMStop-VM

Suspend-VMOpen-VMConsoleWindow

Answer-VMQuestionGet-VMQuestionSet-VMQuestion

Get-VMResourceConfigurationSet-VMResourceConfiguration

VM Operations

To list all the snapshots for all virtual machines:Get-VM | Get-SnapshotTo snapshot a VM: New-Snapshot -VM "XP SP2" -Name BeforePatch1To remove a snapshot: Remove-Snapshot -Snapshot $snapshot1 –RemoveChildren

Snapshot Operations

Top 5 VM memory allocation:Get-VM | Sort-Object -Property MemoryGB -Descending | Select-First 5

Total memory available on all ESXi:Get-VMHost | Measure-Object -Property MemoryTotalGB -Sum |Select -ExpandProperty Sum

Report on NumCPU and number of VM:Get-VM | Group-Object -Property NumCpu |Select @{N="NumCpu";E={$_.Name}},@{N="Number ofVM";E={$_.Count}}

Most API methods require parameters.You create those with New-Object:$vm = Get-VM -Name MyVM$spec = New-Object VMware.Vim.VirtualMachineConfigSpec$spec.latencySensitivity = New-ObjectVMware.Vim.LatencySensitivity$spec.LatencySensitivity.Level =[VMware.Vim.LatencySensitivitySensitivityLevel]::high$vm.ExtensionData.reReconfigVM($spec)

Quick Helpful Commands

To list all resource pools on the connected VMware vSphere server and some oftheir properties: Get-ResourcePool

To create a new resource pool:$clusterRootRP = Get-ResourcePool -Location(Get-Cluster ResearchAndDevelopmentCluster) -Name ResourcesNew-ResourcePool -Location $clusterRootRP -Name DevelopmentResources-CpuExpandableReservation $true -CpuReservationMhz 500 -CpuSharesLevel high -MemExpandableReservation $true -MemReservationMB 500 -MemSharesLevel high

Resource Pool Operations

To list all tasks for a VMware vSphere server and some of their properties:Get-TaskTo stop a task (example: stops the task of removing the VM):Stop-Task -Task (Remove-VM -VM "Lync-Edge-03" -Confirm -RunAsync)To wait until a task is completed before continuing:Wait-Task -Task (Remove-VM -VM "Lync-Edge-03" -Confirm -RunAsync)

Task Information

Invoke-VMScript allows BIN, BASH, and Powershell Commands to be invoked remotelyInvoke-VMScript -VM LABTEST1 -ScriptText "dir" -GU Administrator -GP "VMware1!"

Invoke Commands in Virtual Machines

Create a tag category:New-TagCategory -Name "Owner" -Cardinality Single -EntityType

VirtualMachineRemove-TagCategory "Owner"Create a tag:$myTag = New-Tag -Name "jSmith" -Category "Owner"Assign a tag:Get-VM -Name "Lync-Edge-*" | New-TagAssignment -Tag $myTagGet-VM -Tag "jSmith"

Tag Operations

Using OVFConfiguration to deploy vApps:$ovfconfig = get-OvfConfiguration “myOvfTemplate.ovf”$ovfconfig.ToHashtable()

Use a hashtable:$ovfconfig = @{"vami.DNS.VMware_vCenter_Log_Insight" = "10.144.99.5";"vami.gateway.VMware_vCenter_Log_Insight" = "10.144.99.1";"vami.ip0.VMware_vCenter_Log_Insight" = "10.144.99.30";"vami.netmask0.VMware_vCenter_Log_Insight" = "255.255.255.0";"vm.rootpw" = "VMware1!";}

Or populate an object:$ovfconfig.NetworkMapping.Network.Value = “Network 1”$ovfconfig.vami.VM_1.ip0.Value = “10.144.99.30”$ovfPath = “c:\temp\myOvfTemplate.ovf”

Import-Vapp $ovfPath -OvfConfiguration $ovfConfig -VMHost $vmHost -Name “VM_OVF”

OVF Configuration

Returns a VMware vSphere.Net view object by specified search criteria.$vm = Get-View -ViewType VirtualMachine -Filter @{"Name" = "MS Win XP SP2"}$hostView = Get-View -ID $vm.Runtime.Host$hostView.Summary.Runtime

Another example:(Get-View (Get-VMHost 'ESX1' | getview).ConfigManager.VmotionSystem).SelectVnc('vmk0')

API Reference: https://www.vmware.com/support/developer/vc-sdk/

API Operations

To list all of the VSAN disks groups for an ESXi host:Get-VsanDiskGroup -VMHost (Get-VMHost | select -first 1)

To list all of the disks within a VSAN disk group for an ESXi host:$vmhost = Get-VMHost | select -First 1$vsanDiskGroup = Get-VsanDiskGroup -VMHost $vmhostGet-VsanDisk -VsanDiskGroup $vsanDiskGroup

To create a new VSAN disk group for an ESXi host$vmhost = Get-VMHost | select -First 1$ssd = Get-ScsiLun -VmHost $vmhost | where {$_.extensiondata.ssd -eq $true -and$_.ExtensionData.LocalDisk -eq $true}$datadisk = Get-ScsiLun -VmHost $vmhost | where {$_.extensiondata.ssd -eq $false -and $_.ExtensionData.LocalDisk -eq $true}New-VsanDiskGroup -VMHost $vmhost -SsdCanonicalName $ssd.CanonicalName -DataDiskCanonicalName $datadisk.CanonicalName

To remove a disk from a VSAN disk group:$vmhost = Get-VMHost | select -First 1$vsanDiskGroup = Get-VsanDiskGroup -VMHost $vmhost$vsanDisk = Get-VsanDisk -VsanDiskGroup $vsanDiskGroup | select -first 1Remove-VsanDisk -VsanDisk $vsanDisk

vSAN Operations

To list all virtual switches attached to a VM and some of their properties, use:Get-VirtualSwitch -VM (Get-VM -Name "Lync-Edge-03")To create a new virtual switch:New-VirtualSwitch -VMHost (Get-VMHost -Name 192.168.0.10) -Name Switch02To remove a virtual switch:$vs = Get-VirtualSwitch -VMHost 192.168.0.10 -Name VS23Remove-VirtualSwitch -VirtualSwitch $vsTo change the configuration of a virtual switch:$vs = New-VirtualSwitch -Host 192.168.0.10 -Name VirtSwitchSet-VirtualSwitch -VirtualSwitch $vs -MTU 500

Virtual Switch Operations

Get-AlarmDefinition # Returns all the defined alarms on the servers you’re connected to.Get-AlarmDefinition -Name "virtual machine*" -Enabled $false# Returns all the disabled alarm definitions with names starting with “virtual machine.”Get-VMHost hostname | Get-AlarmDefinition # Returns all alarms that apply to the host “hostname”. Includes alarms defined on this host and alarms inherited from the parent entity, or from any ancestors in the inventory hierarchy.Modify an alarm definition: Get-AlarmDefinition "Host memory status" |Set-AlarmDefinition -Name "Host memory" -Enabled $false# This will rename the alarm to “Host memory” and disable it.

Events and Alarms

To list all the port groups and some of their properties:$vs = Get-VirtualSwitch -VMHost 192.168.0.10 -Name Switch02Get-VirtualPortGroup -VirtualSwitch $vsTo add a new port group to a virtual switch:$vs = Get-VirtualSwitch -VMHost 192.168.0.10 -Name Switch02$vpg = New-VirtualPortGroup -VirtualSwitch $vs -Name VPG1Other cmdlets include:Remove-VirtualPortGroupSet-VirtualPortGroup

Port Group Operations

To connect to a VMware vSphere server. Start a new session or reestablish aprevious session with a VMware vSphere server.$srv = Connect-VIServer –Server 192.168.0.10 -User Admin -Password Pass01To disconnect from the connected vSphere server:Disconnect-VIServer -Server $srv -Confirm:$false

How to Connect to vCenter Server or ESXi

Utilizing the Get-ESXCLI cmdlet with new -V2 parameter to perform two pings from an ESXi host:$esxcli2 = Get-ESXCLI -VMHost (Get-VMhost | Select -first 1) -V2

$arguments = $esxcli2.network.diag.ping.CreateArgs()$arguments.count = 2$arguments.host = “10.0.0.8”$esxcli2.network.diag.ping.Invoke($arguments)

Utilizing the Get-ESXCLI cmdlet with new -V2 parameter to perform two pings from an ESXi host:$esxcli2 = Get-ESXCLI -VMHost (Get-VMhost | Select -first 1) -V2

$arguments = $esxcli2.storage.vmfs.unmap.CreateArgs()$arguments.volumelabel = “Datastore1”$esxcli2.storage.vmfs.unmap.Invoke($arguments)

ESXCLI V2 Operations

The VMware PowerCLI Community Repository is a central location where anyone can contribute their own resources. The repository features a Principles of Operations document to help guide contributors along the process of using, creating, and updating resources which are contained within the repository.

Link: https://github.com/vmware/PowerCLI-Example-Scripts

Featured Modules:

- Horizon View Helper - VM Encryption- vCenter High Availability

Featured Scripts:

- Home Lab Deployment- A�nity Rule Creation- LUN Path Report

PowerCLI Community Repository

Method to not have to input credentials every time you connect to vCenter:New-VICredentialStoreItem -Host vCSA.lab.local -User Root -Password "VMware1!"To remove credentials: Remove-VICredentialStoreItem -Host vCSA.lab.local -Confirm

How to Store vCenter Credentials

PowerCLI Community

Get-EsxTop –Counter

# View the fields available for vCPU counter:(Get-EsxTop –Counter –CounterName VCPU).FieldsGet-EsxTop –TopologyInfo

# View the entries of a specific topology:(Get-EsxTop –TopologyInfo –Topology SchedGroup).Entries | FT# Retrieve the counter values for “VCPU” and “SchedGroup" counters:Get-EsxTop –CounterName VCPU | FT * -AutoSizeGet-EsxTop –CounterName SchedGroup | FT * -AutoSize

ESXTOP through PowerCLI

Files can be copied between user’s local machine and a VM Copy from a VM to the Local Machine:Copy-VMGuestFile -VM LABTEST1 -GuestUser Administrator -GuestPassword "VMware1!" -GuestToLocal -Source c:\temp\logfile.txt -Destination c:\temp\

Copy Files To/From VM

Connect to vCenter Server firstConnect-SrmServer -SrmServerAddress 10.144.99.6 -User "administrator" -Password "myPassword"Disconnect-SrmServer -Server 10.144.99.6

How to Connect to SRM

Connect to the Horizon View Server: $hvserver = Connect-HVServer -Server

view connection.fqdn -User administrator -Password VMware1! -Domain domain.local

Access the Horizon View API: $hvapi = $global:defaultHVservers[0].ExtensionData

View the health of the Horizon View Connection Servers:$hvapi.connectionserverhealth.connectionserverhealth_list()

View the Horizon View Session Data: $hvapi.connectionserverhealth.connectionserverhealth_list().ConnectionData

View connected vCenter Servers:$hvapi.VirtualCenter.VirtualCenter_List()

Horizon View API Reference: http://developercenter.vmware.com/web/dp/explorer-apis/4595/view

Horizon View Operations

O�cial PowerCLI Blog - http://blogs.vmware.com/PowerCLI/Documentation - http://vmware.com/support/developer/PowerCLI/index.htmlVMware PowerCLI Community - http://vmware.com/go/powercliTwitter - https://twitter.com/PowerCLILinkedIn - http://www.linkedin.com/groups/PowerCLI-Users-162324Facebook - https://www.facebook.com/vmwarepowercliSlack - https://code.vmware.com/web/code/joinVMware Education Course: Data Center Automation with vRealize Orchestrator and vSphere PowerCLI - https://mylearn.vmware.com/mgrreg/courses.cfm?a=one&id_subject=71972

Third-Party PowerCLI training from Pluralsight - http://www.pluralsight.com

PowerCLI Sites

VMware Flings featuring PowerCLI - https://labs.vmware.com/flings/?product=PowerCLI

PowerCLI Core - Enable users of Linux, Mac and Docker to now use the same cmdlets which were previously only available on Windows.PowerActions for vSphere Web Client - PowerActions integrates the vSphere Web Client and PowerCLI to provide complex automation solutions from within the standard vSphere management client.Onyx for the Web Client - Onyx for the Web Client is a Fling that translates actions taken in the vSphere Web Client to PowerCLI.Net code.PowerCLI Extensions - PowerCLI Extensions gives PowerCLI users early access to functionality by extending the core PowerCLI cmdlets to include new experimental features and gives PowerCLI users the ability to provide early feedback.

PowerCLI Based Flings

What is PowerCLI?

VMware PowerCLI is a powerful, easy-to-use scripting interface to manage the vSphere platform. Administrators can leverage more than 360 cmdlets to simplify everyday tasks.

PowerCLI Info

VMware PowerCLI frequently asked questions (FAQs) link:http://communities.vmware.com/docs/DOC-13700To find out what cmdlets are available: Get-VICommandTo show documentation for all available cmdlets: Get-PowerCLIDocumentationFor help with a cmdlet: Get-Help cmdlet-name –Full

Getting Started