Is there a way to find out when the "Automation Level" of a VM is set to anything other than "Default (Fully Automated)"? See the 3rd VM in the screenshot as an example. I would like to add a check for this in a Daily Health Check script.
I didn't see a value for Automation Level when performing a Get-DatastoreCluster | Get-Member
Thanks!
Fred
Oops, misread your question obviously.
Try this
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 MyDSC
$dsc.PodStorageDrsEntry.StorageDrsConfig.VmConfig | where {$_.Enabled} | Select @{N="VM";E={(Get-View $_.VM).Name}},Enabled,IntraVmAffinity
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Did you check Script to report on virtual machine automation level in DRS
That property is in the VirtualMachine object returned by Get-VM
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I did see where you get the DRS Automation Level using Get-VM, but I am looking for the Storage DRS Automation Level for a VM in a Datastore Cluster. We are using Datastore Clusters and normally the Automation Level setting is "Default (Fully Automated)", but if someone happens to Manualy Storage vMotion a VM in the Datastore Cluster, it will set the Automation Level to "Disabled" for Storage DRS. We can get around the issue by putting it in our procedures to check this after a manual Storage vMotion, but I like to make sure that it gets checked to be safe. If there was a SDrsAutomationLevel property, that would work.
Thanks
Oops, misread your question obviously.
Try this
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 MyDSC
$dsc.PodStorageDrsEntry.StorageDrsConfig.VmConfig | where {$_.Enabled} | Select @{N="VM";E={(Get-View $_.VM).Name}},Enabled,IntraVmAffinity
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I really appreciate your Help on this! You got me on the right track with your script. If I change the following:
$dsc.PodStorageDrsEntry.StorageDrsConfig.VmConfig |
where {$_.Enabled} | Select @{N="VM";E={(Get-View $_.VM).Name}},Enabled,IntraVmAffinity
To This:
$dsc.PodStorageDrsEntry.StorageDrsConfig.VmConfig | where {$_.Enabled -match "False"} | Select @{N="VM";E={(Get-View $_.VM).Name}},Enabled,IntraVmAffinity
It lists the VMs with the Storage DRS Automation Level not Enabled, which is exactly what I want. I always seem to learn so much from your scripts.
Thanks Again!
Fred
Thanks for this script, it has helped me immensely.
Any ideas on how to change the storagedrs automation level of a VM once you have the list?
Since there are no cmdlets to configure SDRS in the current PowerCLI build, you will have to fall back on the SDK API.
In this case the ConfigureStorageDrsForPod_Task method will do the task.
In the StorageDrsConfigSpec object, that you pass to the method as one of the parameters, you can configure the SDRS behaviour for individual VMs.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks for the prompt response.
Will have to read up on it, still new to powershell and powercli :^ )
Let me know if you can create a working script for this, otherwise I'll see if I can throw together a couple of lines.
Perhaps it would be better to create a new thread for that question.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Anybody know if a cmdlet for this will appear in a future release?
I doubt that VMware will make the PowerCLI roadmap public.
But I'm sure that the new PM is following these threads and will take note of all requests.
The speed in which they will eventually be implemented is something else :smileygrin:
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference