Highlighted
Contributor
Contributor

Configuring iSCSI NIC binding with PowerCLI

Hi,

Is it possible to configure the iSCSI initiator NIC binding with PowerCLI? Usually you would use the "esxcli swiscsi" command to bind the initiator to the required vmkernel ports but I can't find any reference to a way of achieving this through PowerCLI.

Thanks!

0 Kudos
4 Replies
Highlighted
Community Manager
Community Manager

The "esxcli" APIs are not exposed, you'll need to use vCLI's esxcli which can be called from a PowerCLI script if you have installed on a Windows system.

=========================================================================

William Lam

VMware vExpert 2009,2010

VMware scripts and resources at:

Twitter: @lamw

Getting Started with the vMA (tips/tricks)

Getting Started with the vSphere SDK for Perl

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Community

If you find this information useful, please award points for "correct" or "helpful".

Highlighted
Contributor
Contributor

Hi William,

How would you call the vCLI's esxcli command from a PowerCLI script?

0 Kudos
Highlighted
Community Manager
Community Manager

I'm not a Powershell guy ... will leave that to the guru's to answer but you should be able to just call the vCLI's esxcli on the same system that has PowerCLI installed, this is similar to SSHing into an ESX host using plink which you can probably do a search to find an example. You would just pass in the credentials to esxcli along with the commands to bind VMkernel interface to iSCSI adapter.

=========================================================================

William Lam

VMware vExpert 2009,2010

VMware scripts and resources at:

Twitter: @lamw

Getting Started with the vMA (tips/tricks)

Getting Started with the vSphere SDK for Perl

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Community

If you find this information useful, please award points for "correct" or "helpful".

0 Kudos
Highlighted
User Moderator
User Moderator

You can run a console command from PowerCLI using plink.exe:

$User = <account>
$Pswd = <password>
$Computer = <esx-hostname>
$plink = "<PuTTY-directory>\plink.exe"
$plinkoptions = " -v -batch -pw $Pswd"
$cmd1 = 'esxcli swiscsi'
$remoteCommand = '"' + $cmd1 + '"'
$command = $plink + " " + $plinkoptions + " " + $User + "@" + $computer + " " + $remoteCommand
Invoke-Expression -command $command

Most of this code is borrowed from LucD.

Regards, Robert

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos