$printers = get-printer * | where { $_.Portname -like "*.ggg.com"} | Format-Table -Property Name -AutoSize
foreach ($printer in $printers)
{
Remove-Printer -InputObject $printer
}
我也尝试过Remove-Printer -Name $printer.Name
,但它不起作用为什么我会收到此错误:
Remove-Printer : Cannot process argument transformation on parameter 'InputObject'. Cannot convert the
"Microsoft.PowerShell.Commands.Internal.Format.FormatEndData" value of type
"Microsoft.PowerShell.Commands.Internal.Format.FormatEndData" to type
"Microsoft.Management.Infrastructure.CimInstance[]".
At line:4 char:29
+ Remove-Printer -InputObject $printer
+ ~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Remove-Printer], ParameterBindingArgumentTransformationException
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,Remove-Printer