BenLiebowitz
Expert
Expert

It worked! 

I modified one line as we're attempting to run this against only 1 host, and set the get-vm to a specific cluster. 

I changed the $esxcli= line to use a $vmhost variable which is set to a specific hostname.

$rdmHD = get-cluster "CLUSTER1" | Get-VM | Get-HardDisk -DiskType RawPhysical,RawVirtual

$vmhost = get-vmhost "VMHOST"

foreach($rdm in $rdmHD){

    $esxcli = Get-EsxCli -VMHost $vmhost

    $esxcli.storage.core.device.list($rdm.ScsiCanonicalName) |

    Select @{N="Time";E={"{0:g}" -f (Get-Date).TimeOfDay}},Device,IsPerenniallyReserved

    $esxcli.storage.core.device.setconfig($false,$rdm.ScsiCanonicalName,$true)

    $esxcli.storage.core.device.list($rdm.ScsiCanonicalName) |

    Select @{N="Time";E={"{0:g}" -f (Get-Date).TimeOfDay}},Device,IsPerenniallyReserved

Thanks Luc!

Ben Liebowitz, VCP vExpert 2015, 2016, & 2017 If you found my post helpful, please mark it as helpful or answered to award points.