ISCSI Server Installation 1. Create a virtual machine (VM). 2. Note wn the IP address of the created virtual machine 3. RDP the machine Click Start Menu -> All Programs -> Accessories -> Remote Desktop Connection 4. Type the IP address of the iscsi machine in the computer field and click connect button
5. Enter the administrator s credential. 6. Wait for a moment. Then Click Yes 7. Now, open PowerShell prompt as shown below and execute following commands # URL to wnload the iscsi target software $ iscsi_target_url = http://wnload.microsoft.com/wnload/2/f/1/2f110b9c-6cb0-45f1-971b- 4BA37395D820/iSCSITargetQFE4.exe # IP of the main controller. Replace with your main controller s IP $ main_ip= 10.140.17.114 # Name of the main. Replace with your main name $ main_name= titan # Name of the main user account. Change it as per requirement $ main_user= administrator # Password for the main user account. Change it as per requirement $main_password= jjdgfjd#fhf
echo "DOWNLOADING THE ISCSI TARGET SOFTWARE" $wc=new-object system.net.webclient $wc.wnloadfile($iscsi_target_url,"c:\iscsitarget.exe") echo "DISABLE FIREWALL" netsh advfirewall set allprofiles state off echo "ADDING NODE TO DOMAIN" $DOMAINJOIN=[System.Net.Dns]::GetHostName() netsh interface ipv4 set dns name="local Area Connection" source=static address="$main_ip" primary netm join "$DOMAINJOIN" /main:$main_name /userd:$main_user /passwordd:$main_password Set-ExecutionPolicy remotesigned force echo Restarting the machine shutwn r t 0 8. After few minutes, RDP the same machine with the right credential 9. Now, open PowerShell prompt and execute following commands echo "ENABLING PS-REMOTING" netsh advfirewall firewall add rule name="winws Remote Management (HTTP-In)" dir=in action=allow service=any enable=yes profile=any localport=5985 protocol=tcp schtasks /CREATE /TN "EnablePS-Remoting" /SC MINUTE /MO 1 /RL HIGHEST /RU $main_name\$main_username /RP $main_password /TR "powershell -Command Enable-PSRemoting -Force" /F schtasks /RUN /TN "EnablePS-Remoting" sleep 5; $status_code=schtasks /query /fo list /tn "EnablePS-Remoting" find.exe /c `"Running`" }while ("$status_code" -eq "1") schtasks /DELETE /F /TN "EnablePS-Remoting" # EXTRACT iscsi SETUP add-content "c:\iscsi.ps1" 'start c:\iscsitarget.exe -winwstyle hidden -ArgumentList "/s" -wait' schtasks.exe /CREATE /TN "Extract-ISCSI" /SC MONTHLY /MO first /D SUN /RL HIGHEST /RU $main_name\$main_username /RP $main_password /TR "powershell -noprofile -command &c:\iscsi.ps1} - WinwStyle Hidden" /F schtasks.exe /RUN /TN "Extract-ISCSI" sleep 5; $status_code=schtasks /query /fo list /tn "Extract-ISCSI" find.exe /c `"Running`" }while ("$status_code" -eq "1") schtasks /DELETE /F /TN "Extract-ISCSI" remove-item c:\iscsi.ps1 -Force # INSTALL iscsi TARGET add-content "c:\iscsi.ps1" 'start-process "msiexec" "/i C:\iSCSTarget\x64\iscsitarget_public.msi /qn /L*v C:\iscsi_install.log" -WinwStyle hidden' schtasks.exe /CREATE /TN "Install-ISCSI" /SC MONTHLY /MO first /D SUN /RL HIGHEST /RU $main_name\$main_username /RP $main_password /TR "powershell -noprofile -command &c:\iscsi.ps1} - WinwStyle Hidden" /F schtasks.exe /RUN /TN "Install-ISCSI" sleep 5;
$status_code=schtasks /query /fo list /tn "Install-ISCSI" find.exe /c `"Running`" }while ("$status_code" -eq "1") schtasks /DELETE /F /TN "Install-ISCSI" # CREATE VIRTUAL DISKS mkdir c:\disks Import-Module MicrosoftIscsiTarget New-IscsiVirtualDisk "c:\disks\disk1.vhd" -Size 1GB New-IscsiVirtualDisk "c:\disks\disk2.vhd" -Size 1GB New-IscsiVirtualDisk "c:\disks\disk3.vhd" -Size 1GB 10. Then click on Start -> Microsoft iscsi Software Target link 11. Then Click on the Devices. There are list of virtual disks on the right panel 12. Right Click on each Virtual Disk-> Disk Access->Mount Read/Write
After Successful mount, a message box comes. Click OK to close the message box. Repeat this step for each virtual disk. NOTE: As there is no command to enable the iscsi disk access using the cmdlets. This feature (mounting iscsi virtual disk locally) is supported on Winws Server 2012 O.S but not supported in Win2k8 R2 server. That s why we this step manually 13. Then executes the following command on the PowerShell prompt to initialize and format the virtual disks $i=0 $j=1 $file="list disk" diskpart select-string "online" $diskattri="attributes disk clear reanly" $initdisk="convert MBR" $partndisk="create partition primary size=1020" $letter=@("e","f","g") $disk=$file[$j] -split "\s3,}" $seldisk="sel"+$disk[$i] $assignletter="assign letter="+$letter[$j-1] $formatdisk="format fs=ntfs quick label="""+"cluster"+$disk[$i] -replace '\s+', ' ' $formatdisk += '"' $seldisk Out-File -append c:\selectannlinedisk.txt
$diskattri Out-File -append c:\selectannlinedisk.txt $initdisk Out-File -append c:\selectannlinedisk.txt $partndisk Out-File -append c:\selectannlinedisk.txt $assignletter Out-File -append c:\selectannlinedisk.txt $formatdisk Out-File -append c:\selectannlinedisk.txt $j++ }while ($file[$j] -ne $file[$j].eof) get-content c:\selectannlinedisk.txt diskpart