无法将一种类型的值转换为另一种类型

无法将一种类型的值转换为另一种类型
$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

相关内容