Quick Question on Printers

Hey guys, I’m just now learning Powershell as I’m the IT guy here for the company and I’m messing around with some commands. I’m still not exactly sure if I’m reading the errors correctly, so maybe someone could take a look and help me out.

We have a printer on our network, which is installed on my computer. I’m trying to print the list of get-command results and cannot do it. I see that maybe out-printer may not accept an array, is this correct? Would the results of get-command return an array, or is it just strings with line breaks? How could I even know that? I’m also trying to just send ‘Hello world’ to the printer and it won’t work either. Here is what I’ve done.

PS C:WINDOWSsystem32> $h = get-command PS C:WINDOWSsystem32> out-printer -name '10.5.14.26' -inputobject $h out-lineoutput : Settings to access printer '10.5.14.26' are not valid. At line:1 char:1 + out-printer -name '10.5.14.26' -inputobject $h + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [out-lineoutput], InvalidPrinterException + FullyQualifiedErrorId : System.Drawing.Printing.InvalidPrinterException,Microsoft.PowerShell.Commands.OutLineOutputCommand PS C:WINDOWSsystem32> out-printer -name '10.5.14.26' -inputobject 'Hello world' out-lineoutput : Settings to access printer '10.5.14.26' are not valid. At line:1 char:1 + out-printer -name '10.5.14.26' -inputobject 'Hello world' + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [out-lineoutput], InvalidPrinterException + FullyQualifiedErrorId : System.Drawing.Printing.InvalidPrinterException,Microsoft.PowerShell.Commands.OutLineOutputCommand 

Am I even close to anything here, or am I trying something not even possible? Do I need to use -inputobject? I saw that in an example so I tried it, but no dice. Also, how do I get the help page of -inputobject? I cannot pull it up just using get-help inputobject, nor get-help out-printer inputobject. Is it possible to see what that syntax does related to out-printer?

Sorry if this was a lot, but I feel I can learn a lot from this question being answered. Thanks guys!

submitted by /u/ChrispyChris92
[link] [comments]

Leave a Reply