diff --git a/Scripts/print-image.ps1 b/Scripts/print-image.ps1 new file mode 100644 index 00000000..e4619000 --- /dev/null +++ b/Scripts/print-image.ps1 @@ -0,0 +1,27 @@ +<# +.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 +}