Once you have an iSCSI target defined, as you did in the Creating an iSCSI target recipe, you can use it. Essentially, to use the disk, you connect to the iSCSI target server (that is, SRV1
). Once you're connected, the Get-Disk
cmdlet returns the iSCSI disk as though it were a local disk. You can then format and use the iSCSI disk as though it were local.
This recipe uses the iSCSI target you created in the Creating an iSCSI target recipe. You use SRV1
as the iSCSI target and access the target from the iSCSI initiator (FS1
).
FS1
, set the iSCSI service to start automatically, then start the service:Set-Service MSiSCSI -StartupType 'Automatic' Start-Service MSiSCSI
SRV1
:$PHT = @{ TargetPortalAddress = 'SRV1.Reskit.Org' TargetPortalPortNumber = 3260 } New-IscsiTargetPortal @PHT
SalesTarget
on the portal:$Target = Get-IscsiTarget | Where-Object NodeAddress -Match 'SalesTarget' $Target
SRV1
:$CHT = @{ TargetPortalAddress = 'SRV1.Reskit.Org' NodeAddress = $Target.NodeAddress } Connect-IscsiTarget @CHT
SRV1
from FS1
:$ISD = Get-Disk | Where-Object BusType -eq 'iscsi' $ISD | Format-Table -AutoSize
$ISD | Set-Disk -IsOffline $False $ISD | Set-Disk -Isreadonly $False
FS1
:$NVHT = @{ FriendlyName = 'SalesData' FileSystem = 'NTFS' DriveLetter = 'I' } $ISD | New-Volume @NVHT
Set-Location -Path I: New-Item -Path I: -Name SalesData -ItemType Directory | Out-Null 'Testing 1-2-3' | Out-File -FilePath I:SalesDataTest.Txt Get-ChildItem -Path I:SalesData
In step 1, you set the Microsoft iSCSI service to automatically start, then you start it. This step produces no output.
In step 2, you create a portal to the iSCSI server on SRV1
, which looks like this:
In step 3, you use the portal just created to get the SalesTarget
iSCSI target on SRV1
, which looks like this:
In step 4, you connect to the iSCSI target on SRV1
, which looks like this:
Once you've connected to the iSCSI target, you can view the disk drive provided via iSCSI, which looks like this:
In step 6, you turn the disk online and make it read/write. This step produces no output. In step 7, you create a new volume on this disk, which looks like this:
In the final step, step 8, you use the iSCSI disk just like it was a local one, which looks like this:
This recipe enabled you to use the Microsoft iSCSI initiator to connect to a Microsoft iSCSI-provided target. These built-in features work and are fine for simple use.
The iSCSI initiator and the iSCSI target features with Windows Server 2019 have seen little development or improvement since they were first released over a decade ago. You may find independent third-party iSCSI vendors that are more appropriate depending on your requirements.
3.135.206.254