Do not try to type scancodes if there are none. We haven't figured out how to do this on Windows 10 or Windows 7 and below. This will at least allow other types of VMs to be built.

This commit is contained in:
Taliesin Sisson 2015-12-01 07:26:15 +00:00
parent 8734c5b25f
commit 056fc59166
1 changed files with 5 additions and 1 deletions

View File

@ -659,6 +659,10 @@ if ($vm.State -eq [Microsoft.HyperV.PowerShell.VMState]::Running) {
}
func TypeScanCodes(vmName string, scanCodes string) error {
if len(scanCodes) == 0 {
return nil
}
var script = `
param([string]$vmName, [string]$scanCodes)
#Requires -Version 3
@ -674,7 +678,7 @@ param([string]$vmName, [string]$scanCodes)
$ErrorActionPreference = "Stop"
$vm = Get-CimInstance -ComputerName localhost -Namespace "root\virtualization\v2" -ClassName Msvm_ComputerSystem -ErrorAction Ignore -Verbose:$false | where ElementName -eq $VMName | select -first 1
$vm = Get-CimInstance -Namespace "root\virtualization\v2" -ClassName Msvm_ComputerSystem -ErrorAction Ignore -Verbose:$false | where ElementName -eq $VMName | select -first 1
if ($vm -eq $null){
Write-Error ("VirtualMachine({0}) is not found!" -f $VMName)
}