Reconnecting iSCSI Targets

Recently I noticed that my backups were failing. I’m using Windows Server Backup with iSCSI LUNs mapped to individual servers. After looking at a server, I saw that the iSCSI LUN was no longer present on the server.

A look at the iSCSI Initiator properties confirmed that the target wasn’t connected:

Apparently restarting the Microsoft iSCSI initiator service doesn’t necessarily reconnect the target, even if it’s included in the list of Favorite Targets. The only way to guarantee a connection ist to connect it in the GUI – or, of course, PowerShell.

Let’s look at a few PowerShell options. First, use the Get-IscsiTarget command to enumerate targets. This will basically give you the same list as shown above:

We want to reconnect tot he target that has the computer’s name in its address. So basically the command would look something like this:

To be a little bit more flexible, let’s get the computer name out of the computer’s environment:

It’s of course also possible that the target is already connected (IsConnected “True”), so the actual reconnect will only be used if the target isn’t currently connected. The final command therefore is:

In conclusion, I will now create a task on my servers that will launch this command every day just before backups start.



Leave a Reply

Your email address will not be published. Required fields are marked *