Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On Windows XP SP3, how can I extend a volume using Powershell on a remote computer?

I prefer WMI over Powershell remoting.

share|improve this question
up vote 2 down vote accepted

On my local computer I would do this by piping the commands to diskpart:

PS> $a = "select disk 0","select volume 0","extend" | diskpart
PS> write-host $a

Maybe you can build on this to achieve the desired result on the remote computer

share|improve this answer
Current solution: Invoke-Command -ComputerName $compName -Credential $compCred -ScriptBlock {"rescan","select volume 2","extend" | diskpart} – Primoz Jan 27 '11 at 8:35
Thanky you very much for your inspiring answer. – Primoz Jan 27 '11 at 8:36
$pass = convertto-securestring "p@$$w0rd" -asplaintext -force

$mycred = new-object -typename System.Management.Automation.PSCredential -argumentlist "\Administrator",$pass

Invoke-Command -ComputerName -Credential $myCred -ScriptBlock {"rescan","select volume 2","extend" | diskpart}


Where is the remote host where we need to run the Get-PSRemoting command.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.