For a host, you can enable iSCSI, add iSCSI targets, and create new host storages.

Connect to a vSphere server.

1

Enable software iSCSI on a host.

$host = Get-VMHost ESXHost1
Get-VMHostStorage $myHost | Set-VMHostStorage -SoftwareIScsiEnabled $true
2

Get the iSCSI HBA that is on the host.

$iscsiHba = Get-VMHostHba -Type iScsi
3

Add a new iSCSI target for dynamic discovery.

$iscsiHba | New-IScsiHbaTarget -Address 192.168.0.1 -Type Send
4

Rescan the HBAs on the host.

Get-VMHostStorage $host -RescanAllHba
5

Get the path to the SCSI LUN.

$lunPath = Get-ScsiLun -VMHost $host -CanonicalName ($iscsiHba.Device + "*") | Get-ScsiLunPath

You can specify the LUN path by using its canonical name beginning with the device name of the iSCSI HBA.

6

Create a new host storage.

New-Datastore -Vmfs -VMHost $host -Path $lunpath.LunPath -Name iSCSI