Powershell:如何找到其他-ExpandProperty';s
im尝试将ID为的usb设备连接到我的xp模式(虚拟机)。 这是我在网上找到的代码Powershell:如何找到其他-ExpandProperty';s,powershell,powershell-2.0,virtual-machine,xp-mode,Powershell,Powershell 2.0,Virtual Machine,Xp Mode,im尝试将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
# 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。如果您转到设备管理器并选择“未知设备”-属性-详细信息-硬件id,您将看到该设备的id,我希望在Powershell中获取该id,以便我可以使用设备id将其发送到我的VM(xp模式)
我对powershell非常陌生,mybe有一种方法可以查看所有属性$vpc.USBDeviceCollection,但我不知道如何
有人能帮我吗?
谢谢 VirtualPC.Application没有DeviceID属性 请尝试在此处阅读,以便使用wmi获取它
问题是,我想连接一个未知设备。一个未知设备没有名称,只有一个ID。我试图在寄存器中给它一个名称,但它不允许我…在这个命令之后:gwmi Win32_USBControllerDevice |%{[wmi]($|依赖)}| Sort Description,DeviceID | ft Description,你能在列表中找到这个未知的设备吗?是的,它是列表中第一个没有名字的设备屏幕截图:好了,现在你有了你的设备ID。这不是您想要的吗?抱歉,我无法提供更多帮助。您可以使用Get Member命令查看对象的所有可用属性:$vpc.USBDeviceCollection | Get Member