'Why is this error ":OperationStopped: Optional.Value expects values of type" happening in powershell
I am trying to use VMware PowerCLI (installed on powershell running in MAC) to create a static route with next-hop address. I am getting this error when
I am using the below patch method to create this static route and i am getting this error (Optional.Value expects values of type) when running this command although i have correctly formed other parameters for this. Not sure why this is happening and any help would be much appreciated. thanks.
**PS /Users/r> $S3.patch('Router_Demo','10.118.11.37/32',$Rspec)**
OperationStopped: Optional.Value expects values of type 'System.Collections.Generic.List`1[[System.Management.Automation.PSObject, System.Management.Automation, Version=7.2.1.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]' but received value of type 'System.Management.Automation.PSObject'.
**PS /Users/r> $S3**
Name
----
com.vmware.nsx_policy.infra.tier_1s.static_routes
**PS /Users/r> $S3 | Get-Member**
TypeName: VMware.VimAutomation.Cis.Core.Impl.V1.CisServiceBase
Name MemberType Definition
---- ---------- ----------
delete CodeMethod void delete(string tier1_id, string route_id)
get CodeMethod com.vmware.nsx_policy.model.static_routes get(string tier1_id, string route_id)
list CodeMethod com.vmware.nsx_policy.model.static_routes_list_result list(string tier1_id, string? cursor, boolean? include_mark_for_delete_objects, string? included_fields, long? page_size, boolean? sort_ascending, string? sort_by)
**patch CodeMethod void patch(string tier1_id, string route_id, com.vmware.nsx_policy.model.static_routes static_routes)**
update CodeMethod com.vmware.nsx_policy.model.static_routes update(string tier1_id, string route_id, com.vmware.nsx_policy.model.static_routes static_routes)
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
Constants NoteProperty System.Management.Automation.PSCustomObject Constants=
Documentation NoteProperty string Documentation=
_help_cache NoteProperty Lazy[psobject] _help_cache=@{Documentation=; Constants=System.Collections.Generic.List`1[System.Management.Automation.PSObject]; patch=; get=; update=; list=; delete=}
Name Property string Name {get;}
Uid Property string Uid {get;}
Help ScriptProperty System.Object Help {get=$this._help_cache.Value;}
**PS /Users/r> $Rspec**
self : <Unset, [com.vmware.nsx_policy.model.self_resource_link]>
revision : <Unset, [long]>
description : <Unset, [string]>
display_name : Test-VM
id : <Unset, [string]>
resource_type : <Unset, [string]>
tags : <Unset, [List<com.vmware.nsx_policy.model.tag>]>
children : <Unset, [List<dynamic_structure>]>
enabled_on_secondary : <Unset, [boolean]>
network : 10.118.10.37/32
next_hops : @{admin_distance=1; ip_address=10.130.130.2; scope=none}
**PS /Users/r> $Nhopspec**
admin_distance ip_address scope
-------------- ---------- -----
1 10.130.130.2 none
Thanks
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
