I am getting this error while deplying VM from excel, due to this error it fails in customization line.
WARNING: 'State' property is obsolete. Use 'ConnectionState' instead.
int_vlan26_10.7.26.x_24
WARNING: 'DomainAdminUsername' property is obsolete. Use 'DomainUsername'
instead.
Error in Customization line is
Set-OSCustomizationNicMapping : 8/10/2011 7:57:06 AM Set-OSCustomizationNicM
apping The parameter 'Dns' is invalid.
At C:\ps\ServerDeploy\VM_Deploy_V1_Win2003.ps1:87 char:137
+ Get-OSCustomizationSpec $_.customization | Get-OSCustomizationNicMapping | w
here { $_.Position -eq '1'} | Set-OSCustomizationNicMapping <<<< -IpMode UseSt
aticIP -IpAddress $_.ip1 -SubnetMask $_.subnet1 -DefaultGateway $_.Gateway1 -Dn
s $_.dns1,$_.dns2
+ CategoryInfo : InvalidArgument: (:) [Set-OSCustomizationNicMapp
ing], ViError
+ FullyQualifiedErrorId : Core_NicMappingCmdletBase_ValidateIpAddress_Inva
lidIP,VMware.VimAutomation.ViCore.Cmdlets.Commands.SetOSCustomizationNicMa
pping
I was using the same script before and it worked
Herewith i have attached the script & input file could some one assist me.
Is this statement in a code block after an Import-Csv ?
The $_ variable is not the line from the .csv file anymore when you reach the Set-OSCustomizationNicMapping cmdlet.
You can do it like this
foreach($line in (Import-Csv "C:\myinput.csv" -UseCulture)){
...
Get-OSCustomizationSpec $line.customization | Get-OSCustomizationNicMapping | where { $_.Position -eq '1'} | `
Set-OSCustomizationNicMapping -IpMode UseStaticIP -IpAddress $line.ip1 -SubnetMask $line.subnet1 `
-DefaultGateway $line.Gateway1 -Dns $line.Dns0,$line.Dns1
...
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
if we use $_.(after import-CSV) it won't get input values? instead of that i need to use $line.DNS
I have given import-csv c:\filename
Henceforth did i need to change input as foreach($line in (Import-Csv "C:\myinput.csv" -UseCulture)){ } OR i need to add this line additionally
Please suggest and i will execute this tomorrow.
When you do a
Import-Csv "C:\MyFile.Csv" -UseCulture | %{
$_
}
the $_ variable inside the code block will indeed contain the line that comes from the .csv file.
But the line
Get-OSCustomizationSpec $line.customization | Get-OSCustomizationNicMapping | where { $_.Position -eq '1'} | `
Set-OSCustomizationNicMapping -IpMode UseStaticIP -IpAddress $line.ip1 -SubnetMask $line.subnet1 `
-DefaultGateway $line.Gateway1 -Dns $line.Dns0,$line.Dns1
is another pipeline construct (between the different cmdlets in there).
In that pipeline construct the $_ variable will contain the object that is passed through the pipeline from the previous cmdlet.
In this case the $_ variable will contain the object coming from the Get-OSCustomizationNicMapping cmdlet that passed through the where-clause.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Still I am getting same error..
In customzation i have entered only few data not the DNS, DNS value needs to be passed from Excel file but its throwing error.
Could you oplease assist me
Set-OSCustomizationNicMapping : 8/12/2011 4:03:03 AM Set-OSCustomizationNicM
apping The parameter 'Dns' is invalid.
At C:\ps\ServerDeploy\VM_Deploy_V1_Win2003.ps1:90 char:140
+ Get-OSCustomizationSpec $line.customization | Get-OSCustomizationNicMapping
| where { $_.Position -eq '1'} | Set-OSCustomizationNicMapping <<<< -IpMode Us
eStaticIP -IpAddress $line.ip1 -SubnetMask $line.subnet1 -DefaultGateway $line.
Gateway1 -Dns $line.dns1,$line.dns2
+ CategoryInfo : InvalidArgument: (:) [Set-OSCustomizationNicMapp
ing], ViError
+ FullyQualifiedErrorId : Core_NicMappingCmdletBase_ValidateIpAddress_Inva
lidIP,VMware.VimAutomation.ViCore.Cmdlets.Commands.SetOSCustomizationNicMa
pping
Can you show part of the CSV file that is used for input ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Please find the input CSV fieldname
ServerName | ClusterName | Template | Datastore | Customization | ip1 | subnet1 | gateway1 | dns1 | dns2 | inputportgrp1 | inputportgrp2 | ip2 | subnet2 | memory | cpu | OUInput | DNSServer |
Winappd002 | DAYPAA | W2k3X86 | DAY_CS2 | W2K3R2_X86_STD | 10.7.26.195 | 255.255.255.0 | 10.7.26.1 | 10.9.14.14. | 10.9.14.16 | 10.7.26. | 10.7.83. | 10.7.83.50 | 255.255.255.0 | 2048 | 1 | LEB | ABC |
The dns1 entry has an extra dot at the end.
Can you open the CSV file with a text editor and show the content ?
There should be a spearator between the columns.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
ServerName,ClusterName,Template,Datastore,Customization,ip1,subnet1,gateway1,dns1,dns2,inputportgrp1,inputportgrp2,ip2,subnet2,memory,cpu,OUInput,DNSServer
daywinappd003,DAYESXPAA,Win2003Stdx86_sp2_50,NADAYCX4_1624_Win_2317_2,W2K3R2_X86_STD,10.7.26.195,255.255.255.0,10.7.26.1,10.9.14.14.,10.9.14.16,10.7.26.,10.7.83.,10.7.83.50,255.255.255.0,2048,1,Lebenon,NMRFLIDC01
Can you remove the extra dot at the end of 10.9.14.14. and try again ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Extremely Apologies, its my mistake.. I could have revalidated it...
Thanks, its deploying...