troubleshooting Question

Print .PDF files using command start-procces in ascending order of their names (values)

Avatar of nesher13
nesher13Flag for Israel asked on
PowershellScripting Languages
14 Comments1 Solution298 ViewsLast Modified:
Hi folks,

There is script

$ex = New-Object -ComObject Excel.Application
$ex.Visible = 1
$wb = $ex.Workbooks.Open("C:\users\143\Documents\Hoveret-3-Eli.xlsx")

$ws = $wb.Worksheets.Item(1)

$result = @()

[int]$rmax = $ws.Range("G65536").End(-4162).Row
$ws.Range("G3:G$rmax") | Where {$_.Value2} | Foreach {
      $col = $_.Column+1
      $row = $_.Row
      $val = $ws.Cells.Item($row,$col)
      
            $result += [psobject]@{      
            Invoices = [System.Convert]::ToString($_.Value2)
            Values = $val.Value2
      }
}

$result | Where {!$_.Values} | Foreach {Start-Process -FilePath "s:\INVOICES\0070\$($_.Invoices).pdf" –Verb Print }  
$ex.Quit()

how can I do so that the files are printed in ascending order of their names. (Eg 11.pdf, 13.pdf, 28.pdf)?
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 14 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 14 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros