Configure MSiSCSI - Part 2

Microsoft Platform Guide

Audience
Public
Source Type
Documentation

When configuring MSiSCSI Initiator Service using Windows PowerShell, there are several steps involved to gather information before creating the physical connectivity.

Note:

It is recommended to use Visual Studio Code or the PowerShell Integrated Scripting Environment (ISE) to run the below PowerShell functions and cmdlets. This allows you to view and interact with the results. These scripts can also be run directly in a Windows PowerShell session.

1. Open up a Windows PowerShell session as an Administrator and run the following to get all of the Host IP Addresses that are available for configuration.


PS C:\>$HostIPs = Get-WmiObject Win32_NetworkAdapterConfiguration -Namespace 'root\CIMv2' | Where-Object { $_.IPEnabled }
            foreach ($HostIP in $HostIPs) {
                New-Object PSObject -Property @{
                IPAddress = $HostIP.IPAddress[0]
                Subnet = $HostIP.IPSubnet[0]
                Adapter = $HostIP.Description
                }
            }

Subnet        IPAddress     Adapter                        
------        ---------     -------                        
255.255.255.0 10.21.201.17  Cisco VIC Ethernet Interface      <-- Network/Internet
255.255.255.0 10.21.201.215 Cisco VIC Ethernet Interface #2   <-- iSCSI
255.255.255.0 10.21.201.216 Cisco VIC Ethernet Interface #3   <-- iSCSI

2. Using the same Windows PowerShell session, run the following PowerShell to get all of the iSCSI Target information.


PS C:\>$IscsiInitTargetClass = Get-WmiObject -Namespace 'root\wmi' -Class MSiSCSIInitiator_TargetClass
        foreach ($IscsiInitTarget in $IscsiInitTargetClass) {
            foreach ($IscsiTargetPortal in $IscsiInitTarget.PortalGroups.Get(0).Portals) {
            New-Object PSObject -Property  @{
            IscsiTarget = $IscsiInitTarget.TargetName
            IscsiTargetAddress = $IscsiTargetPortal.Address
            IscsiTargetPort = $IscsiTargetPortal.Port
                    }
                }
            }
  
IscsiTargetAddress IscsiTarget                                             IscsiTargetPort                                 
------------------ -----------                                             ---------------                                 
10.21.201.59       iqn.2010-06.com.purestorage:flasharray.261911b733e8cc9d            3260 
10.21.201.61       iqn.2010-06.com.purestorage:flasharray.261911b733e8cc9d            3260 
10.21.201.60       iqn.2010-06.com.purestorage:flasharray.261911b733e8cc9d            3260 
10.21.201.62       iqn.2010-06.com.purestorage:flasharray.261911b733e8cc9d            3260 

3. Using the IP addresses supplied in the previous PowerShell results, run the following to set the IP addresses. create the Target Portals, and connect the NICs to the array.


# Define the variable IP addresses
# Windows server NIC iSCSI IPs
$nic2 = "10.21.201.215"
$nic3 = "10.21.201.216"
# Pure Array iSCSI port IPs
$target1 = "10.21.201.59"
$target2 = "10.21.201.60"
$target3 = "10.21.201.61"
$target4 = "10.21.201.62"

# Create the iSCSI Target portals
New-IscsiTargetPortal -InitiatorPortalAddress $nic2 -TargetPortalAddress $target1 -InitiatorInstanceName "ROOT\ISCSIPRT\0000_0"
New-IscsiTargetPortal -InitiatorPortalAddress $nic3 -TargetPortalAddress $target3 -InitiatorInstanceName "ROOT\ISCSIPRT\0000_0"

# Pause for portal creation completion
Start-sleep -seconds 2

$targetnames = Get-IscsiTarget
$targetname = $targetnames[0]


# Connect the targets 1-4 for NIC 2 and 1-4 for NIC 3
Connect-IscsiTarget -InitiatorPortalAddress $nic2 -TargetPortalAddress $target1 -IsMultipathEnabled $true -NodeAddress $targetname.NodeAddress -IsPersistent $true
Connect-IscsiTarget -InitiatorPortalAddress $nic2 -TargetPortalAddress $target2 -IsMultipathEnabled $true -NodeAddress $targetname.NodeAddress -IsPersistent $true
Connect-IscsiTarget -InitiatorPortalAddress $nic2 -TargetPortalAddress $target3 -IsMultipathEnabled $true -NodeAddress $targetname.NodeAddress -IsPersistent $true
Connect-IscsiTarget -InitiatorPortalAddress $nic2 -TargetPortalAddress $target4 -IsMultipathEnabled $true -NodeAddress $targetname.NodeAddress -IsPersistent $true
Connect-IscsiTarget -InitiatorPortalAddress $nic3 -TargetPortalAddress $target1 -IsMultipathEnabled $true -NodeAddress $targetname.NodeAddress -IsPersistent $true
Connect-IscsiTarget -InitiatorPortalAddress $nic3 -TargetPortalAddress $target2 -IsMultipathEnabled $true -NodeAddress $targetname.NodeAddress -IsPersistent $true
Connect-IscsiTarget -InitiatorPortalAddress $nic3 -TargetPortalAddress $target3 -IsMultipathEnabled $true -NodeAddress $targetname.NodeAddress -IsPersistent $true
Connect-IscsiTarget -InitiatorPortalAddress $nic3 -TargetPortalAddress $target4 -IsMultipathEnabled $true -NodeAddress $targetname.NodeAddress -IsPersistent $true

You should now see all ports connected in the array.