I am writing a powerscript that connects to a target through ISCSi. I need to find the new drive letters (F:
, G:
, …) that is created after connecting. Is there any direct way to find that? MY script would be
New-IscsiTargetPortal -TargetPortalAddress $VirtualDeviceIp
Connect-IscsiTarget -NodeAddress $VirtualDeviceIQN
#Get the drives newly attached
Though not straight I tried another way of doing it.
$initial=Get-Volume
New-IscsiTargetPortal -TargetPortalAddress $VirtualDeviceIp
Connect-IscsiTarget -NodeAddress $VirtualDeviceIQN
$final=Get-Volume
#Now compare $initial and $final to find the newly attached disks
But I dont know implement the second idea too :(
Compare the
DriveLetter
property of the two sets:Expanding the property will give you just the drive letter:
To be on the safe side you could add a filter that restricts results to "right side" items (i.e. newly added drives), thus excluding "left side" items (i.e. removed drives):