PBeebe
Contributor
Contributor

Old PCLI script used to automate 6.5 fails to create vmkernel and TCP/IP stack config on 7.0 install

 

A powercli script I was using to add a standalone ESXi host to vCenter when running v6.5 apparently doesn't work when running it on an 7.0 install. I'm trying this using PCLI v12.2.

When trying to add the vmk2 interface I get this error:

A specified parameter was not correct: argument[3]
At C:\vmware\deployment\Deploy-C2.ps1:59 char:2
+     $esxcli.network.ip.interface.add($null,$null,"vmk2",$null,$MTU,"v ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], InvalidArgument
    + FullyQualifiedErrorId : VMware.VimAutomation.ViCore.Types.V1.ErrorHandling.InvalidArgument

The chunk of script that used to work is below. Is there a more elegant way to do what I'm trying to achieve?

# Create vMotion TCP/IP Stack and vmkernel
Write-host "Creating vmotion TCP/IP Stack and adding vMotion vmkernel." -ForegroundColor Yellow

$esxcli = Get-EsxCli -VMHost $VHost
$esxcli.network.ip.netstack.add($null,"vmotion") | Out-Null
	
New-VirtualSwitch -VMHost $VHost -Name "temp" | Out-Null
	
New-VirtualPortGroup -VirtualSwitch (Get-VirtualSwitch -VMHost $VHost -Name "temp") -Name "temp" -VLanId "999" | Out-Null
	
$esxcli.network.ip.interface.add($null,$null,"vmk2",$null,$MTU,"vmotion","temp") | Out-Null

Start-Sleep -Seconds 2
	
$esxcli.network.ip.interface.ipv4.set($null,"vmk2",$vMotionIP,$Netmask,$null,"static") | Out-Null

Start-Sleep -Seconds 2
	
$esxcli.network.ip.route.ipv4.add("10.9.99.1","vmotion","default") | Out-Null

Start-Sleep -Seconds 10
		
Set-VMHostNetworkAdapter -PortGroup (Get-VDPortgroup -Name ("vMotion_999").Replace("/","%2f") -VDSwitch $dvSwitch) -VirtualNic (Get-VMHostNetworkAdapter -Name "vmk2" -VMHost $VHost) -confirm:$false | Out-Null

Start-Sleep -Seconds 2

Get-VirtualSwitch -Name 'temp' -VMHost $VHost | Remove-VirtualSwitch -Confirm:$false | Out-Null

 

Also, is there a convenient method in PowerCLI to copy NFS4 mount points from another host so I can mount them on this host? The previous method I used was with NFS3 but with NFS4 I've got multiple IPs to the backend storage so the same command doesn't work.

 

Thanks in advance.

0 Kudos
2 Replies
LucD
Leadership
Leadership

I would advise to use the V2 version of Get-EsxCli, no more counting parameters and their position, just complete a hash table.
See  PowerCLI 6.3 R1: Get-ESXCLI Why the V2?


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

0 Kudos
PBeebe
Contributor
Contributor

Thanks for the suggestion.  After re-tooling the scripts using the V2 method I was able to get over the hump and make some progress.

0 Kudos