Use basic functions eg. Write-Host $oldIP to check what actually is going into those variables. 
I have a powershell script that I'm using to look through a CSV file to assign a static iDRAC IP based on serial number.   Here is a command that is working great! racadm -r $oldIP -u root -p calvin set iDRAC.IPv4.Gateway $gw the $oldIP and $gw are the variables that have been assigned values previously in my script. I can verify with 'get iDRAC.IPv4' and all is well with the gateway. I assign the $gw in the exact same way that I assign the $newIP variable. Here is the command that will not work with the PowerShell variable: racadm -r $oldIP -u root -p calvin set iDRAC.IPv4.Address $newIP Returns: "Error: RAC947: Invalid object value specified." If I use the exact same command (by hitting the up arrow to get the previous command) and replace $newIP with the actual IP, it works great...if I wanted to manual enter each IP....which I don't.   I can verify that $newIP is actually assigned the value I need by just calling it separately.  Looks good.  It 'SHOULD' work.  Especially if $gw works fine.   I've tried every which way from Wednesday to get this to work.  Rearranging things in the code.  Made sure that iDRAC.IPv4.DHCPEnable 0 and iDRAC.IPv4 Enable 1 are set.  Researching for hours trying to find an explanation or reason for the failure.  Can't find anything.   Can the iDRAC.IPv4.Address command not take anything except an IP address that is actually typed in?  Some sort of validation? Does anyone have any ideas as to why this isn't working? RACADM version 8.1.0 build 1518 (yeah...I looked into that too).
Using powershell variables in RACADM commands