hyper v - Creating Virtual Disk in PowerShell / Help Understanding Error
2014-04
I am trying to setup a new Virtual Disk in Hyper-V Server 2012 r2. Since there is no GUI, I would like to do this using PowerShell. So far I think I have successfully created a new pool from two HDDs, but when I try to make the Virtual Disk I get an error I don’t understand.
Any help would be greatly appreciated.
PS C:\Users\xxxx> Get-StoragePool
FriendlyName OperationalStat HealthStatus IsPrimordial IsReadOnly
us
------------ --------------- ------------ ------------ ----------
Primordial OK Healthy True False
StoragePool_1 OK Healthy False False
PS C:\Users\xxxx> New-VirtualDisk -StoragePoolFriendlyName StoragePool_1 -FriendlyName VirtualDisk_1 -UseMaximumSize -ResiliencySettingName Simple -ProvisioningType Thin
New-VirtualDisk : Invalid Parameter
At line:1 char:1
+ New-VirtualDisk -StoragePoolFriendlyName StoragePool_1 -FriendlyName
VirtualDisk ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
+ CategoryInfo : InvalidArgument: (StorageWMI:ROOT/Microsoft/...S
FT_StoragePool) [New-VirtualDisk], CimException
+ FullyQualifiedErrorId : StorageWMI 5,New-VirtualDisk
Just in case someone else runs into the same thing--I was able to get things to work by manually setting the NumberOfColumns.
When I try to execute my PowerShell script I get this error:
File C:\Common\Scripts\hello.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see "get-help about_signing" for more details.
At line:1 char:13
+ .\hello.ps1 <<<<
+ CategoryInfo : NotSpecified: (:) [], PSSecurityException
+ FullyQualifiedErrorId : RuntimeException
Enable running unsigned scripts by entering:
set-executionpolicy remotesigned
This will allow running unsigned scripts that you write on your local computer and signed scripts from Internet.
See also Running Windows PowerShell Scripts
The Default Execution Policy is set to restricted, you can see it by typing:
Get-ExecutionPolicy
You should type the following to make it go to unrestricted mode:
Set-ExecutionPolicy unrestricted
Hope this helps
On my machine that I use to dev scripts, I will use -unrestricted as above. When deploying my scripts however, to an end user machine, I will just call powershell with the -executionpolicy switch:
powershell.exe -noprofile -executionpolicy bypass -file .\script.ps1