On my old blog, I previously posted this script which I haven’t used in a while but really needed this script to connect four Hyper-V hosts to some iSCSI storage. Doing the process manually would have taken me about an hour of work, and in the future if the hosts needed to be rebuilt then running a script to connect the iSCSI targets to the host automatically is definitely preferred! So I am basically reposting this as it is super helpful. And I also cannot find the original copy of this script anymore!

Make sure that you test the script in a test/dev environment first – never immediately try it in production first ;).

You also need to create a new CSV along with the following headers: Hostname, Cluster, IP,InitiatorIQN, iSCSI_Portal, iSCSI_Target