Powershell command to get printer job count

I am trying to get the printer job count from a particular printer with invoke powershell activity.
Script that I am using is -
$Job = Get-PrintJob -PrinterName “abc”
$Job.count

When I run this in the powershell cmd it gives the proper value but when I try to run this with uipath it gives value of 1 when no jobs are running or if more than 1 jobs are running in the print queue and throws null reference exception for only 1 print job in the print queue.

I am storing the script in a text file and passing it as a commandtext to the invoke powershell activity. Type argument is set to Int32.

Let me know if anyone has seen this issue or a way to work around this.

I modified the script to -
$Job = Get-PrintJob -PrinterName “abc”
return $Job.count

And in UiPath get the output in a variable from invoke powershell activity, for e.g. int_jobCount
Access this value using int_jobCount(0)

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.