12
21

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.

vSphere PowerCLIの使い方

Last updated at Posted at 2016-08-06

#目的
vSphere PowerCLIで仮想マシン情報取得

#ダウンロード・インストール
以下からダウンロード、インストールを実行
VMware vSphere - My Vmware : https://my.vmware.com/jp/group/vmware/details?downloadGroup=PCLI630R1&productId=491

#起動してみる
コマンドプロンプトが、PSのままで、PowerCLIとなっていない場合は、以下を入力し、再度PowerCLIを起動

PS C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> Set-ExecutionPolicy RemoteSigned

実行ポリシーの変更
実行ポリシーは、信頼されていないスクリプトからの保護に役立ちます。実行ポリシー
を変更すると、about_Execution_Policies のヘルプ トピック
(http://go.microsoft.com/fwlink/?LinkID=135170)
で説明されているセキュリティ上の危険にさらされる可能性があります。実行ポリシー
を変更しますか?
[Y] はい(Y)  [N] いいえ(N)  [S] 中断(S)  [?] ヘルプ (既定値は "Y"): Y
PS C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI>

これが起動画面
powercli_initial.png

#vCenterに接続

Power CLI C:¥> Connect-VIServer –Server <vCenterサーバ> –User <ログオンユーザー> –Password <パスワード>

#データストア情報取得
Get-DataStore

Power CLI C:¥> Get-DataStore

Name                               FreeSpaceGB      CapacityGB
----                               -----------      ----------
datastore-esx02                        180.132         551.000
datastore-esx01                         97.225         551.000
nfs                                     68.137          99.997

#仮想マシンリスト取得
Get-VM

Power CLI C:¥> Get-VM

Name                 PowerState Num CPUs MemoryGB       
----                 ---------- -------- --------       
Logical-Router-0     PoweredOn  1        0.500          
new_CentOS-TOK-test  PoweredOn  1        2.000          
NSX_Controller_3     PoweredOn  4        4.000          
vSphere Replicati... PoweredOn  2        4.000          
NSX l2vpn Edge       PoweredOn  2        1.000          
NSX_Controller_1     PoweredOn  4        4.000          
NSX_Controller_2     PoweredOn  4        4.000          
CentOS-TOK-test2     PoweredOn  1        2.000          
NSX Manager          PoweredOn  4        16.000         
CentOS-TOK-test      PoweredOn  1        2.000          
edge-9c3474e8-8a9... PoweredOn  1        0.500          
nsxedge-0            PoweredOn  2        1.000          
CentOS-L2VPN-Serv... PoweredOn  1        2.000          
Guest Introspecti... PoweredOn  2        1.000          
test-on-ULS          PoweredOn  2        8.000          
DB                   PoweredOff 2        4.000          
Web                  PoweredOff 2        4.000          
Guest Introspecti... PoweredOn  2        1.000          
SL-Web01             PoweredOff 1        4.000          
test2-on-ULS         PoweredOn  2        8.000          
vRzOpsMgr            PoweredOn  2        8.000          
vRzLogInsight        PoweredOn  2        4.000          
SRM                  PoweredOn  2        4.000          
Protected-VM-96      PoweredOff 1        4.000          
HKG-L2VPN-Server-NW  PoweredOff 1        4.000          
Protected-VM-95      PoweredOff 1        4.000          

#仮想マシンの詳細情報取得
Get-VM <仮想マシン名> | select *

Power CLI C:¥> Get-VM test-on-ULS | select *

Name                    : test-on-ULS
PowerState              : PoweredOn
Notes                   : 
Guest                   : test-on-ULS:Microsoft Windows Server 2008 R2 (64-bit)
NumCpu                  : 2
MemoryMB                : 8192
MemoryGB                : 8
VMHostId                : HostSystem-host-10
VMHost                  : ibmesx01.softlayer.local
VApp                    : 
FolderId                : Folder-group-v141
Folder                  : TEST
ResourcePoolId          : ResourcePool-resgroup-352
ResourcePool            : Resource
HARestartPriority       : Disabled
HAIsolationResponse     : AsSpecifiedByCluster
DrsAutomationLevel      : AsSpecifiedByCluster
VMSwapfilePolicy        : Inherit
VMResourceConfiguration : CpuShares:Normal/4000 MemShares:Normal/81920
Version                 : v11
PersistentId            : 525e0240-0e2e-c507-2ac5-35660fd63afb
GuestId                 : windows7Server64Guest
UsedSpaceGB             : 48.074093455448746681213378906
ProvisionedSpaceGB      : 58.182492405176162719726562500
DatastoreIdList         : {Datastore-datastore-11}
ExtensionData           : VMware.Vim.VirtualMachine
CustomFields            : {}
Id                      : VirtualMachine-vm-149
Uid                     : /VIServer=softlayer.local\xxxxx@xxxxx.softlayer.l
                          ocal:443/VirtualMachine=VirtualMachine-vm-149/
Client                  : VMware.VimAutomation.ViCore.Impl.V1.VimClient

#仮想マシンの詳細情報取得2
Get-VMguest <仮想マシン名> | select *

Power CLI C:¥> Get-VMguest test-on-ULS | select *

OSFullName       : Microsoft Windows Server 2008 R2 (64-bit)
IPAddress        : {10.xx.xx.xx}
State            : Running
Disks            : {Capacity:53579083776, FreeSpace:22005411840, Path:C:\}
HostName         : test1
Nics             : {Network adapter 1:dvportgroup-384}
ScreenDimensions : {Width=1349, Height=672}
VmId             : VirtualMachine-vm-149
VM               : test-on-ULS
VmUid            : /VIServer=softlayer.local\xxxxxx@xxxxxx.softlayer.local:44
                   3/VirtualMachine=VirtualMachine-vm-149/
VmName           : test-on-ULS
Uid              : /VIServer=softlayer.local\xxxxxx@xxxxxx.softlayer.local:44
                   3/VirtualMachine=VirtualMachine-vm-149/VMGuest=/
GuestId          : windows7Server64Guest
ToolsVersion     : 10.0.6
ExtensionData    : VMware.Vim.GuestInfo
Client           : VMware.VimAutomation.ViCore.Impl.V1.VimClient
GuestFamily      : windowsGuest

#参考
VMware vSphere 5.5 のPowerCLIのダウンロードとインストール方法 | puti se blog

VMwareデータストアの使用容量・使用状況をコマンドで取得する方法。PowerCLI | puti se blog

Get-VM・Get-VMguestで取得できる仮想マシン・ゲストOS情報とプロパティの一覧。VMware PowerCLI | puti se blog

12
21
0

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
12
21

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?