[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Printing PDF in PowerShell

Posted on 2011-05-02
5
Medium Priority
?
1,532 Views
Last Modified: 2012-05-11
I'm using the following cmdlet: Get-ChildItem  -path c:\temp\pdf -filter myform.pdf | Get-Content | Out-Printer to print a PDF document. For some reason it doesn't print out the PDF document properly, it prints is out in ASCII format or garbage. I'm I missing something?
0
Comment
Question by:7of9121098
  • 3
  • 2
5 Comments
 
LVL 14

Expert Comment

by:Dhiraj Mutha
ID: 35509988
Try this, it will print all the pdf in the folder.

Dir D:\test\*.pdf | Foreach-Object { Start-Process -FilePath $_.FullName –Verb Print }

If you want a specific pdf, try this.

Dir D:\test\myform.pdf | Foreach-Object { Start-Process -FilePath $_.FullName –Verb Print }

0
 

Author Comment

by:7of9121098
ID: 35514592
Hi pspqlb, it worked perfect, you get the points, one quick question. I got the following cmdlet that displays a list of printers on a server from a workstation. It prompts me for a username and password. Is is possible to empbedded the username and password in the cmdlet statement?
If so how, thanks.

$server= "myserver"
Get-WMIObject Win32_Printer -ComputerName $server -credential
(Get-Credential) | foreach-object{$_.Name}


0
 
LVL 14

Accepted Solution

by:
Dhiraj Mutha earned 500 total points
ID: 35683250
0
 

Author Closing Comment

by:7of9121098
ID: 35690875
Thanks.
0
 
LVL 14

Expert Comment

by:Dhiraj Mutha
ID: 35712796
Thanks for the grade.
0

Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
In this post, I will showcase the steps for how to create groups in Office 365. Office 365 groups allow for ease of flexibility and collaboration between staff members.
Loops Section Overview
Screencast - Getting to Know the Pipeline

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question