2
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PowerCLIインストール vCenter接続

Last updated at Posted at 2018-03-08

#インストール
最新はPower Shell5.x以上を入れてからモジュール追加する(↓参考)
VMware PowerCLI Blog

モジュールの確認

インストール/アップデート

インストールされたモジュール確認

PS C:\> Find-Module -Name VMware.PowerCLI

Version    Name                                Type       Repository           Description                                         
-------    ----                                ----       ----------           -----------                                         
10.0.0.... VMware.PowerCLI                     Module     PSGallery            This Windows PowerShell module contains VMware.Po...

PS C:\> Install-Module -Name VMware.PowerCLI -Force #Updateの場合は-Forceをつける

PS C:\> Get-Module VMware* -ListAvailable #'6.5.4.7155375' から '10.0.0.7895300'にアップデートした後の表示


    Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     6.5.2.7... VMware.DeployAutomation             {Add-DeployRule, Add-ProxyServer, Add-ScriptBundle, Copy-D...
Binary     6.5.1.6... VMware.DeployAutomation             {Add-DeployRule, Add-ProxyServer, Add-ScriptBundle, Copy-D...
Script     6.5.2.7... VMware.ImageBuilder                 {Add-EsxSoftwareDepot, Add-EsxSoftwarePackage, Compare-Esx...
Binary     6.5.1.6... VMware.ImageBuilder                 {Add-EsxSoftwareDepot, Add-EsxSoftwarePackage, Compare-Esx...
Manifest   10.0.0.... VMware.PowerCLI
Manifest   6.5.4.7... VMware.PowerCLI
Script     10.0.0.... VMware.VimAutomation.Cis.Core       {Connect-CisServer, Disconnect-CisServer, Get-CisService}
Binary     6.5.4.6... VMware.VimAutomation.Cis.Core       {Connect-CisServer, Disconnect-CisServer, Get-CisService}
Script     10.0.0.... VMware.VimAutomation.Cloud          {Add-CIDatastore, Connect-CIServer, Disconnect-CIServer, G...
Binary     6.5.1.5... VMware.VimAutomation.Cloud          {Add-CIDatastore, Connect-CIServer, Disconnect-CIServer, G...
Script     10.0.0.... VMware.VimAutomation.Common
Manifest   6.5.4.6... VMware.VimAutomation.Common
Script     10.0.0.... VMware.VimAutomation.Core           {Add-PassthroughDevice, Add-VirtualSwitchPhysicalNetworkAd...
Binary     6.5.2.6... VMware.VimAutomation.Core           {Add-PassthroughDevice, Add-VirtualSwitchPhysicalNetworkAd...
Script     6.5.4.7... VMware.VimAutomation.HA             Get-DrmInfo
Binary     6.5.4.7... VMware.VimAutomation.HA             Get-DrmInfo
Script     7.1.0.7... VMware.VimAutomation.HorizonView    {Connect-HVServer, Disconnect-HVServer}
Binary     7.1.0.5... VMware.VimAutomation.HorizonView    {Connect-HVServer, Disconnect-HVServer}
Script     10.0.0.... VMware.VimAutomation.License        Get-LicenseDataManager
Binary     6.5.1.5... VMware.VimAutomation.License        Get-LicenseDataManager
Script     10.0.0.... VMware.VimAutomation.Nsxt           {Connect-NsxtServer, Disconnect-NsxtServer, Get-NsxtService}
Binary     2.0.0.6... VMware.VimAutomation.Nsxt           {Connect-NsxtServer, Disconnect-NsxtServer, Get-NsxtService}
Script     10.0.0.... VMware.VimAutomation.PCloud         {Connect-PIServer, Disconnect-PIServer, Get-PIComputeInsta...
Binary     6.5.1.5... VMware.VimAutomation.PCloud         {Connect-PIServer, Disconnect-PIServer, Get-PIComputeInsta...
Script     10.0.0.... VMware.VimAutomation.Sdk
Manifest   1.0.0.5... VMware.VimAutomation.Sdk            {Get-PSVersion, Get-InstallPath}
Script     10.0.0.... VMware.VimAutomation.Srm            {Connect-SrmServer, Disconnect-SrmServer}
Binary     6.5.1.5... VMware.VimAutomation.Srm            {Connect-SrmServer, Disconnect-SrmServer}
Script     10.0.0.... VMware.VimAutomation.Storage        {Add-KeyManagementServer, Copy-VDisk, Export-SpbmStoragePo...
Binary     6.5.4.7... VMware.VimAutomation.Storage        {Add-KeyManagementServer, Copy-VDisk, Export-SpbmStoragePo...
Script     1.2.0.0    VMware.VimAutomation.StorageUtility Update-VmfsDatastore
Script     1.1        VMware.VimAutomation.StorageUtility Update-VmfsDatastore
Script     10.0.0.... VMware.VimAutomation.Vds            {Add-VDSwitchPhysicalNetworkAdapter, Add-VDSwitchVMHost, E...
Binary     6.5.1.5... VMware.VimAutomation.Vds            {Add-VDSwitchPhysicalNetworkAdapter, Add-VDSwitchVMHost, E...
Script     10.0.0.... VMware.VimAutomation.Vmc            {Connect-Vmc, Disconnect-Vmc, Get-VmcService, Connect-VmcS...
Binary     6.5.4.7... VMware.VimAutomation.Vmc            {Connect-Vmc, Disconnect-Vmc, Get-VmcService, Connect-VmcS...
Script     10.0.0.... VMware.VimAutomation.vROps          {Connect-OMServer, Disconnect-OMServer, Get-OMAlert, Get-O...
Binary     6.5.1.5... VMware.VimAutomation.vROps          {Connect-OMServer, Disconnect-OMServer, Get-OMAlert, Get-O...
Script     6.5.1.7... VMware.VumAutomation                {Add-EntityBaseline, Copy-Patch, Get-Baseline, Get-Complia...
Binary     6.5.1.5... VMware.VumAutomation                {Add-EntityBaseline, Copy-Patch, Get-Baseline, Get-Complia...


    Directory: C:\Program Files\VMware\Infrastructure\vSphere PowerCLI\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Binary     6.0.0.0    VMware.VimAutomation.Cis.Core
Binary     6.3.0.0    VMware.VimAutomation.Cloud
Manifest   6.3.0.0    VMware.VimAutomation.Common
Manifest   6.3.0.0    VMware.VimAutomation.Core           HookGetViewAutoCompleter
Binary     6.0.0.0    VMware.VimAutomation.HA
Binary     1.0.0.0    VMware.VimAutomation.License
Binary     6.0.0.0    VMware.VimAutomation.PCloud
Manifest   6.3.0.0    VMware.VimAutomation.SDK
Binary     6.0.0.0    VMware.VimAutomation.Storage
Binary     6.3.0.0    VMware.VimAutomation.Vds
Binary     6.3.0.0    VMware.VimAutomation.vROps
Binary     6.0.0.0    VMware.VumAutomation

##Proxy認証あるときはFind-Moduleに以下を使用
プロンプト出るのでユーザー名とパスワード入れる

Find-Module -Name VMware.PowerCLI -Proxy "http://server:port" -ProxyCredential (Get-Credential)

インストールの際もいっしょ

Install-Module -Name VMware.PowerCLI -Proxy "http://server:port" -ProxyCredential (Get-Credential)

##指定バージョンダウンロード
Proxyすらない環境とかPowerShell v4で無理やり使う場合等

savesave-module -Name VMware.PowerCLI VMware.PowerCLI -Path <ダウンロード先フォルダ> -RequiredVersion <バージョン番号>

ダウンロードしたファイル(フォルダに分かれてる)を以下に保存
C:\Program Files\WindowsPowerShell\Modules

PowerShell v4の場合はさらに*<モジュール名>*\\*<バージョン>*になっている*<バージョン>*フォルダ内の全ファイルを*<モジュール名>*フォルダ直下に移動させる必要がある
めんどくさい

#PowerShell VMware Module読み込み
読み込み

Import-Module VMware.VimAutomation.Core

確認

Get-Module VMware* -ListAvailable

#PowerCLIConfigurationの設定
以下のような場合PowerCLIConfigurationの設定を行う
なお、管理者権限無いときは「-Scope Users」つける

  • SSL証明書エラーが表示された場合
  • Proxyエラーが表示された場合
  • 実行中にタイムアウトが頻繁に起こる場合
#SSL証明書エラー
Set-PowerCLIConfiguration -Scope User -InvalidCertificateAction Ignore -Confirm:$false

#Proxyなし(直接接続/社内Proxyとかを無視する時に使う)
Set-PowerCLIConfiguration -Scope User -ProxyPolicy NoProxy -Confirm:$false

#タイムアウト値設定(ovfファイルエクスポートとかログファイル出力の際にタイムアウトエラーになるのを防ぐ)
Set-PowerCLIConfiguration -Scope User -WebOperationTimeoutSeconds 36000 -Confirm:$false

#接続
パスワードを直接入力したくないので以下で接続
※Credential情報抜いて接続してもWindows認証出来ないと聞いてきてくれるけどね

$vc_credential = Get-Credential
Connect-VIServer -Server "Server Name/IP Address" -Credential $vc_credential

#切断

Disconnect-VIServer -Server "Server Name/IP Address" -Confirm:$false
2
9
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?