1. 在线安装PowerCLI
1.1 命令
Install-Module -Name VMware.PowerCLI
示例
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
PS C:\Users\Administrator> Install-Module -Name VMware.PowerCLI
NuGet provider is required to continue
PowerShellGet requires NuGet provider version '2.8.5.201' or newer to interact with
NuGet-based repositories. The NuGet provider must be available in 'C:\Program
Files\PackageManagement\ProviderAssemblies' or
'C:\Users\Administrator\AppData\Local\PackageManagement\ProviderAssemblies'. You can also
install the NuGet provider by running 'Install-PackageProvider -Name NuGet -MinimumVersion
2.8.5.201 -Force'. Do you want PowerShellGet to install and import the NuGet provider now?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): Y
Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are
you sure you want to install the modules from 'PSGallery'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): A
PS C:\Users\Administrator>
安装时间以网速下载快慢为准。
2. 安装离线版PowerCLI
2.1下载离线安装包
下载链接:VMware PowerCLI
2.2 解压压缩包
将下载的安装包解压并打开。
(1)方法1- 官方方法
(1)在本地计算机上打开 PowerShell。
(2)查看已解压缩 PowerCLI ZIP 文件的文件夹路径,运行命令:$env:PSModulePath
(3)运行命令以解锁复制的文件:Get-ChildItem -Path 'folder_path' -Recurse | Unblock-File
将 folder_path 替换为解压缩 ZIP 文件内容的文件夹路径。
(4)验证 VMware PowerCLI 模块是否已成功安装。
获取模块: VMware* -ListAvailable
PS C:\Users\yz> $env:PSModulePath
C:\Users\yz\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
PS C:\Users\yz> Get-ChildItem -Path 'C:\Program Files\WindowsPowerShell\Modules' -Recurse | Unblock-File
PS C:\Users\yz> Get-Module VMware* -ListAvailable
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 12.6.0.... VMware.CloudServices {Connect-Vcs, Disconnect-Vcs, Get-VcsOrganizationRole, Get-VcsService...}
Script 8.0.0.2... VMware.DeployAutomation {Add-CustomCertificate, Add-DeployRule, Add-ProxyServer, Add-ScriptBundle...}
Script 8.0.0.2... VMware.ImageBuilder {Add-EsxSoftwareDepot, Add-EsxSoftwarePackage, Compare-EsxImageProfile, Export-EsxImageProfile...}
Manifest 13.1.0.... VMware.PowerCLI
Script 12.6.0.... VMware.PowerCLI.Sdk
Script 12.6.0.... VMware.PowerCLI.Sdk.Types
Script 12.6.0.... VMware.PowerCLI.VCenter {Get-VIMachineCertificate, Get-VITrustedCertificate, Remove-VITrustedCertificate, New-VIMachineCertificateSigningRequest...}
Script 12.6.0.... VMware.PowerCLI.VCenter.Types.Ap...
Script 12.6.0.... VMware.PowerCLI.VCenter.Types.Ce...
Script 4.1.0.2... VMware.Sdk.Nsx.Policy {Connect-NsxServer, Connect-NsxVmcServer, Disconnect-NsxServer, Disconnect-NsxVmcServer...}
Script 1.0.111... VMware.Sdk.Runtime {Get-ServerConfiguration, New-ServerConfiguration, Add-ServerConfiguration, Set-ServerConfiguration...}
Script 8.7.0.2... VMware.Sdk.Srm {Connect-SrmSdkServer, Disconnect-SrmSdkServer, Get-SrmOperation, Initialize-SrmAbrProtectionGroupSpec...}
Script 8.7.0.2... VMware.Sdk.Vr {Connect-VrServer, Disconnect-VrServer, Get-VrOperation, Initialize-VrConfigureReplicationSpec...}
Manifest 8.0.111... VMware.Sdk.vSphere
Script 8.0.111... VMware.Sdk.vSphere.Appliance {Invoke-GetItemHealthMessages, Invoke-GetHealthSettings, Invoke-UpdateHealthSettings, Invoke-CreateLocalAccounts...}
Script 8.0.111... VMware.Sdk.vSphere.Appliance.Access {Invoke-GetAccessConsolecli, Invoke-SetAccessConsolecli, Invoke-GetAccessDcui, Invoke-SetAccessDcui...}
Script 8.0.111... VMware.Sdk.vSphere.Appliance.Health {Invoke-GetHealthApplmgmt, Invoke-GetHealthDatabase, Invoke-GetHealthDatabaseStorage, Invoke-GetHealthLoad...}
Script 8.0.111... VMware.Sdk.vSphere.Appliance.Inf... {Invoke-ExportInfraprofileConfigs, Invoke-ImportInfraprofileConfigsAsync, Invoke-ListInfraprofileConfigs, Invoke-ValidateInfraprofileConfigsAsync...}
Script 8.0.111... VMware.Sdk.vSphere.Appliance.Loc... {Invoke-GetLocalAccountsGlobalPolicy, Invoke-SetLocalAccountsGlobalPolicy, Initialize-LocalAccountsPolicyInfo}
Script 8.0.111... VMware.Sdk.vSphere.Appliance.Log... {Invoke-GetLoggingForwarding, Invoke-SetLoggingForwarding, Invoke-TestLoggingForwarding, Initialize-LoggingForwardingConfig...}
Script 8.0.111... VMware.Sdk.vSphere.Appliance.Net... {Invoke-CreateNetworkingDnsDomains, Invoke-ListNetworkingDnsDomains, Invoke-SetNetworkingDnsDomains, Invoke-GetNetworkingDnsHostname...}
Script 8.0.111... VMware.Sdk.vSphere.Appliance.Rec... {Invoke-GetSystemNameArchive, Invoke-ListSystemNameArchives, Invoke-ValidateRecoveryBackup, Invoke-ListBackupJobDetails...}
Script 8.0.111... VMware.Sdk.vSphere.Appliance.Sup... Invoke-GetSupportBundleComponents
Script 8.0.111... VMware.Sdk.vSphere.Appliance.System {Invoke-GetSystemGlobalFips, Invoke-SetSystemGlobalFips, Invoke-ListSystemStorage, Invoke-ResizeExSystemStorage...}
Script 8.0.111... VMware.Sdk.vSphere.Appliance.Update {Invoke-InstallVersionPending, Invoke-ListUpdatePending, Invoke-PrecheckVersionPending, Invoke-StageAndInstallVersionPending...}
Script 8.0.111... VMware.Sdk.vSphere.Cis {Invoke-CreateSession, Invoke-DeleteSession, Invoke-GetSession, Invoke-CancelTask...}
Script 8.0.111... VMware.Sdk.vSphere.Cis.Tagging {Invoke-AddToUsedByCategoryId, Invoke-CreateCategory, Invoke-DeleteCategoryId, Invoke-GetCategoryId...}
Script 8.0.111... VMware.Sdk.vSphere.Content {Invoke-GetContentConfiguration, Invoke-UpdateContentConfiguration, Invoke-FindContentLibrary, Invoke-GetLibraryIdContent...}
Script 8.0.111... VMware.Sdk.vSphere.ContentLibrary {Invoke-GetLibraryItemVersionLibraryChanges, Invoke-ListLibraryItemContentChanges, Invoke-CancelDownloadSessionId, Invoke-CreateLibraryItemDownloadSession...}
Script 8.0.111... VMware.Sdk.vSphere.Esx.Hcl {Invoke-DownloadHclCompatibilityDataAsync, Invoke-GetHclCompatibilityDataStatus, Invoke-ListHostHclCompatibilityReleases, Invoke-CreateHostCompatibilityReportAsync...}
Script 8.0.111... VMware.Sdk.vSphere.Esx.Hosts {Invoke-ListHostSoftwareInstalledComponents, Invoke-GetSoftware, Initialize-HostsSoftwareHostCredentials}
Script 8.0.111... VMware.Sdk.vSphere.Esx.Settings {Invoke-DeleteClusterDraftSoftwareAddOn, Invoke-DeleteHostDraftSoftwareAddOn, Invoke-GetClusterDraftSoftwareAddOn, Invoke-GetClusterSoftwareAddOn...}
Script 8.0.111... VMware.Sdk.vSphere.VAPI.Metadata {Invoke-GetCliCommand, Invoke-GetCliCommandFingerprint, Invoke-ListMetadataCliCommand, Invoke-GetComponentIdAuthentication...}
Script 8.0.111... VMware.Sdk.vSphere.vCenter {Invoke-GetCluster, Invoke-ListCluster, Invoke-CreateDatacenter, Invoke-DeleteDatacenter...}
Script 8.0.111... VMware.Sdk.vSphere.vCenter.Authe... Invoke-CreateAuthenticationToken
Script 8.0.111... VMware.Sdk.vSphere.vCenter.Autho... {Invoke-GetAuthorizationPrivilegeChecksLatest, Invoke-ListAuthorizationPrivilegeChecks, Initialize-AuthorizationPrivilegeChecksFilterSpec, Initialize-AuthorizationPrivilegeChecksListRequestBody...}
Script 8.0.111... VMware.Sdk.vSphere.vCenter.CertM... {Invoke-GetCertificateManagementSigningCertificate, Invoke-RefreshSigningCertificate, Invoke-SetCertificateManagementSigningCertificate, Invoke-GetCertificateManagementTls...}
Script 8.0.111... VMware.Sdk.vSphere.vCenter.Consu... {Invoke-AddZoneAssociations, Invoke-GetZoneClusterAssociations, Invoke-RemoveZoneAssociations, Invoke-ListConsumptionDomainsZoneAssociationsCluster...}
Script 8.0.111... VMware.Sdk.vSphere.vCenter.Content {Invoke-CreateContentRegistriesHarbor, Invoke-DeleteRegistryRegistriesHarbor, Invoke-GetRegistryRegistriesHarbor, Invoke-ListContentRegistriesHarbor...}
Script 8.0.111... VMware.Sdk.vSphere.vCenter.Datas... Invoke-GetDatastoreDefaultPolicy
Script 8.0.111... VMware.Sdk.vSphere.vCenter.Deplo... {Invoke-CheckMigrateActiveDirectory, Invoke-CancelDeploymentHistory, Invoke-GetDeploymentHistory, Invoke-PauseDeploymentHistory...}
Script 8.0.111... VMware.Sdk.vSphere.vCenter.Guest {Invoke-CreateGuestCustomizationSpecs, Invoke-DeleteNameGuestCustomizationSpecs, Invoke-ExportNameCustomizationSpecs, Invoke-GetNameGuestCustomizationSpecs...}
Script 8.0.111... VMware.Sdk.vSphere.vCenter.HVC {Invoke-AddManagementAdministrators, Invoke-GetHvcManagementAdministrators, Invoke-RemoveManagementAdministrators, Invoke-SetHvcManagementAdministrators...}
Script 8.0.111... VMware.Sdk.vSphere.vCenter.Identity {Invoke-GetTenantBrokerAdminClient, Invoke-GetBrokerTenantsOperatorClient, Invoke-CreateIdentityProviders, Invoke-DeleteProviderIdentity...}
Script 8.0.111... VMware.Sdk.vSphere.vCenter.Inven... {Invoke-GetInventoryDatastore, Invoke-GetInventoryNetwork}
Script 8.0.111... VMware.Sdk.vSphere.vCenter.ISO {Invoke-MountIsoImage, Invoke-UnmountIsoImage, Initialize-IsoImageMountRequestBody, Initialize-IsoImageUnmountRequestBody}
Script 8.0.111... VMware.Sdk.vSphere.vCenter.LCM {Invoke-CreateLcmDiscoveryAssociatedProducts, Invoke-DeleteProductDiscoveryAssociatedProducts, Invoke-GetProductDiscoveryAssociatedProducts, Invoke-ListLcmDiscoveryAssociatedProducts...}
Script 8.0.111... VMware.Sdk.vSphere.vCenter.Names... {Invoke-ListNamespaceManagementSoftwareClusterAvailableVersions, Invoke-GetNamespaceManagementClusterCompatibilityV2, Invoke-ListNamespaceManagementClusterCompatibility, Invoke-DisableCluster...}
Script 8.0.111... VMware.Sdk.vSphere.vCenter.Names... {Invoke-CreateNamespaceDomainSubjectAccess, Invoke-DeleteNamespaceDomainSubjectAccess, Invoke-GetNamespaceDomainSubjectAccess, Invoke-SetNamespaceDomainSubjectAccess...}
Script 8.0.111... VMware.Sdk.vSphere.vCenter.OVF {Invoke-ListOvfExportFlag, Invoke-ListOvfImportFlag, Invoke-CreateOvfLibraryItem, Invoke-DeployOvfLibraryItemId...}
Script 8.0.111... VMware.Sdk.vSphere.vCenter.Services {Invoke-GetService, Invoke-GetServices, Invoke-RestartService, Invoke-StartService...}
Script 8.0.111... VMware.Sdk.vSphere.vCenter.Storage {Invoke-ListPoliciesEntitiesCompliance, Invoke-CheckCompatibilityPolicyPolicies, Invoke-ListStoragePolicies, Invoke-ListPoliciesComplianceVm...}
Script 8.0.111... VMware.Sdk.vSphere.vCenter.Syste... {Invoke-GetSystemConfigDeploymentType, Invoke-SetSystemConfigDeploymentType, Invoke-GetSystemConfigPscRegistration, Invoke-RepointSystemConfigPscRegistration...}
Script 8.0.111... VMware.Sdk.vSphere.vCenter.Tagging Invoke-ListAssociations
Script 8.0.111... VMware.Sdk.vSphere.vCenter.Topology {Invoke-GetNodeTopology, Invoke-ListTopologyNodes, Invoke-ListTopologyReplicationStatus}
Script 8.0.111... VMware.Sdk.vSphere.vCenter.Trust... {Invoke-CreateTrustedInfrastructureTrustAuthorityHostsAttestation, Invoke-GetHostTrustedInfrastructureAttestation, Invoke-DeleteClusterVersionBaseImagesAsync, Invoke-GetClusterBaseImagesAsync...}
Script 8.0.111... VMware.Sdk.vSphere.vCenter.VCHA {Invoke-GetClusterActive, Invoke-DeployVchaClusterAsync, Invoke-FailoverVchaClusterAsync, Invoke-GetVchaCluster...}
Script 8.0.111... VMware.Sdk.vSphere.vCenter.Vm {Invoke-GetVmHardwareBoot, Invoke-UpdateVmHardwareBoot, Invoke-ConnectVmCdrom, Invoke-CreateVmHardwareCdrom...}
Script 8.0.111... VMware.Sdk.vSphere.vCenter.VmTem... {Invoke-CheckInTemplateLibraryItemVmCheckOuts, Invoke-CheckOutTemplateLibraryItemCheckOuts, Invoke-DeleteTemplateLibraryItemVmVmTemplateCheckOuts, Invoke-GetTemplateLibraryItemVmVmTemplateCheckOuts...}
Script 8.0.111... VMware.Sdk.vSphere.vStats {Invoke-CreateStatsAcqSpecs, Invoke-DeleteIdStatsAcqSpecs, Invoke-GetIdStatsAcqSpecs, Invoke-ListStatsAcqSpecs...}
Script 8.0.111... VMware.Sdk.vSphereRuntime {New-vSphereServerConfiguration, Get-vSphereServerConfiguration, Set-vSphereServerConfiguration, Set-vSphereServerConfigurationApiKey...}
Script 8.1.0.2... VMware.Vim
Script 13.1.0.... VMware.VimAutomation.Cis.Core {Connect-CisServer, Disconnect-CisServer, Get-CisService}
Script 13.1.0.... VMware.VimAutomation.Cloud {Add-CIDatastore, Connect-CIServer, Disconnect-CIServer, Get-Catalog...}
Script 13.1.0.... VMware.VimAutomation.Common {Get-PowerCLIContext, Get-Task, New-OAuthSecurityContext, Stop-Task...}
Script 13.1.0.... VMware.VimAutomation.Core {Add-PassthroughDevice, Add-VirtualSwitchPhysicalNetworkAdapter, Add-VMHost, Add-VMHostNtpServer...}
Script 13.0.0.... VMware.VimAutomation.Hcx {Connect-HCXServer, Disconnect-HCXServer, Get-HCXAppliance, Get-HCXComputeProfile...}
Script 13.1.0.... VMware.VimAutomation.HorizonView {Connect-HVServer, Disconnect-HVServer}
Script 12.0.0.... VMware.VimAutomation.License Get-LicenseDataManager
Script 13.1.0.... VMware.VimAutomation.Nsxt {Connect-NsxtServer, Disconnect-NsxtServer, Get-NsxtGlobalManagerService, Get-NsxtPolicyService...}
Script 13.1.0.... VMware.VimAutomation.Sdk {Get-ErrorReport, Get-PSVersion, EnableParameterCompleters, Get-InstallPath}
Script 13.1.0.... VMware.VimAutomation.Security {Add-AttestationServiceInfo, Add-KeyProviderServiceInfo, Add-TrustAuthorityKeyProviderServer, Add-TrustAuthorityKeyProviderServerCertificate...}
Script 12.7.0.... VMware.VimAutomation.Srm {Connect-SrmServer, Disconnect-SrmServer}
Script 13.1.0.... VMware.VimAutomation.Storage {Add-EntityDefaultKeyProvider, Add-KeyManagementServer, Add-VsanFileServiceOvf, Add-VsanObjectToRepairQueue...}
Script 1.6.0.0 VMware.VimAutomation.StorageUtility Update-VmfsDatastore
Script 13.1.0.... VMware.VimAutomation.Vds {Add-VDSwitchPhysicalNetworkAdapter, Add-VDSwitchVMHost, Export-VDPortGroup, Export-VDSwitch...}
Script 13.0.0.... VMware.VimAutomation.Vmc {Add-VmcSddcHost, Connect-Vmc, Disconnect-Vmc, Get-AwsAccount...}
Script 13.1.0.... VMware.VimAutomation.vROps {Connect-OMServer, Disconnect-OMServer, Get-OMAlert, Get-OMAlertDefinition...}
Script 12.4.0.... VMware.VimAutomation.WorkloadMan... {Disable-WMCluster, Enable-WMCluster, Get-WMCluster, Get-WMNamespace...}
Script 12.7.0.... VMware.VumAutomation {Add-EntityBaseline, Copy-Patch, Get-Baseline, Get-Compliance...}
(2)方法 2
打开powershell,cd到解压的powercli文件夹下
cd C:\Users\yz\Desktop\VMware-PowerCLI-13.1.0-21624340
配置远程执行策略为允许。
PS C:\Users\yz\Desktop\VMware-PowerCLI-13.1.0-21624340> Set-ExecutionPolicy RemoteSigned
Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose
you to the security risks described in the about_Execution_Policies help topic at
https:/go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution policy?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): A
PS C:\Users\yz\Desktop\VMware-PowerCLI-13.1.0-21624340> Set-PowerCLIConfiguration -Scope AllUsers -ParticipateInCeip $false -InvalidCertificateAction Ignore
WARNING: Please consider joining the VMware Customer Experience Improvement Program, so you can help us make PowerCLI a
better product. You can join using the following command:
Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP $true
VMware's Customer Experience Improvement Program ("CEIP") provides VMware with information that enables VMware to
improve its products and services, to fix problems, and to advise you on how best to deploy and use our products. As
part of the CEIP, VMware collects technical information about your organization’s use of VMware products and services
on a regular basis in association with your organization’s VMware license key(s). This information does not
personally identify any individual.
For more details: type "help about_ceip" to see the related help article.
To disable this warning and set your preference use the following command and restart PowerShell:
Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP $true or $false.
Perform operation?
Performing operation 'Update VMware.PowerCLI configuration.'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): A
Scope ProxyPolicy DefaultVIServerMode InvalidCertificateAction DisplayDeprecationWarnings WebOperationTimeout
Seconds
----- ----------- ------------------- ------------------------ -------------------------- -------------------
Session UseSystemProxy Multiple Ignore True 300
User
AllUsers Ignore