PowerShell/scripts/print-image.ps1

28 lines
576 B
PowerShell
Raw Normal View History

2023-10-31 12:48:22 +01:00
<#
2022-05-07 15:24:52 +02:00
.SYNOPSIS
Prints an image
.DESCRIPTION
This PowerShell script shows the printer dialogue to print the given image file.
.PARAMETER Path
Specifies the path to the image file
.EXAMPLE
PS> ./print-image dog.jpg
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
param($Path = "")
try {
if ("$Path" -eq "") {
$Path = Read-Host "Enter path to the image file"
}
Start-Process -filepath $Path -verb print
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}