VMware Cloud Community
Foyman1973
Enthusiast
Enthusiast
Jump to solution

PowerCLI ESXCLI iSCSI Port Binding V2

So I have found a bunch of examples, and also made a working script using, Get-ESXCLI -V1.  I have NOT been able to make work, or find any examples of working code for Get-ESXCLI -V2 where iSCSI port binding is concerned.  Can anyone help me out here?

When I do this is works, but obviously this is a deprecated use:

$esxCLI = Get-EsxCli -VMHost $vmhost

$esxCLI.iscsi.networkportal.add($hba, $false, $vmkPort)

I know I must be missing something here when I attempt to use -V2:

$esxCLI = Get-EsxCli -VMHost $vmhost -V2

$esxCLI.iscsi.networkportal.method.add(@{nic=$vmkPort;adapater=$hba;force=$false})

also tried:

$esxCLI.iscsi.networkportal.method.add(nic=$vmkPort, adapater=$hba, force=$false})

and:

$cliArgs = $esxcli.iscsi.networkportal.add.CreateArgs()

$cliArgs.nic = "vmk3"

$cliArgs.adapter = "vmhba33"

$esxcli.iscsi.networkportal.method.add($cliArgs)

also tried calling args this way using above $cliArgs hashtable:

$b=$esxcli.TypeManager.QueryTypeInfo("vim.EsxCLI.iscsi.networkportal")

$b.InvokeOperation("add", $cliArgs)


What am I missing here?

1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You need to call the Invoke method, like this

$cArgs = $esxCLI.iscsi.networkportal.add.CreateArgs()

$cArgs.nic =  'vmk3'

$cArgs.adapter = 'vmhba33'

$esxCLI.iscsi.networkportal.add.Invoke($cArgs)


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

View solution in original post

2 Replies
LucD
Leadership
Leadership
Jump to solution

You need to call the Invoke method, like this

$cArgs = $esxCLI.iscsi.networkportal.add.CreateArgs()

$cArgs.nic =  'vmk3'

$cArgs.adapter = 'vmhba33'

$esxCLI.iscsi.networkportal.add.Invoke($cArgs)


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

Foyman1973
Enthusiast
Enthusiast
Jump to solution

Yes! That was exactly it, thank you LucD!

0 Kudos