- Microsoft Edge: Open new tab without MSN news, configure start pages with GPO - Tue, Jan 4 2022
- Turn off web search in Windows 11 using Group Policy - Tue, Dec 28 2021
- Set default web browser in Windows 11 using Group Policy - Thu, Dec 23 2021
When you start the applet for the iSCSI initiator on a computer on which a connection has never been configured, you will receive a message that the iSCSI service is not running. If you prefer to use PowerShell instead of the GUI tool, then you have to take care of the prerequisites yourself.
Checking the prerequisites ^
The first step is to query the status of the iSCSI service:
Get-Service -Name MSiSCSI
If it turns out that the service has to be started, you can do this with the following command:
Start-Service -Name MSiSCSI
Next, change the start type to automatic, so that it will be executed again every time the computer is rebooted.
Set-Service -Name MSiSCSI -StartupType Automatic
If you are not sure whether there are already connections to an iSCSI target, you can check this using:
In the following figure, the command returns a blank result. Hence, no connections exist.
Discovery of targets ^
To establish a new target, direct the initiator to the corresponding storage device. This is done by invoking:
New-IscsiTargetPortal -TargetPortalAddress "<IP or FQDN>"
This command uses the default initiator for the discovery process and default port 3260. Both can be specified using parameters, with Target¬Portal¬Port¬Number responsible for specifying the port.
If the client has more than one initiator, you can display them using the command:
You then pass the desired one to the InitiatorInstanceName parameter:
New-IscsiTargetPortal -TargetPortalAddress "192.168.0.180" \` -InitiatorInstanceName "ROOT\\ISCSIPRT\\0000\_0"
The next call to Get-IscsiTarget will provide the necessary information for the subsequent procedure. First and foremost, this includes the NodeAddress of the targets found. This is needed to establish a connection with the target.
In our example, the target is provided by a Synology NAS:
Connect-IscsiTarget -NodeAddress "iqn.2000-01.com.synology:DS214.Target-1.0e1a3dc1d1"
This command can be varied as needed. For example, the above call will only create a connection until the next reboot. If you want to make it permanent, then add the parameter -IsPersistent $true.
If you want to connect all available targets, then the following command does the job:
Get-IscsiTarget | Connect-IscsiTarget
Disconnect targets ^
The PowerShell module iSCSI also has cmdlets for the reverse operations. In our example, to terminate the connection to a target, you would issue the following command:
Disconnect-IscsiTarget -NodeAddress "iqn.2000-01.com.synology:DS214.Target-1.0e1a3dc1d1"
Finally, the target portal can be removed in this way:
Subscribe to 4sysops newsletter!
Remove-IscsiTargetPortal -TargetPortalAddress "192.168.0.180"
Here, be sure to specify the parameters in the same way as before for New- IscsiTargetPortal. If you used an IP for the portal address, then you should not specify a DNS name here. The same applies to the Initiator Instance Name. If you have originally passed one to the cmdlet, you have to do the same when you remove it.