Scripting new VHDx using PowerShell [Resolved]
Hi All,
Got a bit of an issue when I'm trying to script the creation of a new VHDx.
If I open Powershell and send/type the following command it creates a new VHDx file;
However if I try passing the parameters by using the run command using this;
I get this error;
However if I use the run command with this;
it then works.
I can only assume it's something to do with spaces between my directory but I've tried playing about with quotes and no luck!
Cheers Swain90
Hi All,
Got a bit of an issue when I'm trying to script the creation of a new VHDx.
If I open Powershell and send/type the following command it creates a new VHDx file;
Code:
NEW-VHD -Fixed -SizeBytes 2GB -path "E:\Virtual Machine VHDs\Test.vhdx"
However if I try passing the parameters by using the run command using this;
Code:
powershell NEW-VHD -Fixed -SizeBytes 2GB -path "E:\Virtual Machine VHDs\Test.vhdx"
I get this error;
Code:
New-VHD : A positional parameter cannot be found that accepts argument 'Machine'.
At line:1 char:1
+ NEW-VHD -Fixed -SizeBytes 2GB -path E:\Virtual Machine VHDs\Test.vhdx
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [New-VHD], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.Vhd.PowerShell.NewVhdCommand
However if I use the run command with this;
Code:
powershell New-VHD -Fixed -SizeBytes 2GB –Path E:\NewVHDFile.VHDX
it then works.
I can only assume it's something to do with spaces between my directory but I've tried playing about with quotes and no luck!
Cheers Swain90
Last edited: