VMware Cloud Community
sujeetkp
Contributor
Contributor

Unable to Set IPAddress of a Static Nic Mapping in Customization Spec

I am trying to set the IPAddress of an existing Nic Mapping in Customization Spec using below command, but it is throwing error.

Command

Get-OSCustomizationSpec ClientSpec | Get-OSCustomizationNicMapping | Set-OSCustomizationNicMapping -IpAddress 10.10.0.6

Existing NIC Mapping

C:\Users\administrator> Get-OSCustomizationSpec ClientSpec | Get-OSCustomizationNicMapping | select *

Dns                   : {192.168.50.90}

Wins                  : 

SpecId                : 718ebb47-31d3-4ba0-b11f-96c1af797cde

Spec                  : ClientSpec

SpecType              : NonPersistent

NetworkAdapterMac     : 

Position              : 1

IPMode                : UseStaticIP

IPAddress             : 10.10.0.5

SubnetMask            : 255.255.255.0

DefaultGateway        : 10.10.0.1

AlternateGateway      : 10.10.0.1

VCApplicationArgument : 

Id                    : /Local=/OSCustomizationNicMapping=OSCustomizationNicMappingImpl-ClientSpec-NonPersistent-1/

Uid                   : /Local=/OSCustomizationNicMapping=OSCustomizationNicMappingImpl-ClientSpec-NonPersistent-1/

ExtensionData         : VMware.Vim.CustomizationAdapterMapping

Client                : 

Version               : 1

 

Error:

Set-OSCustomizationNicMapping : 2/14/2019 2:45:03 PM    Set-OSCustomizationNicMapping        If the IpMode parameter is set to "UseDhcp" you must not specify the parameters that configure values loaded by the DHCP server.    

At line:1 char:70

+ Get-OSCustomizationSpec ClientSpec | Get-OSCustomizationNicMapping | Set-OSCusto ...

+                                                                      ~~~~~~~~~~~

    + CategoryInfo          : InvalidArgument: (:) [Set-OSCustomizationNicMapping], ViError

    + FullyQualifiedErrorId : Core_NicMappingCmdletBase_ValidateParameters_DhcpConflictingParameters,VMware.VimAutomation.ViCore.Cmdlets.Commands. 

   SetOSCustomizationNicMapping

C:\Users\administrator.SA> Get-OSCustomizationSpec ClientSpec | Get-OSCustomizationNicMapping | select *
 
 
Dns                   : {192.168.50.90}
Wins                  : 
SpecId                : 718ebb47-31d3-4ba0-b11f-96c1af797cde
Spec                  : ClientSpec
SpecType              : NonPersistent
NetworkAdapterMac     : 
Position              : 1
IPMode                : UseStaticIP
IPAddress             : 10.10.0.5
SubnetMask            : 255.255.255.0
DefaultGateway        : 10.10.0.1
AlternateGateway      : 10.10.0.1
VCApplicationArgument : 
Id                    : /Local=/OSCustomizationNicMapping=OSCustomizationNicMappingImpl-ClientSpec-NonPersistent-1/
Uid                   : /Local=/OSCustomizationNicMapping=OSCustomizationNicMappingImpl-ClientSpec-NonPersistent-1/
ExtensionData         : VMware.Vim.CustomizationAdapterMapping
Client                : 
Version               : 1
Reply
0 Kudos
1 Reply
LucD
Leadership
Leadership

I'm afraid that is a "feature" of that cmdlet, you wil have to specify all the parameters for a static IP.
The error message is not too clear I'm afraid (and Example 1 of the Help is not correct).
Feel free to open a SR to report this inconsistency

Get-OSCustomizationSpec MyOC |

   Get-OSCustomizationNicMapping |

   Set-OSCustomizationNicMapping -IpAddress 192.168.1.2 -IpMode UseStaticIP -SubnetMask 255.255.255.0 -Dns 192.168.1.2 -DefaultGateway 192.168.1.254


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos