Fetching contributors…
Cannot retrieve contributors at this time
50 lines (42 sloc) 2.11 KB
.NOTES Product/Feature: vCenter Server/SDRS
.NOTES Author: Vikas Shitole
.NOTES Reference:
.NOTES Description: Re-enable SDRS on VMs where SDRS was disabled when particular datastore was selected for VMDK/VM placement. Tested on vSphere 6.0.
.NOTES Please add the vCenter server IP/credetails as per your environment
Write-host "Connecting to vCenter server.."
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false -DisplayDeprecationWarnings:$false -Scope User
Connect-VIServer -Server -User administrator@vsphere.local -Password Admin!23
$pod=Get-View -ViewType 'StoragePod' -filter @{"Name”=”DatastoreCluster”}
$report = @()
if($pod -eq $null){
Write-Host "SDRS POD not found on vCenter"
if($vmOverrides -eq $null){
Write-Host "There is NO any VM which overrides SDRS cluster level configuration"
foreach ($vmOverride in $vmOverrides) {
$row = '' | select VMName
$vmMo=Get-View $vmOverride.Vm
if($vmOverride.Enabled -eq $false){
$spec = New-Object VMware.Vim.StorageDrsConfigSpec
$spec.vmConfigSpec = New-Object VMware.Vim.StorageDrsVmConfigSpec[] (1)
$spec.vmConfigSpec[0] = New-Object VMware.Vim.StorageDrsVmConfigSpec
$spec.vmConfigSpec[0].operation = 'add'
$spec.vmConfigSpec[0].info = New-Object VMware.Vim.StorageDrsVmConfigInfo
$_this = Get-View -Id 'StorageResourceManager-StorageResourceManager'
$_this.ConfigureStorageDrsForPod_Task($pod_Mor, $spec, $true)
Write-Host "SDRS is re-enabled on this VM :" $vmMo.Name
$row.VMName =$vmMo.Name
$report += $row
Write-Host "SDRS was already enabled on VM :" $vmMo.Name
$report | Export-Csv -Path "D:VMOverride.csv" #Please change the CSV file location as per your environment