vSphere PowerCLIでThinかThickを一覧取得する方法

#内容
どの仮想マシンのどのディスクがシンプロビジョニングでシックプロビジョニングなのか、わからなくなってしまった方のために、一覧取得する方法を書いておきます

#PowerCLIのダウンロード・インストール
こちらを参照ください。
<a href="http://qiita.com/khayama/items/3593e7e64109957788ca" >vSphere PowerCLIの使い方 - Qiita</a>

#SoftLayer上、ESXiのvCenterへの接続

```ps1:Connect-vCenter
Connect-VIServer –Server <vCenterのIPアドレス> –User <SSOユーザー> –Password <SSOパスワード>
```

#一つの仮想マシンに対してストレージフォーマットを確認してみる

```ps1:Get-StorageFormat
Get-VM Test-For-VMware | Get-HardDisk | select *

StorageFormat   : EagerZeroedThick
Persistence     : Persistent
DiskType        : Flat
Filename        : [datastore-esx01] Test-For-VMware/Test-For-VMware.vmdk
CapacityKB      : 5242880
CapacityGB      : 5
ParentId        : VirtualMachine-vm-152
Parent          : Test-For-VMware
Uid             : /VIServer=softlayer.local\administrator@10.xx.xx.xx:443/VirtualMachine=VirtualMachine-vm-152/HardDisk=2000/
ConnectionState :
ExtensionData   : VMware.Vim.VirtualDisk
Id              : VirtualMachine-vm-152/2000
Name            : Hard disk 1
Client          : VMware.VimAutomation.ViCore.Impl.V1.VimClient
```

#ストレージフォーマット一覧の取得

```ps1:Get-StorageFormatList
Get-VM | Get-HardDisk | select Parent,Name,StorageFormat,@{N="GB";E={[int]$_.CapacityGB}},Filename | ft -AutoSize

Parent                                              Name            StorageFormat  GB Filename
------                                              ----            -------------  -- --------
Test-For-VMware                                     Hard disk 1  EagerZeroedThick   5 [datastore-esx01] Test-For-VMware/Test-For-VMware.vmdk
nsxedge-0                                           Hard disk 1             Thick   0 [datastore-esx01] nsxedge-0/nsxedge-0.vmdk
edge-5865babd-f125-43b8-982e-491f3295d3ad-0-U-DLR01 Hard disk 1             Thick   0 [datastore-esx01] edge-5865babd-f125-43b8-982e-491f3295d3ad-0-U-DLR01/edge-5865babd-f125-43b8-982e-491f3295d3ad...
NSX_Controller_0dc8e634-7cee-49dd-8e33-36ae70ae810d Hard disk 1             Thick  20 [datastore-esx01] NSX_Controller_0dc8e634-7cee-49dd-8e33-36ae70ae810d/NSX_Controller_0dc8e634-7cee-49dd-8e33-36...
NSX_Controller_d70b2a1b-a4fd-4ddc-baf7-d7741a0683ee Hard disk 1             Thick  20 [datastore-esx01] NSX_Controller_d70b2a1b-a4fd-4ddc-baf7-d7741a0683ee/NSX_Controller_d70b2a1b-a4fd-4ddc-baf7-d7...
Guest Introspection (2)                             Hard disk 1             Thick   5 [datastore-esx01] Guest Introspection (2)/Guest Introspection (2)-000001.vmdk
CentOS-TOK-test                                     Hard disk 1              Thin  16 [datastore-esx01] CentOS-TOK-test/CentOS-TOK-test-thin.vmdk
NSX l2vpn Edge                                      Hard disk 1              Thin   0 [datastore-esx01] NSX l2vpn Edge/NSX l2vpn Edge.vmdk
NSX l2vpn Edge                                      Hard disk 2              Thin   0 [datastore-esx01] NSX l2vpn Edge/NSX l2vpn Edge_1.vmdk
NSX Manager                                         Hard disk 1              Thin  60 [datastore-esx01] NSX Manager/NSX Manager.vmdk
ibmvcsa                                             Hard disk 1              Thin  12 [datastore-esx01] ibmvcsa/ibmvcsa.vmdk
ibmvcsa                                             Hard disk 2  EagerZeroedThick   1 [datastore-esx01] ibmvcsa/ibmvcsa_1.vmdk
ibmvcsa                                             Hard disk 3              Thin  25 [datastore-esx01] ibmvcsa/ibmvcsa_2.vmdk
ibmvcsa                                             Hard disk 4              Thin  50 [datastore-esx01] ibmvcsa/ibmvcsa_3.vmdk
ibmvcsa                                             Hard disk 5              Thin  10 [datastore-esx01] ibmvcsa/ibmvcsa_4.vmdk
ibmvcsa                                             Hard disk 6              Thin  10 [datastore-esx01] ibmvcsa/ibmvcsa_5.vmdk
ibmvcsa                                             Hard disk 7              Thin   5 [datastore-esx01] ibmvcsa/ibmvcsa_6.vmdk
ibmvcsa                                             Hard disk 8              Thin  25 [datastore-esx01] ibmvcsa/ibmvcsa_7.vmdk
ibmvcsa                                             Hard disk 9              Thin   1 [datastore-esx01] ibmvcsa/ibmvcsa_8.vmdk
ibmvcsa                                             Hard disk 10             Thin  10 [datastore-esx01] ibmvcsa/ibmvcsa_9.vmdk
ibmvcsa                                             Hard disk 11             Thin  10 [datastore-esx01] ibmvcsa/ibmvcsa_10.vmdk
CentOS-L2VPN-Server-NW                              Hard disk 1              Thin  16 [datastore-esx01] CentOS-L2VPN-Server-NW/CentOS-L2VPN-Server-NW-thin.vmdk
NSX_Controller_7efe16ff-9a4b-447e-b423-01a2969716af Hard disk 1             Thick  20 [datastore-esx01] NSX_Controller_7efe16ff-9a4b-447e-b423-01a2969716af/NSX_Controller_7efe16ff-9a4b-447e-b423-01...
ibmpsc                                              Hard disk 1              Thin  12 [datastore-esx01] ibmpsc/ibmpsc.vmdk
ibmpsc                                              Hard disk 2  EagerZeroedThick   1 [datastore-esx01] ibmpsc/ibmpsc_1.vmdk
ibmpsc                                              Hard disk 3              Thin   5 [datastore-esx01] ibmpsc/ibmpsc_2.vmdk
ibmpsc                                              Hard disk 4              Thin   5 [datastore-esx01] ibmpsc/ibmpsc_3.vmdk
ibmpsc                                              Hard disk 5              Thin   5 [datastore-esx01] ibmpsc/ibmpsc_4.vmdk
ibmpsc                                              Hard disk 6              Thin  10 [datastore-esx01] ibmpsc/ibmpsc_5.vmdk
ibmpsc                                              Hard disk 7              Thin   0 [datastore-esx01] ibmpsc/ibmpsc_6.vmdk
ibmpsc                                              Hard disk 8              Thin   0 [datastore-esx01] ibmpsc/ibmpsc_7.vmdk
ibmpsc                                              Hard disk 9              Thin   0 [datastore-esx01] ibmpsc/ibmpsc_8.vmdk
ibmpsc                                              Hard disk 10             Thin   0 [datastore-esx01] ibmpsc/ibmpsc_9.vmdk
ibmpsc                                              Hard disk 11             Thin   0 [datastore-esx01] ibmpsc/ibmpsc_10.vmdk
CentOS-TOK-test2                                    Hard disk 1              Thin  16 [datastore-esx01] CentOS-TOK-test2/CentOS-TOK-test2-thin.vmdk
vSphere Replication Appliance                       Hard disk 1              Thin  16 [datastore-esx01] vSphere Replication Appliance/vSphere Replication Appliance.vmdk
vSphere Replication Appliance                       Hard disk 2              Thin   2 [datastore-esx01] vSphere Replication Appliance/vSphere Replication Appliance_1.vmdk
test-on-ULS                                         Hard disk 1              Thin  50 [datastore-esx01] test-on-ULS/test-on-ULS-thin.vmdk
vra-05                                              Hard disk 1              Thin 100 [datastore-esx02] vra-05/vra-05.vmdk
vra-05                                              Hard disk 2             Thick  20 [datastore-esx02] vra-05/disk1.vmdk
Web-tmpl                                            Hard disk 1              Thin 100 [datastore-esx02] Web-tmpl/Web-tmpl-000001.vmdk
SL-Web01                                            Hard disk 1              Thin 100 [datastore-esx02] SL-Web01_1/SL-Web01.vmdk
HKG-L2VPN-Server-NW                                 Hard disk 1              Thin  40 [datastore-esx02] HKG-L2VPN/HKG-L2VPN.vmdk
vRzLogInsight                                       Hard disk 1              Thin  20 [datastore-esx02] VMware vRealize Log Insight/VMware vRealize Log Insight.vmdk
vRzLogInsight                                       Hard disk 2              Thin 120 [datastore-esx02] VMware vRealize Log Insight/VMware vRealize Log Insight_1.vmdk
vRzLogInsight                                       Hard disk 3              Thin   0 [datastore-esx02] VMware vRealize Log Insight/VMware vRealize Log Insight_2.vmdk
Protected-VM-96                                     Hard disk 1              Thin  40 [datastore-esx02] Protected-VM-96/Protected-VM-96-thin.vmdk
vRzOpsMgr                                           Hard disk 1              Thin  20 [datastore-esx02] vCenter Operations Manager アプライアンス/vCenter Operations Manager アプライアンス.vmdk
vRzOpsMgr                                           Hard disk 2              Thin 250 [datastore-esx02] vCenter Operations Manager アプライアンス/vCenter Operations Manager アプライアンス_1.vmdk
vRzOpsMgr                                           Hard disk 3              Thin   4 [datastore-esx02] vCenter Operations Manager アプライアンス/vCenter Operations Manager アプライアンス_2.vmdk
SRM                                                 Hard disk 1              Thin  20 [datastore-esx02] SRM/SRM.vmdk
Centos68-x64-minimal                                Hard disk 1              Thin   3 [datastore-esx02] Centos68-x64-minimal/Centos68-x64-minimal.vmdk
VyOS-For-Internet                                   Hard disk 1              Thin   4 [datastore-esx02] VyOS-For-Internet_1/VyOS-For-Internet.vmdk
test2-on-ULS                                        Hard disk 1              Thin  50 [datastore-esx02] test2/test2.vmdk
Guest Introspection (1)                             Hard disk 1             Thick   5 [datastore-esx02] Guest Introspection (1)/Guest Introspection (1)-000001.vmdk
vRealize Automation                                 Hard disk 1              Thin  50 [datastore-esx02] vRealize Automation/vRealize Automation.vmdk
vRealize Automation                                 Hard disk 2              Thin  15 [datastore-esx02] vRealize Automation/vRealize Automation_1.vmdk
vRealize Automation                                 Hard disk 3              Thin  25 [datastore-esx02] vRealize Automation/vRealize Automation_2.vmdk
vRealize Automation                                 Hard disk 4              Thin  50 [datastore-esx02] vRealize Automation/vRealize Automation_3.vmdk
Protected-VM-95                                     Hard disk 1              Thin  40 [datastore-esx02] Protected-VM-95/Protected-VM-95-thin.vmdk
```

- ft -AutoSizeは列幅に入りきらない文字列を省略しないオプション
- $はパイプで渡されたオブジェクト
- $_は、Typically refers to the item inside a foreach loop
- @{}はハッシュテーブル(連想配列)
- NはName
- EはExpression

#今日の日付でCSVに出力しておく
##日付の設定

```ps1:Set-Date
$today = (Get-Date).ToString("yyyyMMdd")
```

##CSVに出力する

```ps1:Export-csv
Get-VM | Get-HardDisk | select Parent,Name,StorageFormat,@{N="GB";E={[int]$_.CapacityGB}},Filename | Export-csv $today"VMStorageFormat.csv" -NoTypeInformation
```

#参考
<a href="http://blog.livedoor.jp/morituri/archives/54105843.html" >morituriのブログ : powershellの連想配列（Hashtable）メモ</a>
<a href="https://msdn.microsoft.com/ja-jp/powershell/scripting/getting-started/cookbooks/using-format-commands-to-change-output-view" >Format コマンドを使用した出力ビューの変更</a>