Connecting an iSCSI initiator to an iSCSI target
You can use Windows PowerShell to establish a connection between an initiator and a target. As an example, start by using the Get-IscsiConnection cmdlet to display a list of active connections on the initiator computer:
PS C:\> Get-IscsiConnection
ConnectionIdentifier : fffffa80144a8020-1
To view information about the session for this connection, you can get the connection using the Get-IscsiConnection cmdlet and pipe the connection into the Get-IscsiSession cmdlet like this:
PS C:\> Get-IscsiConnection -ConnectionIdentifier "fffffa80144a8020-1" | `
TargetNodeAddress : iqn.1991-05.com.microsoft:host7-fabrikam-data-target
Now let’s establish a connection to a target. To do this, begin by using the Get-IscsiTarget cmdlet to display a list of available targets that have been discovered on the target portal:
PS C:\> Get-IscsiTarget | fl
IsConnected : False
NodeAddress : iqn.1991-05.com.microsoft:host7-fabrikam-db-target
IsConnected : True
NodeAddress : iqn.1991-05.com.microsoft:host7-fabrikam-data-target
You already established a connection with the target named fabrikam-data, so let’s try to establish a connection with target fabrikam-db instead. To do this, use the Connect-IscsiTarget cmdlet and specify the IQN of target fabrikam-db like this:
PS C:\> Connect-IscsiTarget -NodeAddress `
IsConnected : True
IsPersistent : False
The IsConnected property in the preceding command output indicates that your connection attempt succeeded, but the value of the IsPersistent property indicates that your connection won’t persist across reboots. To fix this, you can use the Register-IscsiSession cmdlet with the SessionIdentifier taken from the preceding command output:
PS C:\> Register-IscsiSession -SessionIdentifier "fffffa80144a8020-4000013700000003"
If you now view the value of the IsPersistent property for this session, you can see that the session has been configured to persist across reboots:
PS C:\> Get-IscsiSession -SessionIdentifier "fffffa80144a8020-4000013700000003" | `
IsPersistent : True
The above tip was excerpted from Mitch Tulloch's book Training Guide: Installing and Configuring Windows Server 2012 from Microsoft Press.
Mitch is a nine-time recipient of the Microsoft Most Valuable Professional (MVP) award and a widely recognized expert on Windows administration, deployment and virtualization. For more information see http://www.mtit.com.