You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在PowerShell中使用Remove-Printer命令删除多台打印机?

单条PowerShell命令删除多台打印机的方法

Remove-Printer的-Name参数支持传入字符串数组,你之前的错误在于把多个名称拼成了单个字符串,正确的写法是直接传递多个独立的名称:

  • 直接在命令里用逗号分隔多个打印机名称(每个名称单独用引号包裹,名称无空格时可省略引号):

    Remove-Printer -Name "Name", "Name1", "Name2"
    
  • 先将需要删除的打印机名称存入数组变量,再传入命令:

    $targetPrinters = @("Name", "Name1", "Name2")
    Remove-Printer -Name $targetPrinters
    

如果需要批量删除名称符合特定模式的打印机,还可以使用通配符简化操作:

# 删除所有以"TempPrinter"开头的打印机
Remove-Printer -Name "TempPrinter*"

内容的提问来源于stack exchange,提问作者nhoz

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.17 07:45:20