Disable Storage DRS on a VM

This code will reconfigure your Storage DRS Cluster Settings for a single VM.

### Set your vars ###
$theVM = “MyVM”
$theDatastoreCluster = “MyStorageCluster”

###
$SRMan = Get-View StorageResourceManager
$DSCluster = Get-DatastoreCluster -Name $theDatastoreCluster
$spec = New-Object VMware.Vim.StorageDrsConfigSpec
$DSCluster.ExtensionData.PodStorageDrsEntry.StorageDrsConfig.VmConfig |
where {(Get-View $_.VM | Select -ExpandProperty Name) -like $theVM} | %{
$entry = New-Object VMware.Vim.StorageDrsVmConfigSpec
$entry.Operation = “edit”
$entry.Info = $_
$entry.Info.Enabled = $false
$spec.vmConfigSpec += $entry
}
$SRMan.ConfigureStorageDrsForPod($DSCluster.ExtensionData.MoRef,$spec,$true)