Functions/Get-PrinterDetails.ps1
function Get-PrinterDetails { [CmdletBinding()] param ( [Parameter()] [string] $Name ) $printers = Get-Printer if ($Name) { $printers = $printers | Where-Object Name -EQ $Name } $Result = @() foreach ($p in $printers) { $PortDetails = Get-PrinterPort -Name $p.PortName -ea 0 # $PrinterProperties = Get-PrinterProperty -PrinterName $p.Name $obj = [PSCustomObject]@{ PrinterName = $p.Name ComputerName = $p.ComputerName PrinterType = $p.Type PrinterShareName = $p.ShareName PrinterPortName = $p.PortName PrinterDriverName = $p.DriverName PrinterLocation = $p.Location PrinterComment = $p.Comment PrinterPrintProcessor = $p.PrintProcessor PrinterDatatype = $p.Datatype PrinterShared = $p.Shared PrinterPublished = $p.Published PrinterDeviceType = $p.DeviceType PrinterPrinterStatus = $p.PrinterStatus Name = $PortDetails.Name PortDescription = $PortDetails.Description PortMonitor = $PortDetails.PortMonitor PrinterHostAddress = $PortDetails.PrinterHostAddress PrinterHostIP = $PortDetails.PrinterHostIP Protocol = $PortDetails.Protocol } $Result += $obj # Get-PrinterDriver # Get-PrintConfiguration -PrinterName $p.Name } return $Result } $scriptblock = { param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters) $o = Get-Printer | Where-Object { $_.Name -like "$wordToComplete*" } $o.Name | ForEach-Object { if ($_ -match " ") { "'$_'" } else { $_ } } } Register-ArgumentCompleter -CommandName Get-PrinterDetails -ParameterName Name -ScriptBlock $scriptblock |