PowerCLI-Example-Scripts
PowerCLI-Example-Scripts copied to clipboard
Desktop.Desktop_Update can't update Datastore settings
trafficstars
Describe the bug
I tried to update Datastore setting using Desktop_Update. What's wrong with my version?
Exception on call "Desktop_Update" with "2" arguments: "Failed to load type "VMware.Hv.String" from assembly "VMware.Hvi, Version=8.4.0.709, Culture=neutral, PublicKeyToken=null"."
string:1 symbol:2
+ $ViewAPI.Desktop.Desktop_Update($DesktopId,$MapEntryDesktopVirtualCenterStorageSettings)
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : TypeLoadException
Reproduction steps
PS C:\Windows\system32> $DesktopVirtualCenterDatastoreSettings = @()
>> ForEach ($DatastoreName in $DatastoreNames)
>> {
>> $DatastoreId1 = ($ViewAPI.Datastore.Datastore_ListDatastoresByHostOrCluster($HostOrClusterId) | Where-Object {$_.DatastoreData.Name -eq $DatastoreName}).Id
>> $DesktopVirtualCenterDatastoreSettingsTemp = New-Object VMware.Hv.DesktopVirtualCenterDatastoreSettings -Property @{datastore=$DatastoreId1;sdrsCluster=$SdrsCluster;storageOvercommit=$StorageOvercommit}
>> $DesktopVirtualCenterDatastoreSettings += $DesktopVirtualCenterDatastoreSettingsTemp
>> }
>>
>> $MapEntryDesktopVirtualCenterStorageSettings1 = New-Object VMware.Hv.MapEntry -Property @{
>> Key='automatedDesktopData.virtualCenterProvisioningSettings.virtualCenterStorageSettings.datastores';Value=$DesktopVirtualCenterDatastoreSettings
>> }
>> $MapEntryDesktopVirtualCenterStorageSettings = @($MapEntryDesktopVirtualCenterStorageSettings1)
PS C:\Windows\system32> $MapEntryDesktopVirtualCenterStorageSettings
Key Value
--- -----
automatedDesktopData.virtualCenterProvisioningSettings.virtualCenterStorageSettings.datastores {VMware.Hv.DesktopVirtualCenterDatastoreSettings}
PS C:\Windows\system32> $MapEntryDesktopVirtualCenterStorageSettings.Value
Datastore SdrsCluster StorageOvercommit
--------- ----------- -----------------
VMware.Hv.DatastoreId False UNBOUNDED
PS C:\Windows\system32> $MapEntryDesktopVirtualCenterStorageSettings | gm
TypeName: VMware.Hv.MapEntry
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
Key Property string Key {get;set;}
Value Property System.Object Value {get;set;}
PS C:\Windows\system32> $DesktopId
Id
--
Desktop/ZTE3ZTVjMjctZDg4Yy00NmNiLWIyN2UtNWRhYjFlYTI5NGE0/aDgyLXRzdA
PS C:\Windows\system32> $ViewAPI.Desktop.Desktop_Update($DesktopId,$MapEntryDesktopVirtualCenterStorageSettings)
Exception on call "Desktop_Update" with "2" arguments: "Failed to load type "VMware.Hv.String" from assembly "VMware.Hvi, Version=8.4.0.709, Culture=neutral, PublicKeyToken=null"."
string:1 symbol:2
+ $ViewAPI.Desktop.Desktop_Update($DesktopId,$MapEntryDesktopVirtualCenterStorageSettings)
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : TypeLoadException
Expected behavior
Metod succesfully update Datastore settings
Additional context
Horizon Connection Server 8.6.0 build - 20099816 PowerCLI 12.7