我正在编写一个通过 ISCSI 连接到目标的 powerscript。我需要找到连接后创建的新驱动器号 ( F:
, G:
, ...)。有什么直接的方法可以找到吗?我的脚本是
New-IscsiTargetPortal -TargetPortalAddress $VirtualDeviceIp
Connect-IscsiTarget -NodeAddress $VirtualDeviceIQN
#Get the drives newly attached
虽然不直,但我尝试了另一种方法。
$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
但我也不知道实现第二个想法:(