[英]Powershell: how to find the other -ExpandProperty's
試圖將具有ID的USB設備連接到我的XP模式(虛擬機)。 這是我在互聯網上找到的代碼。
# Connect to Virtual PC
$vpc = new-object -comobject "VirtualPC.Application"
# Get VM name
$vmName = Read-host "Specify the name of the virtual machine that you want to use"
# List available USB devices
write-host "The following USB devices are available:"
$vpc.USBDeviceCollection | select -ExpandProperty DeviceString
# Get the USB device name
$usb = Read-host "Enter the name of the USB device that you want to connect to the virtual machine"
# Get the VM object
$vm = $vpc.findVirtualMachine($vmName)
# Get the USB object
$usbDevice = $vpc.USBDeviceCollection | ? {$_.DeviceString -eq $usb} | select -first 1
# Attach the device - this will fail if the VM is not running
$vm.AttachUSBDevice($usbDevice)
現在,以下行給出了設備的名稱:
$vpc.USBDeviceCollection | select -ExpandProperty DeviceString
我想查看設備的ID。 如果轉到設備管理器並選擇“未知設備” -properties -details-硬件ID,您將看到該設備的ID,並且我想在Powershell中獲取此ID,以便可以將其與設備ID一起確定給我的VM (xp模式)
我對Powershell還是很陌生,也許有一種方法可以查看$ vpc.USBDeviceCollection的所有屬性,但是我不知道如何...
有人可以幫我嗎? 謝謝!
VirtualPC.Application沒有DeviceID屬性。
嘗試在這里閱讀以使用wmi獲得它
http://blogs.msdn.com/b/powershell/archive/2007/02/24/displaying-usb-devices-using-wmi.aspx
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.