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

Prerequisites

Verify that you are connected to a vCenter Server system.

Procedure

  1. Enable software iSCSI on a host.
    $vmhost = Get-VMHost ESXHost1
    Get-VMHostStorage $myHost | Set-VMHostStorage -SoftwareIScsiEnabled $true
  2. Get the iSCSI Host Bus Adapter (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 $vmhost -RescanAllHba
  5. Get the path to the SCSI LUN.
    $lunPath = Get-ScsiLun -VMHost $vmhost -CanonicalName ($iscsiHba.Device + "*") | Get-ScsiLunPath
    You can provide 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 $vmhost -Path $lunpath.LunPath -Name iSCSI