Hi,
The diskpart volume number cannot be found in the WMI class Win32_Volume. You have to parse the output of diskpart
$letter = "C"
$command = "select vol $letter"
Invoke-Command -Computername $vm -scriptblock {
$using:command | diskpart| foreach{
if($_ -match "Volume \d+"){
$Matches.Values
}
}
}
Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.