<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Re: Automatically mount most recent snapshot and connect to target. in Array Performance and Data Protection</title>
    <link>https://community.hpe.com/t5/array-performance-and-data/automatically-mount-most-recent-snapshot-and-connect-to-target/m-p/6981772#M50</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Two more items:&amp;nbsp; First, a heartfelt thank you to Chris Aylott for putting together above code!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Second, I forgot to add a couple of statements that would remove the "Unrestricted" access to the new volume and then add the initiator group of the server to which you're connecting the new volume:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;plink %array-name% vol --removeacl clone-%volume%&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;plink %array-name% vol --addacl clone-%volume% --initiatorgrp &lt;/STRONG&gt;&lt;EM&gt;&lt;STRONG&gt;initiatorgroup&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 21 Feb 2014 14:31:20 GMT</pubDate>
    <dc:creator>azagajewski27</dc:creator>
    <dc:date>2014-02-21T14:31:20Z</dc:date>
    <item>
      <title>Automatically Mount Most Recent Snapshot and Connect to Target</title>
      <link>https://community.hpe.com/t5/array-performance-and-data/automatically-mount-most-recent-snapshot-and-connect-to-target/m-p/6981770#M48</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it's useful to someone. Uses batch scripting, it's simple, working and tested.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Applications:&lt;/STRONG&gt; Clone and mount most recent snapshot...&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;for development environment, scheduled it to mount the most recent snap at a DR environment so that devs would be working of the most recent data.&lt;/LI&gt;&lt;LI&gt;for backup&lt;/LI&gt;&lt;LI&gt;TODO - for backup and disable cache to prevent cache churn.&lt;/LI&gt;&lt;LI&gt;TODO - clone all recent snapshots for a volume collection and mount on ESX to simulate DR test without affecting replication.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;or simply use it to quickly clone the most recent snapshot for a volume&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Behaviour:&lt;/STRONG&gt;,&lt;/P&gt;&lt;P&gt;BATCH - Finds most recent snapshot for the volume you specify, clones it (sets it online), fetches the new iqn which can then be passed into a powershell script to either connect the cloned snapshot volume to ESX or a Windows box. Uses text files to filter the results.&lt;/P&gt;&lt;P&gt;POWERSHELL - Connects only the new volume target IQN and sets &lt;SPAN style="text-decoration: underline;"&gt;any&lt;/SPAN&gt; offline disk online. From testing it will retain any drive letter previously associated. !! Make sure you limit your volumes by intiator groups for security, as is best practice. !!&lt;/P&gt;&lt;P&gt;&amp;gt; can be run without executing anything to ensure you return the expected results.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Environment&lt;/STRONG&gt;:&lt;/P&gt;&lt;P&gt;It's a batch script which executes a powershell script. Tested on MS2012 (will work on 2008 however the the ps1 will have to be changed) with array versions 1.4.x and 2.0.x. Run this script from the server you want to mount the volume onto.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Useful references:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;For ps scripts using the iscsi cmdlets &lt;A href="http://www.vinithmenon.com/2012/11/new-iscsi-cmdlets-in-powershell-v3-part.html" title="http://www.vinithmenon.com/2012/11/new-iscsi-cmdlets-in-powershell-v3-part.html"&gt;Windows PowerShell&amp;nbsp; PS &amp;gt;_: New iSCSI cmdlets in PowerShell V3 Part - 1&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H2&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;Disclaimer:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/H2&gt;&lt;P&gt;Test it yourself use at your own peril ... etc etc. Read the comments.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Usage&lt;/STRONG&gt;:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Create a password-less connection to the array by generating a SSH key between the server and array.&lt;/LI&gt;&lt;/OL&gt;&lt;OL&gt;&lt;OL&gt;&lt;LI&gt;Install plink, puttyGEN and putty into c:\folder - &lt;A href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html" title="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html"&gt;PuTTY Download Page&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;Run puttyGen selecting &lt;STRONG&gt;1024 bits&lt;/STRONG&gt;, see screenshot&lt;/LI&gt;&lt;LI&gt;Save the key, selecting no to any passwords.&lt;/LI&gt;&lt;LI&gt;Copy the key &lt;STRONG&gt;exactly&lt;/STRONG&gt; as shown below.&lt;/LI&gt;&lt;/OL&gt;&lt;/OL&gt;&lt;P&gt;&lt;IMG __jive_id="1418" alt="generate-ssh.jpg" class="jive-image" src="https://community.hpe.com/legacyfs/online/1418_generate-ssh.jpg" /&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5. Connect to the array via putty using the login admin and your GUI password.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6. sshkey --add &amp;lt;name&amp;gt; --type rsa --key &amp;lt;paste the ssh key from previous step&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7. Open putty again prefix the array ip address with admin@ set the auth to SSH and point it at the key you saved in step 3, save the session with the name of your array.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;gt; You can now run commands on the array via plink directly from the machine.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;IMG __jive_id="1419" alt="putty-auth.jpg" class="jive-image" src="https://community.hpe.com/legacyfs/online/1419_putty-auth.jpg" /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;2. Open powershell as administrator run Set-ExecutionPolicy Unrestricted &amp;gt; Read what this means to you! &lt;A href="http://technet.microsoft.com/en-us/library/ee176961.aspx" title="http://technet.microsoft.com/en-us/library/ee176961.aspx"&gt;Using the Set-ExecutionPolicy Cmdlet&lt;/A&gt;&lt;/P&gt;&lt;P&gt;3. Save the code below into c:\folder and rename i.e. recent-snapshot.bat save the powershell script as connect-target.ps1&lt;/P&gt;&lt;P&gt;4. Change the modifications in the script, add the session name of putty from step 1.7 above to the array-name=XXXXX&lt;/P&gt;&lt;P&gt;5. Execute - on first run comment out the sections where the snapshot is actually cloned to ensure you get the expected results.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; name.bat VOLUME-NAME&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; i.e. C:\folder\recent-snapshot AA-SQL01-DB01&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Batch file&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_13999981521384902 jive_text_macro" jivemacro_uid="_13999981521384902"&gt;&lt;BR /&gt;&lt;P&gt;:: This script will return the most recent snapshot for the volume and clone it, which sets it online.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: Run the bat file followed by the name of the volume i.e. recent-snapshot.bat AA-GOLD-EXCH01-DB01&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: Once the volume has been created you can discover it on the host and connect to it.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: This can be done automatically however if scheduled the volume target iqn changes, increases by 1 every time.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: NUMBER OF MODIFICATIONS 5:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: MOD 1. Having setup a SSH key with your array define the putty session name (array name) below&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: MOD 2. If you are mounting a snapshot for a backup and do not want it to churn your cache set to true NOT IN USE&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;@ echo off&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;set array-name=array-01&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;set full-backup=false&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: paramater taken from the command line - do not change&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;set volume=%1&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp; echo Using the session %array-name%&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp; echo .&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp; echo .&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: MOD 3. If this is not a scheduled task you will want to comment the lines below to set the clone volume offline and delete it.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: NOTE: there is a 20 second wait command, the ping, to allow the command to complete successfully&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: This is where you would invoke a powershell command if it is mounted in ESX | MS, on testing this is not neccessary for MS.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;echo Removing the existing snapshot clone-%volume%&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp; echo .&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp; echo .&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;plink %array-name% vol --offline clone-%volume% --force&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;ping 192.0.2.2 -n 1 -w 20000 &amp;gt; nul&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;plink %array-name% vol --delete clone-%volume%&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;ping 192.0.2.2 -n 1 -w 20000 &amp;gt; nul&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;plink %array-name% snap --list &amp;gt; snap-list.txt&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: export the snapshot list&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;findstr /B /I %volume% c:snap-list.txt &amp;gt; snap.txt&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: find the snapshots related to the volume&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;for /f "tokens=2 delims= " %%a in (snap.txt) do (&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: retrieve the most recent volume collection name&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp; set mostrecent=%%a&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp; goto :break&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp; )&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp; :break&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp; echo Mounting the snapshot %mostrecent% for volume %volume% it will be called clone-%volume% it will take a minute or so to appear within the GUI.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp; echo .&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp; plink %array-name% vol --clone %volume% --snapname %mostrecent% --clonename clone-%volume%&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: MOD 4. If you don't need the IQN to pass onto Powershell to automatically mount the volume then comment out the section below.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;ping 192.0.2.2 -n 1 -w 60000 &amp;gt; nul&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: wait for the volume to be cloned&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;plink %array-name% vol --info clone-%volume% &amp;gt; vol-info.txt&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: get the new volume information&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;findstr /B /I iSCSI&amp;nbsp; c:vol-info.txt &amp;gt; iscsi.txt&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: find the right line&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;for /f "tokens=3 delims= " %%a in (iscsi.txt) do (&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: get the IQN of the new volume created this can be passed into a powershell script for esx or MS.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp; echo %%a&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp; set iqn=%%a&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp; )&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: MOD 5. from here you pass the parameter into a Vmware or MS powershell script. Script below will set the new volume online on MS 2012 only!.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: The first time you mount the volume assign a drive letter and it will use the same letter every time, or you can add the command to the PS script.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: NOTE: On testing we found you need to restart the SQL service, add it to the PS script.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;powershell.exe -file c:\chris\connect-target.ps1 "%iqn%"&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;exit /b&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Powershell to connect to target&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_13999981520584278 jive_text_macro" jivemacro_uid="_13999981520584278"&gt;&lt;BR /&gt;&lt;P&gt;param(&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;[string]$a&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;)&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Write-Host $a&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Get-IscsiSession | Register-IscsiSession&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Connect-IscsiTarget -NodeAddress "$a"&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Get-Disk | ?{$_.operationalstatus -eq "offline"} | Set-Disk -IsOffline 0&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Get-Disk | ?{$_.operationalstatus -eq "online"}&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE: Initiator groups and ACL's are not replicated, if run at a DR site these will have to be defined.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Feb 2014 11:26:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/array-performance-and-data/automatically-mount-most-recent-snapshot-and-connect-to-target/m-p/6981770#M48</guid>
      <dc:creator>chris24</dc:creator>
      <dc:date>2014-02-06T11:26:20Z</dc:date>
    </item>
    <item>
      <title>Re: Automatically mount most recent snapshot and connect to target.</title>
      <link>https://community.hpe.com/t5/array-performance-and-data/automatically-mount-most-recent-snapshot-and-connect-to-target/m-p/6981771#M49</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For those of us who are still using Windows 2008 R2 (probably most of us) and don't have PowerShell V4 which has the iSCSI commandlets, you can use iscsicli.exe to connect the LUNs and then diskpart.exe to put the new volumes online.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First, you need one more variable to account for the IP of the array, use the iSCSI discovery portal IP from the GUI:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;set array-ip=10.0.1.50&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Next, you have to attach and log in the new volume to the server using iscsicli.exe:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;iscsicli.exe qaddtarget %iqn% %array-ip%&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;iscsicli.exe qlogintarget %iqn%&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then I like to wait 20 seconds for the O/S to recognize it and output all disks using diskpart.exe so that you can find the new volume which will be offline and, in turn, put it online (this won't work if you have multiple volumes offline, of course):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Create a new text file called listdisk.txt and save it in the same directory as all of your other batch files, executables, etc.&amp;nbsp; All it needs to contain is this line:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;list disk&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Back to the batch file:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;timeout /t 20&lt;/STRONG&gt; (much neater than pinging, btw)&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;diskpart.exe /s listdisk.txt &amp;gt; disks.txt&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Create another new text file called offlinedisk.txt and save it in the same directory as all of your other batch files, executables, etc.&amp;nbsp; All it needs to contain is these three lines:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;select disk %disk%&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;online disk&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;attributes disk clear readonly&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Continuing in the batch file, you need to parse the disks.txt for the offline disk and put it online:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;findstr Offline disks.txt &amp;gt; offline.txt&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;for /f "tokens=2" %%b in (offline.txt) do set disk=%%b&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;diskpart.exe /s offlinedisk.txt&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Feb 2014 14:00:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/array-performance-and-data/automatically-mount-most-recent-snapshot-and-connect-to-target/m-p/6981771#M49</guid>
      <dc:creator>azagajewski27</dc:creator>
      <dc:date>2014-02-21T14:00:50Z</dc:date>
    </item>
    <item>
      <title>Re: Re: Automatically mount most recent snapshot and connect to target.</title>
      <link>https://community.hpe.com/t5/array-performance-and-data/automatically-mount-most-recent-snapshot-and-connect-to-target/m-p/6981772#M50</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Two more items:&amp;nbsp; First, a heartfelt thank you to Chris Aylott for putting together above code!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Second, I forgot to add a couple of statements that would remove the "Unrestricted" access to the new volume and then add the initiator group of the server to which you're connecting the new volume:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;plink %array-name% vol --removeacl clone-%volume%&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;plink %array-name% vol --addacl clone-%volume% --initiatorgrp &lt;/STRONG&gt;&lt;EM&gt;&lt;STRONG&gt;initiatorgroup&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Feb 2014 14:31:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/array-performance-and-data/automatically-mount-most-recent-snapshot-and-connect-to-target/m-p/6981772#M50</guid>
      <dc:creator>azagajewski27</dc:creator>
      <dc:date>2014-02-21T14:31:20Z</dc:date>
    </item>
    <item>
      <title>Re: Automatically mount most recent snapshot and connect to target.</title>
      <link>https://community.hpe.com/t5/array-performance-and-data/automatically-mount-most-recent-snapshot-and-connect-to-target/m-p/6981773#M51</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK, more updates:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have found that because the serial of the cloned volume changes, Windows sees it as a new volume and does NOT always assign it the same drive letter or one at all.&amp;nbsp; My backup software looks to backup specific drive letters on the backup media server therefore having the same one is critical.&amp;nbsp; So I've added some more code that will take the new offline volume, find it and then assign it a drive letter.&amp;nbsp; This also means that you have to pass another variable upon execution of the batch file to determine the drive letter.&amp;nbsp; The new command will now be: &lt;STRONG&gt;C:\nimble\recent-snapshot.bat [Volume-Name] [Drive_Letter]&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You also have to add a new line towards the beginning of the batch file to grab this drive letter:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;:: drive letter to assign&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;set letter=%2&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, the new stuff needed to assign a drive letter to the new drive:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Add the following lines before the first &lt;STRONG&gt;iscsicli.exe&lt;/STRONG&gt; line:&lt;/P&gt;&lt;P&gt;:: turn off automounting of basic volumes which will help later with drive letter assignment&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;diskpart.exe /s automountoff.txt&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;:: assign a drive letter to this new volume, make sure it's not already utilized but you have to get the volume from the &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;previously offline disk first&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;diskpart.exe /s findnolettervol.txt &amp;gt; diskdetail.txt&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;:: find the no letter volume from the new disk and assign a letter to it&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;findstr Volume diskdetail.txt &amp;gt; nolettervol.txt&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;:: get the volume number&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;for /f "tokens=2" %%c in (nolettervol.txt) do set vol=%%c&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;:: assign a drive letter to this volume using the passed parameter when batch was launched&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;diskpart.exe /s assignlettervol.txt&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;:: turn back on automounting of volumes which helps with removable storage, etc&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;diskpart.exe /s automounton.txt&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;New text files to create, and their content:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;EM&gt;automountoff.txt:&lt;/EM&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/EM&gt;&lt;/EM&gt;automount disable&lt;/P&gt;&lt;P&gt;&lt;EM&gt;automounton.txt:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/EM&gt;automount enable&lt;/P&gt;&lt;P&gt;&lt;EM&gt;findnolettervol.txt:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select disk %disk%&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; detail disk&lt;/P&gt;&lt;P&gt;&lt;EM style="font-size: 10pt; line-height: 1.5em;"&gt;assignlettervol.txt:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select volume %vol%&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; attributes volume clear readonly&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; attributes volume clear hidden&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; assign letter %letter%&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've noticed that the volumes would come up as read only which is a problem because Windows needs to write a signature.&amp;nbsp; Hence the added lines in the last text file.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Mar 2014 15:44:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/array-performance-and-data/automatically-mount-most-recent-snapshot-and-connect-to-target/m-p/6981773#M51</guid>
      <dc:creator>azagajewski27</dc:creator>
      <dc:date>2014-03-05T15:44:02Z</dc:date>
    </item>
    <item>
      <title>Re: Automatically mount most recent snapshot and connect to target.</title>
      <link>https://community.hpe.com/t5/array-performance-and-data/automatically-mount-most-recent-snapshot-and-connect-to-target/m-p/6981774#M52</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Alex, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Great work!! I have added your contributions to the original script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have rolled up your diskpart scripts into one bat file so no need to create them by hand. Added an example for how I would call this when mounting daily snapshots to a SQL server, it also logs out of the target before deleting the snapshot ... found it kept the drive letter otherwise.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 May 2014 17:26:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/array-performance-and-data/automatically-mount-most-recent-snapshot-and-connect-to-target/m-p/6981774#M52</guid>
      <dc:creator>chris24</dc:creator>
      <dc:date>2014-05-12T17:26:10Z</dc:date>
    </item>
    <item>
      <title>Re: Automatically mount most recent snapshot and connect to target.</title>
      <link>https://community.hpe.com/t5/array-performance-and-data/automatically-mount-most-recent-snapshot-and-connect-to-target/m-p/6981775#M53</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;Unable to edit the original post --- continues from point 2.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Open powershell as administrator run Set-ExecutionPolicy Unrestricted &amp;gt; Read what this means to you! &lt;A href="http://technet.microsoft.com/en-us/library/ee176961.aspx" title="http://technet.microsoft.com/en-us/library/ee176961.aspx"&gt;Using the Set-ExecutionPolicy Cmdlet&lt;/A&gt;&lt;/P&gt;&lt;P&gt;3. Save the code snippets below into c:\folder and rename accordingly i.e. recent-snapshot.bat.&lt;/P&gt;&lt;P&gt;4. Run the create-diskpart-scripts.bat once only.&lt;/P&gt;&lt;P&gt;5. Change the modifications in the script recent-snapshot.bat, add the session name of putty from step 1.7 above to the array-name=XXXXX&lt;/P&gt;&lt;P&gt;6. Execute - ensure the drive letters you want to use are free, the script will not disconnect any targets on the first run, I would recommend not having any connected so you can see it in action.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; recent-snapshot VOLUME DRIVE-LETTER&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; i.e. C:\folder\recent-snapshot AA-SQL01-DB01 F&lt;/P&gt;&lt;P&gt;7. SQL-E-F-drive.bat is an example of usage with SQL&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Batch file - create-diskpart-scripts.bat&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_13999176594122520" jivemacro_uid="_13999176594122520" modifiedtitle="true"&gt;&lt;BR /&gt;&lt;P&gt;echo list disk &amp;gt;&amp;gt; listdisk.txt&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;echo automount disable &amp;gt;&amp;gt; automountoff.txt&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;echo select disk %%disk%% &amp;gt;&amp;gt; findnolettervol.txt&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;echo detail disk &amp;gt;&amp;gt; findnolettervol.txt&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;echo select volume %%vol%% &amp;gt;&amp;gt; assignlettervol.txt&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;echo attributes volume clear readonly &amp;gt;&amp;gt; assignlettervol.txt&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;echo attributes volume clear hidden &amp;gt;&amp;gt; assignlettervol.txt&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;echo assign letter %%letter%% &amp;gt;&amp;gt; assignlettervol.txt&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;echo select disk %%disk%% &amp;gt;&amp;gt; offlinedisk.txt&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;echo online disk &amp;gt;&amp;gt; offlinedisk.txt&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;echo attributes disk clear readonly &amp;gt;&amp;gt; offlinedisk.txt&lt;/P&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;Batch file - recent-snapshot.bat&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_1399917659367206 jive_text_macro" jivemacro_uid="_1399917659367206" modifiedtitle="true"&gt;&lt;BR /&gt;&lt;P&gt;:: This script will:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: 1. logout the existing iSCSI session&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: 2. delete any existing snapshot previously created by this script&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: 3. Create a clone copy of the most recent snapshot&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: 4. change the ACL&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: 5. connect the iSCSI target and associate it with a drive letter&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: Usage&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: Run the bat file followed by the name of the volume and the drive letter i.e. recent-snapshot.bat AA-GOLD-EXCH01-DB01 F&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: NUMBER OF MODIFICATIONS 3:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: MOD 1. Having setup a SSH key with your array define the putty session name (array name) below&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: MOD 2. Array discovery IP, used for connecting the target&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;@ echo off&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;set array-name=array-connect&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;set discovery-ip=10.101.1.50&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: MOD 3. If you do not want the cloned snapshot to have the default permission of full access (0) define the init group.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;set initator-grp=0&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: paramater taken from the command line - do not change&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;set volume=%1&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;set letter=%2&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp; echo Using the session %array-name%&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp; echo .&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp; echo .&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;echo Disconnecting the iSCSI session for the existing mounted snpashot&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp; echo .&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp; echo .&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: Logout of the old target&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: Find the session ID of the existing connection - script has to be run once to get these values.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;findstr "Session Id" %volume%login.txt &amp;gt; %volume%sessionID.txt&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: remove the gyberish leaving us with the SessionID&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;for /f "tokens=4 delims= " %%a in (%volume%sessionID.txt) do (&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp; set sessionid=echo %%a&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp; goto :break&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp; )&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp; :break&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: Logout the specified session ID&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;iscsicli logouttarget %sessionid%&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;echo Removing the existing snapshot clone-%volume%&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp; echo .&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp; echo .&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;plink %array-name% vol --offline Clone-%volume% --force&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;ping 192.0.2.2 -n 1 -w 20000 &amp;gt; nul&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;plink %array-name% vol --delete Clone-%volume%&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;ping 192.0.2.2 -n 1 -w 20000 &amp;gt; nul&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: Find the most recent snapshot&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;plink %array-name% snap --list &amp;gt; snap-list.txt&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: export the snapshot list&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;findstr /B /I %volume% c:snap-list.txt &amp;gt; snap.txt&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: find the snapshots related to the volume&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;for /f "tokens=2 delims= " %%a in (snap.txt) do (&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: retrieve the most recent volume collection name&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp; set mostrecent=%%a&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp; goto :break&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp; )&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp; :break&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp; echo Mounting the snapshot %mostrecent% for volume %volume% it will be called Clone-%volume% it will take a minute or so to appear within the GUI.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp; echo .&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;plink %array-name% vol --clone %volume% --snapname %mostrecent% --clonename Clone-%volume%&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: wait&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;ping 192.0.2.2 -n 1 -w 20000 &amp;gt; nul&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: Set the ACL on the created clone&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;if %initiator-grp%==0 (GOTO :BREAK)&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp; else (&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;plink %array-name% vol --removeacl Clone-%volume%&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;plink %array-name% vol --addacl Clone-%volume% --initiatorgrp %initiator-grp%)&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:BREAK&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: Fetch the IQN&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;plink %array-name% vol --info Clone-%volume% &amp;gt; vol-info.txt&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: get the new volume information&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;findstr /B /I iSCSI&amp;nbsp; c:vol-info.txt &amp;gt; iscsi.txt&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: find the right line&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;for /f "tokens=3 delims= " %%a in (iscsi.txt) do (&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: get the IQN of the new volume created this can be passed into a powershell script for esx or MS.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp; echo %%a &amp;gt; %volume%iqn.txt&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp; set iqn=%%a&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp; )&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: You now have the IQN - you can pass this into powershell via powershell.exe -file c:\putty\connect-target.ps1 "%iqn%"&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: Prevent the volume from being automatically added when the disk is onlined&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;diskpart.exe /s automountoff.txt&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: Connect the new target&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;iscsicli.exe qaddtarget %iqn% %discovery-ip%&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: login to the target and save the output to extract the sessionID required when dismounting the volume on next run&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;iscsicli.exe qlogintarget %iqn% &amp;gt; %volume%login.txt&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;ping 192.0.2.2 -n 1 -w 20000 &amp;gt; nul&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: fetch the disk&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;diskpart.exe /s listdisk.txt &amp;gt; disks.txt&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: online and clear read only attributes&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;findstr Offline disks.txt &amp;gt; offline.txt&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;for /f "tokens=2" %%b in (offline.txt) do set disk=%%b&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;diskpart.exe /s offlinedisk.txt&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: assign a drive letter to this new volume&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;diskpart.exe /s findnolettervol.txt &amp;gt; diskdetail.txt&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: find the no letter volume from the new disk and assign a letter to it&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;findstr Volume diskdetail.txt &amp;gt; nolettervol.txt&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: get the volume number&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;for /f "tokens=2" %%c in (nolettervol.txt) do set vol=%%c&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: online the volume with assigned drive letter&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;diskpart.exe /s assignlettervol.txt&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp; exit /b&lt;/P&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;SQL server example - call this with a scheduled task&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_1399917659355119 jive_text_macro" jivemacro_uid="_1399917659355119" modifiedtitle="true"&gt;&lt;BR /&gt;&lt;P&gt;:: Stop SQL Service&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;net stop mssqlserver&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;call recent-snapshot.bat CA-SQL01-DB-F F&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;call recent-snapshot.bat CA-SQL01-LOG-E E&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;:: Start SQL Service&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;net start mssqlserver&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;EXIT&lt;/P&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 May 2014 18:01:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/array-performance-and-data/automatically-mount-most-recent-snapshot-and-connect-to-target/m-p/6981775#M53</guid>
      <dc:creator>chris24</dc:creator>
      <dc:date>2014-05-12T18:01:56Z</dc:date>
    </item>
    <item>
      <title>Re: Automatically Mount Most Recent Snapshot and Connect to Target</title>
      <link>https://community.hpe.com/t5/array-performance-and-data/automatically-mount-most-recent-snapshot-and-connect-to-target/m-p/6981776#M54</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Chris, I tried running your script but I'm getting error "GOTO was unexpected at this time" after "&lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;Mounting the snapshot %mostrecent% &lt;/SPAN&gt;&lt;SPAN class="keyword" style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #006699;"&gt;for&lt;/SPAN&gt;&lt;SPAN style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #000000;"&gt; volume %volume% it will be called Clone-%volume% it will take a minute or so to appear within the GUI. &lt;/SPAN&gt;"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any idea where could be wrong? Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;P.S. I bypassed the ACL section now I'm having problem with this section:&lt;/P&gt;&lt;OL class="dp-cpp" start="1" style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; list-style-position: initial; list-style-image: initial; color: #5c5c5c; margin: 0 0 1px 45px !important;"&gt;&lt;LI&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;&lt;SPAN class="keyword" style="font-weight: inherit; font-style: inherit; color: #006699; font-size: 9pt !important; background-color: inherit;"&gt;for&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt; /f &lt;/SPAN&gt;&lt;SPAN class="string" style="font-weight: inherit; font-style: inherit; color: blue; font-size: 9pt !important; background-color: inherit;"&gt;"tokens=3 delims= "&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt; %%a in (iscsi.txt) &lt;/SPAN&gt;&lt;SPAN class="keyword" style="font-weight: inherit; font-style: inherit; color: #006699; font-size: 9pt !important; background-color: inherit;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt; (&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;:: get the IQN of the &lt;SPAN class="keyword" style="font-weight: inherit; font-style: inherit; color: #006699; font-size: 9pt !important; background-color: inherit;"&gt;new&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt; volume created &lt;/SPAN&gt;&lt;SPAN class="keyword" style="font-weight: inherit; font-style: inherit; color: #006699; font-size: 9pt !important; background-color: inherit;"&gt;this&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt; can be passed into a powershell script &lt;/SPAN&gt;&lt;SPAN class="keyword" style="font-weight: inherit; font-style: inherit; color: #006699; font-size: 9pt !important; background-color: inherit;"&gt;for&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt; esx or MS.&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;&amp;nbsp; echo %%a &amp;gt; %volume%iqn.txt&amp;nbsp; &lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;&amp;nbsp; set iqn=%%a&amp;nbsp; &lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;&amp;nbsp; )&amp;nbsp; &lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;The echo didn't give me the right iqn, it's just empty. The iscsi.txt does have the right info like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;iSCSI target: iqn.2007-11.com.nimblestorage:clone-fileserver-v665c089a794a082d.000000a6.1f1600b7&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Oct 2014 16:17:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/array-performance-and-data/automatically-mount-most-recent-snapshot-and-connect-to-target/m-p/6981776#M54</guid>
      <dc:creator>jliu79</dc:creator>
      <dc:date>2014-10-21T16:17:47Z</dc:date>
    </item>
  </channel>
</rss>

