Get-View PodStorageDrsEntry.StorageDrsConfig.VmConfig with UpdateViewData()

This post was originally published on this site

Hi,

 

is it possible to use UpdateViewData() method with Get-View on the ViewType “StoragePod” to Update the data of PodStorageDrsEntry.StorageDrsConfig.VmConfig for the VM names without using another Get-View (Get-View -Id $_.Id -Property Name) calls? The extra Get-View calls cost us some valuable seconds which I would like to save and in almost all other places, UpdateViewData() also works fine. So I think I am missing something or doing something wrong.

 

Unfortunately I cannot get it to run with UpdateViewData(), f.e.:

 

$_.UpdateViewData("PodStorageDrsEntry.StorageDrsConfig.VmConfig.Vm.Name")
MhodInvocationExcption: Exception calling "UpdateViewData" with "1" argument(s): ""

 

Example Code:

 

$ViewProperties = “Name”,

“PodStorageDrsEntry.StorageDrsConfig.PodConfig”,

“PodStorageDrsEntry.StorageDrsConfig.VmConfig”

$ViewType = “StoragePod”

(Get-View ViewType $ViewType Property $ViewProperties).ForEach(

    {

        $_.UpdateViewData(“ChildEntity.Name”)

        [PSCustomObject][ordered]@{

            Name           = [string]$_.Name

            Datastores     = ($_.LinkedView.ChildEntity.Name) -join ‘, ‘

            DatastoreIds   = ($_.LinkedView.ChildEntity.MoRef) -join ‘, ‘

            DrsEnabledVms  = ((@($_.PodStorageDrsEntry.StorageDrsConfig.VmConfig).ForEach( { if ($_.Enabled -eq $true) { Get-View Id $_.Vm Property Name } })).Name) -join ‘, ‘

            DrsDisabledVms = ((@($_.PodStorageDrsEntry.StorageDrsConfig.VmConfig).ForEach( { if ($_.Enabled -eq $false -or $_.Behavior -match “manual”) { Get-View Id $_.Vm Property Name } })).Name) -join ‘, ‘

        }

    }

)

(I have the same problem for other Api Types (f.e. in ClusterComputeResource -> $_.ConfigurationEx.DrsVmConfig)

(Perhaps LucD or mattboren can help?)

 

Thanks in advance,

Eize

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.