Using an iSCSI target

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.

Getting ready

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).

How to do it...

  1. On FS1, set the iSCSI service to start automatically, then start the service:
    Set-Service MSiSCSI -StartupType 'Automatic'
    Start-Service MSiSCSI
  2. Set up the portal to SRV1:
    $PHT ...

Get Windows Server 2019 Automation with PowerShell Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.