- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
LucD's script is valid.
The below script is Cluster based. So need to provide a cluster name and then it finds the all RDM disks attached to all VMs in that cluster. Then it makes the RDM devices perenerrally reserved on
the ESXi hosts.
$ClusterName = "Cluster Name"
# Create a connection object to all hosts in the Target Cluster
$TargetCluster = Get-Cluster -Name $ClusterName | Get-VMHost
# Find the ScsiCanonicalName for all RDM Disks attached to VMs in the Target Cluster
$RDMDisks = Get-VM | Get-HardDisk -DiskType "RawPhysical","RawVirtual" | Select ScsiCanonicalName
foreach ($rdm2 in $RDMDisks){
$rdm2
}
# Retrieve and EsxCli instance for each connection
foreach($RDMDisk in $RDMDisks) {
foreach($hst in $TargetCluster) {
# And for each RDM Disk
$esxcli=Get-EsxCli -VMHost $Hst
# Set the configuration to "PereniallyReserved".
# setconfig method: void setconfig(boolean detached, string device, boolean perenniallyreserved)
$esxcli.storage.core.device.setconfig($false, ($RDMDisk.ScsiCanonicalName), $false)
}
}
# Disconnect the connection objects created for the Target Cluster
Disconnect-VIServer * -Confirm:$false | Out-Null