NetboxPS icon indicating copy to clipboard operation
NetboxPS copied to clipboard

Unset fields

Open tigpas opened this issue 5 months ago • 0 comments

Hi,

I whould like to unset fields.

Example: I created a new object

New-NetboxIPAMAddress -Address 192.0.2.0/24 -Status active

id                   : 1
url                  : https://192.168.16.135/api/ipam/ip-addresses/1/
display              : 192.0.2.0/24
family               : @{value=4; label=IPv4}
address              : 192.0.2.0/24
vrf                  :
tenant               :
status               : @{value=active; label=Active}
role                 :
assigned_object_type :
assigned_object_id   :
assigned_object      :
nat_inside           :
nat_outside          : {}
dns_name             :
description          :
comments             :
tags                 : {}
custom_fields        :
created              : 01/09/2024 17:20:01
last_updated         : 01/09/2024 17:20:01

I added a tenant to this object

set-NetboxIPAMAddress -id 1 -Tenant 1

id                   : 1
url                  : https://192.168.16.135/api/ipam/ip-addresses/1/
display              : 192.0.2.0/24
family               : @{value=4; label=IPv4}
address              : 192.0.2.0/24
vrf                  :
tenant               : @{id=1; url=https://192.168.16.135/api/tenancy/tenants/1/; display=test; name=test; slug=test;
                       description=}
status               : @{value=active; label=Active}
role                 :
assigned_object_type :
assigned_object_id   :
assigned_object      :
nat_inside           :
nat_outside          : {}
dns_name             :
description          :
comments             :
tags                 : {}
custom_fields        :
created              : 01/09/2024 17:20:01
last_updated         : 01/09/2024 17:21:26

Now, I whould like to remove the tenant.

set-NetboxIPAMAddress -id 1 -Tenant ""
Invoke-RestMethod:  {   "tenant": [     "Related object not found using the provided numeric ID: 0"   ] }
InvalidOperation: You cannot call a method on a null-valued expression.

set-NetboxIPAMAddress -id 1 -Tenant 0
Invoke-RestMethod:  {   "tenant": [     "Related object not found using the provided numeric ID: 0"   ] }
InvalidOperation: You cannot call a method on a null-valued expression.

set-NetboxIPAMAddress -id 1 -Tenant
Set-NetboxIPAMAddress: Missing an argument for parameter 'Tenant'. Specify a parameter of type 'System.UInt64' and try again.

set-NetboxIPAMAddress -id 1 -Tenant NULL
Set-NetboxIPAMAddress: Cannot process argument transformation on parameter 'Tenant'. Cannot convert value "NULL" to type "System.UInt64". Error: "The input string 'NULL' was not in a correct format."

set-NetboxIPAMAddress -id 1 -Tenant $null
Invoke-RestMethod:  {   "tenant": [     "Related object not found using the provided numeric ID: 0"   ] }
InvalidOperation: You cannot call a method on a null-valued expression.

set-NetboxIPAMAddress -id 1 -Tenant unset
Set-NetboxIPAMAddress: Cannot process argument transformation on parameter 'Tenant'. Cannot convert value "unset" to type "System.UInt64". Error: "The input string 'unset' was not in a correct format."

Have you an idea for a solution? Maybe a code example can help.

tigpas avatar Sep 01 '24 17:09 tigpas