As per
I'm using LucD's method, to extract a list of vm's that have vm's turned on
function Get-StoragePod{
<#
.SYNOPSIS Find a DatastoreCluster
.DESCRIPTION The function will return a StoragePod object.
This is the server-side object used by vSphere for a DatastoreCluster.
.NOTES Author: Luc Dekens
.PARAMETER Name The name of the DatastoreCluster
.EXAMPLE
PS> Get-StoragePod
.EXAMPLE
PS> Get-StoragePod -Name "SDC*"
#>
param(
[CmdletBinding()]
[parameter(Position = 0, ValueFromPipeline = $true)]
[string]$Name = "*" )
begin{
function Get-StoragePodInternal{
param(
[CmdletBinding()]
[parameter(Mandatory = $true,ValueFromPipeline = $true)]
[VMware.Vim.Folder]$Folder )
$Folder.ChildEntity | %{
if($_.Type -eq "StoragePod"){
Get-View -Id $_ }
elseif($_.Type -eq "Folder"){
Get-View -Id $_ | Get-StoragePodInternal
}
}
}
}
process{
Get-Folder -Name datastore | %{
Get-StoragePodInternal -Folder $_.ExtensionData
} | where {$_.Name -like $Name}
}
}
$dsc = Get-StoragePod -Name $datastorecluster
$vmlist = $dsc.PodStorageDrsEntry.StorageDrsConfig.VmConfig | where {$_.Enabled -notmatch "False"} | Select @{N="VM";E={(Get-View $_.VM).Name}},Enabled,IntraVmAffinity | where {$_.VM -like "*_replica"}
This successfully gets a list of vm's that have sdrs enabled that shouldnt.
I'm struggling with how to disable sdrs. I'm new to powershell
from what i can gather i need to update dsc.podstoragedrsentry.storagedrsconfig.vmconfig.enabled to False.
but i'm unsure how to do this, or could point me in the right direction?