-
Notifications
You must be signed in to change notification settings - Fork 0
/
ImageNowAutoScanner.ps1
48 lines (36 loc) · 1.52 KB
/
ImageNowAutoScanner.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
$defaultPrinter = Get-WmiObject -Query " SELECT * FROM Win32_Printer WHERE Default=$true" | select Name
# Check if ImageNow Printer is the default
if ($defaultPrinter.Name -ne "ImageNow Printer") {
Write-Error "ImageNow is not your default printer. Please fix it before proceeding."
return
}
# Check if Imagenow is open
try {
$process = Get-Process -Name "imagenow" -ErrorAction Stop
}
catch [Microsoft.PowerShell.Commands.ProcessCommandException] {
Read-Host "Imagenow (Perceptive Content) is not running, please run it and log into the system before proceeding. Press any key to continue"
return
}
$files = Get-ChildItem -Path ".\*.pdf"
if ($files.Count -le 0) {
Read-Host "No PDF files found in the current folder. Press any key to exit."
return
}
$confirmation = Read-Host "Printing $($files.Count) files to Imagenow. Do you want to proceed? [Y] or [N]?"
if ($confirmation -ne "y" -and $confirmation -ne "yes") {
Read-Host "Operation cancelled. Press any key to exit"
return
}
$intervalBetweenFiles = 5 #in seconds
# Print files
foreach ($file in $files) {
Write-Output "Printing file $file"
Start-Process -FilePath $file -Verb Print -PassThru | %{sleep $intervalBetweenFiles;$_} | kill
# Create processed folder if not exists
if (!(Test-Path -Path "Processed" -PathType Container)) {
New-Item -ItemType Directory -Name "Processed"
}
# Move items to processed folder
Move-Item -Path $file -Destination "Processed"
}