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
- Enable software iSCSI on a host.
$vmhost = Get-VMHost ESXHost1
Get-VMHostStorage $myHost | Set-VMHostStorage -SoftwareIScsiEnabled $true
- Get the iSCSI Host Bus Adapter (HBA) that is on the host.
$iscsiHba = Get-VMHostHba -Type iScsi
- Add a new iSCSI target for dynamic discovery.
$iscsiHba | New-IScsiHbaTarget -Address 192.168.0.1 -Type Send
- Rescan the HBAs on the host.
Get-VMHostStorage $vmhost -RescanAllHba
- 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.
- Create a new host storage.
New-Datastore -Vmfs -VMHost $vmhost -Path $lunpath.LunPath -Name iSCSI