Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# vSAN Default Storage Policy Report Script.
#
# Created by: Go Watanabe / @gowatana
# Usage:
# PowerCLI> .\get_vsan_default_storage_policy.ps1 <vSAN Cluster Name>
# PowerCLI> .\get_vsan_default_storage_policy.ps1 vsan-cluster-03
# PowerCLI> .\get_vsan_default_storage_policy.ps1 vsan-cluster-03 |
# >> Out-File -Encoding utf8 -PSPath vsan-report.txt
$report_width = 100
$vsan_cluster_name = $args[0]
$test_vm_name = ("vsan-policy-check-vm-" + $vsan_cluster_name)
function report_table ($report_title, $report) {
"-" * $report_width
"# $report_title"
""
$report = $report | ft -AutoSize | Out-String
$report.Trim()
""
}
$vsan_cluster = Get-Cluster -Name $vsan_cluster_name | where {$_.VsanEnabled -eq $true}
if($vsan_cluster.Count -ne 1){
$vsan_cluster_name + " is not a vSAN Cluster."
exit
}
$vsan_cluster_info = $vsan_cluster | Get-VsanClusterConfiguration | select `
Cluster,
@{N="vSAN";E={$_.VsanEnabled}},
VsanDiskClaimMode,
@{N="SpaceEfficiency";E={$_.SpaceEfficiencyEnabled}},
@{N="StretchedCluster";E={$_.StretchedClusterEnabled}},
WitnessHost
$vsan_datastore = $vsan_cluster | Get-VMHost | select -First 1 | Get-Datastore | where {$_.Type -eq "vsan"}
$vsan_datastore_info = $vsan_datastore | select `
Name,
Type,
Datacenter,
ParentFolder
# Create check VM.
$vm = $vsan_cluster | Get-VMHost | Get-Random |
New-VM -StorageFormat Thin -DiskMB 10 -Name $test_vm_name -Datastore $vsan_datastore
# Get Default Storage Policy info.
$vsan_default_st_policy = ($vm | Get-SpbmEntityConfiguration).StoragePolicy
$vsan_default_st_policy_info = $vsan_default_st_policy |
select -ExpandProperty AnyOfRuleSets | % {
$RuleName = $_.Name
$_ | select -ExpandProperty AllOfRules | select `
Capability,
Value,
@{N="RuleName"; E={$RuleName}}
}
# Delete check VM.
$vm | Remove-VM -DeletePermanently -Confirm:$false
# Output report.
report_table "vSAN Cluster" $vsan_cluster_info
report_table "vSAN Datastore" $vsan_datastore_info
report_table "vSAN Dafault Storage Policy Name" $vsan_default_st_policy.Name
report_table "vSAN Dafault Storage Policy Capability Rules" $vsan_default_st_policy_info
@gowatana

This comment has been minimized.

Copy link
Owner Author

commented Feb 11, 2018

下記の投稿むけ。

PowerCLI で vSAN Datastore のデフォルト ストレージ ポリシーを確認してみる。
https://communities.vmware.com/people/gowatana/blog/2018/02/11/powercli-vsan-default-policy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.