This fixes error for Win 10 Enterprise:
An error occurred while executing a PowerShell script. This error
is shown below. Please read the error message and see if this is
a configuration error with your system. If it is not, then please
report a bug.
Script: get_vm_status.ps1
Error:
C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.7.4\plugins\providers\hyperv\scripts\get_vm_status.ps1 : Unable to
find type [Microsoft.HyperV.PowerShell.VirtualizationOperationFailedException].
At line:1 char:1
+ &('C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.7.4\plugins\prov ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Microsoft.Hyper...FailedException:TypeName) [get_vm_status.ps1], Ru
ntimeException
+ FullyQualifiedErrorId : TypeNotFound,get_vm_status.ps1
26 lines
590 B
PowerShell
26 lines
590 B
PowerShell
Param(
|
|
[Parameter(Mandatory=$true)]
|
|
[string]$VmId
|
|
)
|
|
|
|
# Include the following modules
|
|
$Dir = Split-Path $script:MyInvocation.MyCommand.Path
|
|
. ([System.IO.Path]::Combine($Dir, "utils\write_messages.ps1"))
|
|
|
|
# Get the VM with the given name
|
|
try {
|
|
$VM = Get-VM -Id $VmId -ErrorAction "Stop"
|
|
$State = $VM.state
|
|
$Status = $VM.status
|
|
} catch [Microsoft.HyperV.PowerShell.VirtualizationException] {
|
|
$State = "not_created"
|
|
$Status = $State
|
|
}
|
|
|
|
$resultHash = @{
|
|
state = "$State"
|
|
status = "$Status"
|
|
}
|
|
$result = ConvertTo-Json $resultHash
|
|
Write-Output-Message $result
|