Trying to run Diskpart using powershell

Hello,
 I've been trying to find a way to extend a storage volume using powershell v2.

So far I've just writen it so that powershell automates using diskpart.exe but when i try to execute it throws me a Error saying no disk or volume is selected.

$Volume = $args[0]

$command= @"
select partition $volume
select volume $volume
extend
"@

$command| Diskpart
LVL 2
MedassurantAsked:
Who is Participating?
 
QlemoConnect With a Mentor DeveloperCommented:
You need to select the disk first. You can try that in interactive mode of diskpart first, then apply the changes to your script:




$Volume = $args[0]

$command= @"
select disk=1
select  partition $volume
select volume $volume
extend
"@

$command|  Diskpart
0
 
miked2004Commented:
Not sure if this will help, but when ever i need to repartition a disk i use Gparted or a ubuntu live cd. Works great. I am not familiar with powershell
0
 
MedassurantAuthor Commented:
This was a partial solution to my question
0
All Courses

From novice to tech pro — start learning today.