그것을 완벽하게 작동합니다 : (안 하나의 오류) 내가 한 줄에이 코드를 넣어Powershell 코드는 편집기에서 작동하지만 Powershell cmd에서는 작동하지 않습니다. 내가 편집기에서이 코드를 실행하면
$vm = 0
$vpc=new-object –com VirtualPC.Application –Strict
foreach ($vm in $vpc.VirtualMachines){}
$broken = Get-WmiObject Win32_PnPEntity | where {$_.ConfigManagerErrorCode -ne 0}
$usbDevice = $vpc.USBDeviceCollection | ? {$_.DeviceString -eq $usb} | select -first 1
$vm.AttachUSBDevice($usbDevice)
; 말 :
$vm = 0; $vpc=new-object –com VirtualPC.Application –Strict; foreach ($vm in $vpc.VirtualMachines){}; $broken = Get-WmiObject Win32_PnPEntity | where {$_.ConfigManagerErrorCode -ne 0}; $usbDevice = $vpc.USBDeviceCollection | ? {$_.DeviceString -eq $usb} | select -first 1; $vm.AttachUSBDevice($usbDevice)
이 나에게 0 × 80020005 오류 제공 :
Exception calling "AttachUSBDevice" with "1" argument(s): "Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_T
YPEMISMATCH))"
At line:1 char:293
+ $vpc=new-object -com VirtualPC.Application -Strict; $vm = $vpc.findVirtualMachine("Windows XP Mode"); $broken = Get-W
miObject Win32_PnPEntity | where {$_.ConfigManagerErrorCode -ne 0}; $usbDevice = $vpc.USBDeviceCollection | ? {$_.Devic
eString -eq $usb} | select -first 1; $vm.AttachUSBDevice <<<< ($usbDevice)
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ComMethodTargetInvocation
누군가가이 문제를 해결하는 방법을 알고 있습니까?
(I 코드가 조금 이상하지만 포인트를 :)하지 먹으 렴 알고)
코드에서 $ usb를 정의 할 수 있습니까? –
나는 USB가 아무것도 필요 없기 때문에 나는 usb를 정의하지 않았다. 내가 0 = 또는 "="라고 말하면 분명히 아무것도 아닌 것처럼 보입니다. – Freddy