LucD
Leadership
Leadership

To do this on all ESXi nodes in a cluster and for all LUNs used as RDM, you could do

$clusterName = 'cluster'

Get-Cluster -Name $clusterName -PipelineVariable cluster |

    Get-VM |

    Get-HardDisk -DiskType "RawPhysical", "RawVirtual" -PipelineVariable rdm |

    ForEach-Object -Process {

        Get-VMHost -Location $cluster -PipelineVariable esx |

            ForEach-Object -Process {

                $esxcli = Get-EsxCli -VMHost $esx -V2


                $naaid = $rdm.ScsiCanonicalName

                $esxcli.storage.core.device.setconfig.Invoke(@{device = $naaid; perenniallyreserved = $true })

            }

    }


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference