Skip to main content
Pure Technical Services

Setup iSCSI on Windows Server with Windows PowerShell

Currently viewing public documentation. Please login to access the full scope of documentation.

Overview

The Pure Storage FlashArray supports the Internet Small Computer Systems Interface an Internet Protocol (IP) based storage networking standard for linking data storage facilities. Using iSCSI provides access to the Pure Storage FlashArray by issuing SCSI commands over the TCP/IP network. 

The screenshot below illustrates two disconnected Ethernet Ports in a Pure Storage FlashArray. These ports will be configured on the FlashArray and Windows Server for connectivity.

The following steps will configure the MSiSCSI Initiator Service to connect to the Pure Storage FlashArray iSCSI ports using Windows PowerShell.

The Windows PowerShell script examples provided below are based on the following lab configuration. Adjustments will need to be made to the scripts to match your environment. 

Lab Configuration

  • Windows Server has (3) Network Interface Cards (NICs)
    • NIC1 - Host connectivity to the Network/Internet
    • NIC2 - iSCSI
    • NIC3 - iSCSI
  • Pure FlashArray has (4) iSCSI target interfaces

Setup Using Windows PowerShell

This section walks through the steps for configuring MSiSCSI using the iscsicli command line tool provided in Windows Server and Pure Storage PowerShell SDK.

If you have not installed the Pure Storage PowerShell SDK please see Install PowerShell SDK using Microsoft Installer Package (MSI) or Install PowerShell SDK using PowerShell Gallery before proceeding.

This article shows the commands using the PowerShell SDK version 1 and version 2. You may use either version or both to accomplish the solution.

Configure MSiSCSI (Part 1)

Using the iscsicli.exe command line tool.

1. Open up a Windows PowerShell session as an Administrator and run the following PowerShell to ensure the MSiSCSI Initiator Service is Running.

PS C:\> Get-Service -Name MSiSCSI

Status   Name               DisplayName
------   ----               -----------
Stopped  MSiSCSI            Microsoft iSCSI Initiator Service

PS C:\> Set-Service -Name MSiSCSI -StartupType Automatic
PS C:\> Start-Service -Name MSiSCSI
WARNING: Waiting for service 'Microsoft iSCSI Initiator Service (MSiSCSI)' to start...
PS C:\> Get-Service -Name MSiSCSI

Status   Name               DisplayName
------   ----               -----------
Running  MSiSCSI            Microsoft iSCSI Initiator Service

Configure FlashArray Host and Volume

  1. Open up a Windows PowerShell session as an Administrator.
  2. Retrieve the NodeAddress from the Windows Server host. The NodeAddress for the example server, Server01, is iqn.1991-05.com.microsoft:server01. In the below example the NodeAddress is being stored in a PowerShell variable, $ServerIQN, which will be used in future steps.

PS C:\> $ServerIQN = (Get-InitiatorPort | Where-Object { $_.NodeAddress -like '*iqn*' }).NodeAddress

PS C:\> $ServerIQN
iqn.1991-05.com.microsoft:server01

2. Connect to the FlashArray and configure a host and the host port. In this step a new host is created, Server01, and the IQN is assigned using the $ServerIQN variable that was populated in Step 1.

Using PowerShell SDK version 1.x

# Using the PowerShell SDK version 1.x
PS C:\> $FlashArray = New-PfaArray -EndPoint 10.0.0.1 -Credentials (Get-Credential) -IgnoreCertificateError

cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:

PS C:\> New-PfaHost -Array $FlashArray -Name 'Server01' -IqnList $ServerIQN

iqn                                  wwn name 
---                                  --- ---- 
{iqn.1991-05.com.microsoft:server01} {}  Server01

Using PowerShell SDK version 2.x 

# Using the PowerShell SDK version 2.x
PS C:\> $FlashArray = Connect-Pfa2Array -EndPoint 10.0.0.1 -Credential (Get-Credential) -IgnoreCertificateError

cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:

PS C:\> New-Pfa2Host -Array $FlashArray -Name 'Server01' -Iqns $ServerIQN
Name             : Server01
Chap             : class Chap {
                     HostPassword:
                     HostUser:
                     TargetPassword:
                     TargetUser:
                   }

ConnectionCount  : 0
HostGroup        : class ReferenceNoId {
                     Name:
                   }

Iqns             : {iqn.1991-05.com.microsoft:sn1-r720-e04-05.ale.local}
Nqns             : {}
Personality      :
PortConnectivity : class HostPortConnectivity {
                     Details: None
                     Status: critical
                   }

PreferredArrays  : {}
Space            : class Space {
                     DataReduction: 1
                     Shared:
                     Snapshots: 0
                     System:
                     ThinProvisioning: 1
                     TotalPhysical: 0
                     TotalProvisioned: 0
                     TotalReduction: 1
                     Unique: 0
                     Virtual: 0
                   }

Wwns             : {}
IsLocal          : True

3. Create a volume on the FlashArray and connect to the host, Server01, from Step 2.

Using PowerShell SDK version 1.x

# Using the PowerShell SDK version 1.x
PS C:\> New-PfaVolume -Array $FlashArray -VolumeName 'iSCSI-TestVolume' -Unit G -Size 500

source  : 
serial  : 45084F3508BF461400011AE3
created : 2017-06-07T02:49:32Z
name    : iSCSI-TestVolume
size    : 536870912000

PS C:\> New-PfaHostVolumeConnection -Array $FlashArray -VolumeName 'iSCSI-TestVolume' -HostName 'Server01'

vol  : iSCSI-TestVolume
name : Server01
lun  : 1

Using PowerShell SDK version 2.x 

# Using the PowerShell SDK version 2.x
PS C:\> New-Pfa2Volume -Array $FlashArray -Name 'iSCSI-TestVolume' -Provisioned 536870912000
Id                      : 40af952b-b047-94d2-9bb9-ca8cd9560a64
Name                    : iSCSI-TestVolume
ConnectionCount         : 0

PS C:\> New-Pfa2Connection -Array $FlashArray -VolumeNames 'iSCSI-TestVolume' -HostNames 'Server01'
Host             : class ReferenceNoId {
                     Name: Server01
                   }

HostGroup        : class ReferenceNoId {
                     Name:
                   }

Lun              : 1
ProtocolEndpoint : class Reference {
                     Id:
                     Name:
                   }

Volume           : class FixedReference {
                     Id: 40af952b-b047-94d2-9bb9-ca8cd9560a64
                     Name: iSCSI-TestVolume
                   }

The completed view from the FlashArray management interface shows the host, volume and host ports set.

 

Configure MSiSCSI - Part 2

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

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 $target.NodeAddress -IsPersistent $true
Connect-IscsiTarget -InitiatorPortalAddress $nic2 -TargetPortalAddress $target2 -IsMultipathEnabled $true -NodeAddress $target.NodeAddress -IsPersistent $true
Connect-IscsiTarget -InitiatorPortalAddress $nic2 -TargetPortalAddress $target3 -IsMultipathEnabled $true -NodeAddress $target.NodeAddress -IsPersistent $true
Connect-IscsiTarget -InitiatorPortalAddress $nic2 -TargetPortalAddress $target4 -IsMultipathEnabled $true -NodeAddress $target.NodeAddress -IsPersistent $true
Connect-IscsiTarget -InitiatorPortalAddress $nic3 -TargetPortalAddress $target1 -IsMultipathEnabled $true -NodeAddress $target.NodeAddress -IsPersistent $true
Connect-IscsiTarget -InitiatorPortalAddress $nic3 -TargetPortalAddress $target2 -IsMultipathEnabled $true -NodeAddress $target.NodeAddress -IsPersistent $true
Connect-IscsiTarget -InitiatorPortalAddress $nic3 -TargetPortalAddress $target3 -IsMultipathEnabled $true -NodeAddress $target.NodeAddress -IsPersistent $true
Connect-IscsiTarget -InitiatorPortalAddress $nic3 -TargetPortalAddress $target4 -IsMultipathEnabled $true -NodeAddress $target.NodeAddress -IsPersistent $true

You should now see all ports connected in the array.

Test Connectivity

To test the connectivity from the host to the FlashArray, you can use DISKSPD for a basic plumbing test. DISKSPD is a storage load generator and performance test tool from the Microsoft Windows, Windows Server and Cloud Server Infrastructure Engineering teams.

DISKSPD is not recommended for performance testing. The use case mentioned here is to simply test the connectivity to the FlashArray.

Running diskspd with the below example command line will generate I/O to evaluate connectivity. The <DRIVE_LETTER> in the command line should be the drive letter of the newly connected volume. To learn how to setup a drive letter for a newly connected volume see Working with Volumes on a Windows Server 2012, 2012 R2 or 2016 Host.

 C:\>Diskspd.exe -b8K -d3600 -h -L -o16 -t16 -r -w30 -c400M <DRIVE_LETTER>:\io.dat

The results of the plumbing test should generate similar output as below.

The host can also be monitored using the Purity CLI with the pureuser account with the below command. 

pureuser@myarray-ct0:~# purehost monitor --balance
Name      Time                     Initiator WWN  Initiator IQN                       Target       Target WWN  Failover  I/O Count  I/O Relative to Max
Server01  2020-08-26 03:11:43 PDT  -              iqn.1991-05.com.microsoft:server01  (primary)    -           -         500187     99%
                                                  iqn.1991-05.com.microsoft:server01  (secondary)              -         506741     100%