try to get the virtual keyboard a number of different ways. This should hopefully work for Windows 7, Window 10 and Windows Server 2016
This commit is contained in:
parent
056fc59166
commit
4ab2e8b252
|
@ -682,8 +682,17 @@ param([string]$vmName, [string]$scanCodes)
|
|||
if ($vm -eq $null){
|
||||
Write-Error ("VirtualMachine({0}) is not found!" -f $VMName)
|
||||
}
|
||||
|
||||
|
||||
$vmKeyboard = $vm | Get-CimAssociatedInstance -ResultClassName "Msvm_Keyboard" -ErrorAction Ignore -Verbose:$false
|
||||
|
||||
if ($vmKeyboard -eq $null) {
|
||||
$vmKeyboard = Get-CimInstance -Namespace "root\virtualization\v2" -ClassName Msvm_Keyboard -ErrorAction Ignore -Verbose:$false | where SystemName -eq $vm.Name | select -first 1
|
||||
}
|
||||
|
||||
if ($vmKeyboard -eq $null) {
|
||||
$vmKeyboard = Get-CimInstance -Namespace "root\virtualization" -ClassName Msvm_Keyboard -ErrorAction Ignore -Verbose:$false | where SystemName -eq $vm.Name | select -first 1
|
||||
}
|
||||
|
||||
if ($vmKeyboard -eq $null){
|
||||
Write-Error ("VirtualMachine({0}) keyboard class is not found!" -f $VMName)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue