VMWareのPowerCLIをインストールしてみた

スポンサーリンク

はじめに

VMware ESXiを管理するためにPowerCLIをインストールして少し使ってみました。備忘録を兼ねて手順をまとめておきます。

インストール手順

Powershell Gallery でモジュールを検索します。

Find-Module -Name VMware.PowerCLI

Version    Name                                Repository           Description
-------    ----                                ----------           -----------
12.0.0.... VMware.PowerCLI                     PSGallery            This Windows PowerShell module contains VMware.P...

Powershell Gallery から名前を指定してモジュールをインストールします。

Install-Module -Name VMware.PowerCLI

インストールされたVMwareのモジュールを確認します。

Get-InstalledModule -Name vmware*

Version    Name                                Repository           Description                                                             
-------    ----                                ----------           -----------                                                             
12.0.0.... VMware.CloudServices                PSGallery            PowerCLI CloudServices sample module.                                   
7.0.0.1... VMware.DeployAutomation             PSGallery            This Windows PowerShell module contains PowerCLI Auto Deploy cmdlets.   
7.0.0.1... VMware.ImageBuilder                 PSGallery            This Windows PowerShell module contains PowerCLI ImageBuilder cmdlets.  
12.0.0.... VMware.PowerCLI                     PSGallery            This Windows PowerShell module contains VMware.PowerCLI                 
7.0.0.1... VMware.Vim                          PSGallery            This Windows PowerShell module contains PowerCLI Vim.                   
12.0.0.... VMware.VimAutomation.Cis.Core       PSGallery            This Windows PowerShell module contains PowerCLI Cloud Infrastructure...
12.0.0.... VMware.VimAutomation.Cloud          PSGallery            This Windows PowerShell module contains PowerCLI Cloud cmdlets.         
12.0.0.... VMware.VimAutomation.Common         PSGallery            This Windows PowerShell module contains functionality required by mul...
12.0.0.... VMware.VimAutomation.Core           PSGallery            This Windows PowerShell module contains Windows PowerShell cmdlets fo...
12.0.0.... VMware.VimAutomation.Hcx            PSGallery            This Windows PowerShell module contains PowerCLI HCX cmdlets.           
7.12.0.... VMware.VimAutomation.HorizonView    PSGallery            This Windows PowerShell module contains Connect/Disconnect cmdlets fo...
12.0.0.... VMware.VimAutomation.License        PSGallery            This Windows PowerShell module contains PowerCLI cmdlets for managing...
12.0.0.... VMware.VimAutomation.Nsxt           PSGallery            This Windows PowerShell module contains PowerCLI NSXT cmdlets.          
12.0.0.... VMware.VimAutomation.Sdk            PSGallery            This Windows PowerShell module contains PowerCLI Sdk.                   
12.0.0.... VMware.VimAutomation.Security       PSGallery            This Windows PowerShell module contains PowerCLI security management ...
11.5.0.... VMware.VimAutomation.Srm            PSGallery            This Windows PowerShell module contains PowerCLI SRM cmdlets.           
12.0.0.... VMware.VimAutomation.Storage        PSGallery            This Windows PowerShell module contains PowerCLI storage management c...
1.3.0.0    VMware.VimAutomation.StorageUtility PSGallery            This Windows PowerShell module contains utility scripts for storage.    
12.0.0.... VMware.VimAutomation.Vds            PSGallery            This Windows PowerShell module contains PowerCLI VDS cmdlets.           
12.0.0.... VMware.VimAutomation.Vmc            PSGallery            This Windows PowerShell module contains PowerCLI VMC cmdlets.           
12.0.0.... VMware.VimAutomation.vROps          PSGallery            This Windows PowerShell module contains PowerCLI vROps cmdlets.         
12.0.0.... VMware.VimAutomation.WorkloadMan... PSGallery            PowerShell commands for automation of workloads related functionality...
6.5.1.7... VMware.VumAutomation                PSGallery            This Windows PowerShell module contains PowerCLI VUM cmdlets.

PowerCLIのバージョンを確認します。

Get-PowerCLIVersion

PowerCLI Version
----------------
   VMware PowerCLI 12.0.0 build 15947286
---------------
Component Versions
---------------
   VMware Common PowerCLI Component 12.0 build 15939652
   VMware Cis Core PowerCLI Component PowerCLI Component 12.0 build 15939657
   VMware VimAutomation VICore Commands PowerCLI Component PowerCLI Component 12.0 build 15939655

vCenter/ESXiの接続

Connect-VIServer -Server IPアドレス -Force -User ユーザー名 -Password パスワード

Name                           Port  User
----                           ----  ----
IPアドレス                     443   root

-------------------------------------------------------------

#Windows認証させている場合は以下でも良い
$credential = Get-Credential
Connect-VIServer -Server IPアドレス -Credential $credential

仮想マシンの情報を取得

Get-VM

Name                 PowerState Num CPUs MemoryGB
----                 ---------- -------- --------
WindowsServer2016    PoweredOn  2        4.000
・・・
CentOS7              PoweredOff 1        2.000

仮想マシンのパワーオン/パワーオフ/リセット

#パワーオン(起動)
start-VM -vm windowsserver2016

#パワーオフ(停止)
Stop-VM -vm windowsserver2016 -Confirm:$false

#リセット
Restart-VM -VM Windowsserver2016 -Confirm:$false

仮想マシンの再起動/シャットダウン

#再起動
Restart-VMGuest -vm windowsserver2016

#シャットダウン
Shutdown-VMGuest -vm windowsserver2016

vCenter/ESXiの切断

Disconnect-VIServer -Server IPアドレス -Confirm:$false

参考サイト

VMware Knowledge Base
https://kb.vmware.com/s/article/2012964?lang=ja

コメント

タイトルとURLをコピーしました