locked
Start-Process -Verb print printing multiple copies of PDF file RRS feed

  • Question

  • So I am working on a script that gathers info from PCs, creates a PDF document based on a template, then prints out the PDF docs. The problem is that when it prints, it prints multiple copies of the same file(s). Below is my simple command to print:

    function Print-BuildSheets ($refreshList)
    {
    	$buildSheetsToPrint = @()
    	foreach ($refreshPC in $refreshList)
    	{
    		$computerName = $refreshPC.Name
    		$buildSheet = Get-ChildItem "X:\ircstm\PCTechs\EUC Central Services\PC Refresh\Refresh_V2\Build Sheets\BuildSheet_$computerName.pdf"
    		$buildSheetsToPrint += $buildSheet
    		#Start-Process -FilePath $buildSheet -Verb print -PassThru
    	}
    	foreach ($buildSheet in $buildSheetsToPrint)
    	{
    		Start-Process -FilePath $buildSheet -Verb print -PassThru
    		#Start-Process -FilePath $buildSheet -Verb print -PassThru | % { sleep 5; $_ } | kill
    		#Start-Process -FilePath $buildSheet.fullname -Verb Print
    	}
    	
    }

    Any help is appreciated,

    Brian

    Tuesday, August 1, 2017 3:34 PM

All replies

  • Hi,

    I have do some test , below is the testing sample for your reference:

    function Print-BuildSheets ($refreshList)
    {
           $buildSheetsToPrint = @()
           foreach ($refreshPC in $refreshList)
           {
                  $computerName = $refreshPC
                  $buildSheet = Get-ChildItem "d:\$computerName.txt"
                  $buildSheetsToPrint += $buildSheet
                  #Start-Process -FilePath $buildSheet -Verb print -PassThru
           }
           foreach ($buildSheet in $buildSheetsToPrint)
           {
                  Start-Process -FilePath $buildSheet -Verb print -PassThru
                  #Start-Process -FilePath $buildSheet -Verb print -PassThru | % { sleep 5; $_ } | kill
                  #Start-Process -FilePath $buildSheet.fullname -Verb Print
           }
           
    }
    Print-BuildSheets("localhost") 


    I found a possible issue is that you might provide same variable value for the parameter $refreshList. Please confirm this before further troubleshooting!

    Best Regards, 

    Frank


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Thursday, August 3, 2017 8:00 AM
  • Hi,
    Just checking in to see if the information provided was helpful. Please let us know if you would like further assistance.

    Best Regards,

    Frank

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Wednesday, August 30, 2017 9:58 AM
  • Hi,

    Was your issue resolved? 

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.
    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.
    If no, please reply and tell us the current situation in order to provide further help.

    Best Regards,
    Frank

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Wednesday, September 6, 2017 8:08 AM