vmware / PowerCLI-Example-Scripts

http://blogs.vmware.com/powercli
Other
753 stars 603 forks source link

object reference not set for setting IP Pool #433

Open dwchan69 opened 3 years ago

dwchan69 commented 3 years ago

I copy just the "Function Set-NSXTIPPool {}" portion of the code within in mine, as it seems pretty straight forward. When I try to execute the following,

Set-NSXTIPPool -display_name "Test Pool Name" -allocation_start "192.168.31.2" -allocation_end "192.168.31.100" -cidr "192.168.31.0/24" -dns_nameservers "192.168.30.2" -gateway_ip "192.168.31.1" -dns_suffix "tataoui.com" -Confirm:$false

here is the error I am getting.

Object reference not set to an instance of an object. At line:124 char:17

I walk through the code and not sure what else I am not setting prior or missing

dwchan69 commented 3 years ago

I pipe the $ip_pool variable out to a json prior to executing $NSXTIPPoolService.create($ip_pool)

I think I find the problem, but not sure why. The IP allocation range is not being set for some reason?

{ "revision": 0, "description": "Test Pool description", "display_name": "Test Pool Name", "id": {

       },
"resource_type":  "IpPool",
"tags":  [

         ],
"ip_release_delay":  {

                     },
"pool_usage":  {

               },
"subnets":  [
                {
                    "allocation_ranges":  "",
                    "cidr":  "192.168.31.0/24",
                    "dns_nameservers":  "192.168.30.2",
                    "dns_suffix":  "tataoui.com",
                    "gateway_ip":  "192.168.31.1"
                }
            ]

}