Array Setup and Networking
1819814 Members
2711 Online
109607 Solutions
New Discussion юеВ

Automate Windows iSCSI Connections

 
aherbert23
Trusted Contributor

Automate Windows iSCSI Connections

This script will work on Windows Server 2003, 2008, 2008R2, and 2012 with the native software iSCSI initiator. Any Nimble volumes accessible to the server will be mapped with all possible paths.

NOTE!

By default PowerShell scrips are disabled from running. You must set the PowerShell ExecutionPolicy to from Restricted to at least AllSigned. Please see this MS KB for more information : Using the Set-ExecutionPolicy Cmdlet Also it may be necessary to run this script from a PowerShell session launched with Administrator privileges.

18 REPLIES 18
edayeh69
Valued Contributor

Re: Automate Windows iSCSI Connections

This script is great to use with customers/partners that bring up MPIO setup as a potential blocker to our solution. Great work Adam!

Nick_Dyer
Honored Contributor

Re: Automate Windows iSCSI Connections

Nice work Adam - it works every time.

Only question I have is if it would be possible to automate the failover policy to Least Queue Depth vs the Round Robin it defaults to?

A blog available on the web seems to have found a way to do this... Connecting MPIO iSCSI Targets via PowershellтАж and a bit of dirty VBscript.

Nick Dyer
twitter: @nick_dyer_
aherbert23
Trusted Contributor

Re: Automate Windows iSCSI Connections

Absolutely, it's very possible. I have an update that I'll post soon and that will be a part of it.

smurthy110
Occasional Contributor

Re: Automate Windows iSCSI Connections

Thanks for the Script. Does this script automatically detect the Initiators and Nimble Target and maps them or we manually need to key in the parameters?

Nick_Dyer
Honored Contributor

Re: Automate Windows iSCSI Connections

Hey Sathish,

The script will automatically detect the Nimble volumes presented and will map/MPIO them for you. Give it a go on a windows VM - works perfectly!

Nick Dyer
twitter: @nick_dyer_
Hakanl10
New Member

Re: Automate Windows iSCSI Connections

When using this script, you would first have to define allowed connections to the Nimble volume through the web interface, right?

Nick_Dyer
Honored Contributor

Re: Automate Windows iSCSI Connections

Hi Hakan,

If i'm reading your question right - yes you have to configure your access control list correctly in the Nimble GUI/CLI for your host before you run the script on said host.

Nick Dyer
twitter: @nick_dyer_
Hakanl10
New Member

Re: Automate Windows iSCSI Connections

That's exactly what I meant. Thanks

Not applicable

Re: Automate Windows iSCSI Connections

Adam,

I'm trying to run my script.  I ran the Set-ExecutionPolicy RemoteSigned and then i tried launching the NimbleMPIO script but get this.  Any suggestions?

mpio.png

aherbert23
Trusted Contributor

Re: Automate Windows iSCSI Connections

This could be one of two things.

  1. Try starting PowerShell as an administrator. You will need to right click on the PowerShell icon and select "Run as Administrator."
  2. If you are using a hardware dependent iSCSI card (eg Broadcom) and using it as the initiator instead of the Windows software iSCSI initiator. Use the normal network interfaces for IP connectivity instead of the hardware iSCSI initiator and it would fix this issue.
Not applicable

Re: Automate Windows iSCSI Connections

Just wanted to update the forum with what my issue was.   I just rebooted the host and it fixed the issue.

nschoonover110
New Member

Re: Automate Windows iSCSI Connections

I found a bug in that script. The LoadBalancePolicy should be set to 4 and not 2 as is used in their script. Here's the corrected script.

---

$MPIOPolicy = (тАЬNon-SelectedтАЭ,тАЭFailover OnlyтАЭ,тАЭRound RobinтАЭ,тАЭRound Robin with SubsetтАЭ,тАЭLeast Queue DepthтАЭ,тАЭWeighted PathsтАЭ,тАЭLeast BlocksтАЭ)

$Policies = get-wmiobject -namespace ROOT\WMI -class DSM_QueryLBPolicy_V2

foreach($Policy in $Policies){

$Instance = $Policy.InstanceName

$objShare = Get-WmiObject -Namespace ROOT\WMI -Class DSM_LB_Operations | where{$_.InstanceName -eq $Instance}

$InParams = $objShare.GetMethodParameters(тАЬDsmSetLoadBalancePolicyALUAтАЭ)

Write-Host Current Policy is $MPIOPolicy[$policy.LoadBalancePolicy.LoadBalancePolicy] for $policy.InstanceName$policy.LoadBalancePolicy.LoadBalancePolicy = 2

$InParams.LoadBalancePolicy = $Policy.LoadBalancePolicy

$Inparams1 = $InParams.LoadBalancePolicy

$Inparams1.LoadBalancePolicy = 4

$Inparams.LoadBalancePolicy = $Inparams1

$outparams = $objShare.DsmSetLoadBalancePolicy($inparams.LoadBalancePolicy)

If ($outparams.Status = 2){Write-Host Policy Set to $MPIOPolicy[$Inparams1.LoadBalancePolicy]}

}

rfenton4
Honored Contributor

Re: Automate Windows iSCSI Connections

Hey Adam,

Did the update with Least Queue Depth change ever get released ?

Thanks
Rich

jjackson72
New Member

Re: Automate Windows iSCSI Connections

Hey Adam,

I get the following message when I try to run in Windows 2003 R2. New to PowerShell so any help would do.

nimblempio error.png

jjackson72
New Member

Re: Automate Windows iSCSI Connections

Never mind. Installed PowerShell 2.0 and it ran successfully; however, it made double amount of persistent connection for each volume.

alex_goltz
Advisor

Re: Automate Windows iSCSI Connections

Hey Adam,

Is this script something I could use to do a daily VSS snapshot (clone and mount) for an additional SQL server that needs less resources and privileges?

Thanks,

Alex

HenriAZ
New Member

Re: Automate Windows iSCSI Connections

I am having a problem with this script on a Windows 2008R2 server. I have downloaded the script twice and unzipped it, but keep getting the same error about the hash of the file not matching the digital signature. I am running Powershell as Administrator. Is there a security problem with the NimbleMPIO.ps1 script available for download?

PS C:\Users\hprudhommeadm\Documents\NimbleMPIO.ps1> .\NimbleMPIO.ps1

File C:\Users\hprudhommeadm\Documents\NimbleMPIO.ps1\NimbleMPIO.ps1 cannot be loaded. The contents of file C:\Users\hprudhommeadm\Documents\NimbleMPIO.ps1\NimbleMPIO.ps1 may have been tampered because the hash of the file does not match the hash stored in the digital signature. The script will not execute on the system. Please see "get-help about_signing"

for more details..

At line:1 char:17

+ .\NimbleMPIO.ps1 <<<<

    + CategoryInfo          : NotSpecified: (:) [], PSSecurityException

    + FullyQualifiedErrorId : RuntimeException

Thanks,

Henri

B_Rajesh
Frequent Advisor

Re: Automate Windows iSCSI Connections

Hi Henri,

You may have to change the execution policy for PowerShell. Get the following help to get more information in order to decide what to select - "help about_Execution_Policies".

Try below PowerShell command:

Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned

 

Regards
Rajesh Balakrishnan
I am a HPE Employee