http://pingforinfo.com/powercli-script-to-set-perennial-reservation-to-all-rdm-luns-in-a-cluster/
Please find the Powercli script for configuring Perennial reservation on all RDM luns in a ESXi Cluster. Please change the value for following variables before you execute the script.
$vcenter = “vCenter.vmtest.com”
$dCenter = “123456”
$cluster = “Production Hypervisor”
This is the flow of script execution.
-
Get the list of RDM LUNs from the cluster.
-
Check the current perennial reservation status of the RDM. If it’s TRUE, no changes will be applied.
-
If the status is FALSE, the perennial reservation will be set on the LUN.
-
Script will query the latest status and the status will be displayed.
The result, after executing the script, looks something like this.
Please see attached script.
# This script will set the parameter Perennially Reservations to True on RDM Luns in a cluster #$vcenter = #"vCenter Name " #$dCenter = #"Datacenter Name" #$cluster = #"Cluster Name"
$vcenter = "vCenter.vmtest.com" $dCenter = "123456" $cluster = "Production Hypervisor"
#-------------------------------------------------------------------------
# Do not modify bellow script #-------------------------------------------------------------------------
#Add-PSSnapIn VMware* -ErrorAction SilentlyContinue
$connected = Connect-VIServer -Server $vcenter | Out-Null
$clusterInfo = Get-Datacenter -Name $dCenter | get-cluster $cluster $vmHosts = $clusterInfo | get-vmhost | select -ExpandProperty Name $RDMNAAs = $clusterInfo | Get-VM | Get-HardDisk -DiskType "RawPhysical","RawVirtual" | Select -ExpandProperty ScsiCanonicalName -Unique
foreach ($vmhost in $vmHosts) { $myesxcli = Get-EsxCli -VMHost $vmhost
foreach ($naa in $RDMNAAs) {
$diskinfo = $myesxcli.storage.core.device.list("$naa") | Select -ExpandProperty IsPerenniallyReserved $vmhost + " " + $naa + " " + "IsPerenniallyReserved= " + $diskinfo if($diskinfo -eq "false") { write-host "Configuring Perennial Reservation for LUN $naa......." $myesxcli.storage.core.device.setconfig($false,$naa,$true) $diskinfo = $myesxcli.storage.core.device.list("$naa") | Select -ExpandProperty IsPerenniallyReserved $vmhost + " " + $naa + " " + "IsPerenniallyReserved= " + $diskinfo } write-host "----------------------------------------------------------------------------------------------" } }
Disconnect-VIServer $vcenter -confirm:$false | Out-Null
|
附件:http://down.51cto.com/data/2366671
本文转自学海无涯博客51CTO博客,原文链接http://blog.51cto.com/549687/1927058如需转载请自行联系原作者
520feng2007