How to null terminate object properties in Powershell

Summary:
I was working on a script, which I'll post on later, to insert IPMI/iLO/iDRAC configs into my ESXi hosts.  I would get an error the following error consistently no matter what I put into my IPMI object:

Exception calling "UpdateIpmi" with "1" argument(s): "A specified parameter was not correct. 
"
At line:50 char:2
+     $_this.UpdateIpmi($ipmiInfo)
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : VimException

The short answer, I had to 'null terminate' the properties in my IPMI object.  I don't know 'why' I have to do this, but the vSphere API docs state that this is a requirement.  Quite frankly, I had no idea what this meant.

Solution Example:
To null terminate an object's property, you can simply do like so:
$MyObject = "" | Select Usefulproperty
$MyObject.Usefulproperty =  ("Something" + $null)

Additional Notes:
I'll follow-up w/ a post of the script I put together to do this so that it makes more sense.

Comments

Popular posts from this blog

NSX-T: vCenter and NSX-T Inventory out of Sync (Hosts in vSphere not showing up in NSX-T)

MacOS: AnyConnect VPN client was unable to successfully verify the IP forwarding table modifications.

vCenter: Cluster Skip Quickstart Workflow via API