对于Powershell设备管理->;启用设备

对于Powershell设备管理->;启用设备,powershell,module,cmdlet,Powershell,Module,Cmdlet,我为Powershell安装了设备管理模块,专门用于启用设备和禁用设备功能 但当我调用其中任何一个时,它都需要一个TargetDevice(这显然是有意义的)。。但我无法为执行此命令而计算出我的设备(本例中为驱动器)的“名称” 与大多数PowerShell cmdlet一样,它们的设计考虑了管道 通常,处理此问题的最佳方法是首先获取Set或Update cmdlet的目标,并将其导入更改它的目标: $deviceName = Read-Host -Prompt 'Please enter the

我为Powershell安装了设备管理模块,专门用于启用设备和禁用设备功能


但当我调用其中任何一个时,它都需要一个TargetDevice(这显然是有意义的)。。但我无法为执行此命令而计算出我的设备(本例中为驱动器)的“名称”

与大多数PowerShell cmdlet一样,它们的设计考虑了管道

通常,处理此问题的最佳方法是首先获取Set或Update cmdlet的目标,并将其导入更改它的目标:

$deviceName = Read-Host -Prompt 'Please enter the Name of the Device to Disable'
Get-Device | Where-Object -Property Name -Like $deviceName | Disable-Device

$deviceName = Read-Host -Prompt 'Please enter the Name of the Device to Enable'
Get-Device | Where-Object -Property Name -Like $deviceName | Enable-Device

这直接来自。

与大多数PowerShell cmdlet一样,它们的设计考虑了管道

通常,处理此问题的最佳方法是首先获取Set或Update cmdlet的目标,并将其导入更改它的目标:

$deviceName = Read-Host -Prompt 'Please enter the Name of the Device to Disable'
Get-Device | Where-Object -Property Name -Like $deviceName | Disable-Device

$deviceName = Read-Host -Prompt 'Please enter the Name of the Device to Enable'
Get-Device | Where-Object -Property Name -Like $deviceName | Enable-Device
这是直接从中提取的