PoshCode Archive  Artifact Content

Artifact 6525c7f9772eec376eee0637bbf6c54ff650e25d9c48ccae3c44e9ecebe6a31a:

  • File print-file.ps1 — part of check-in [55a48a4b8a] at 2018-06-10 14:24:57 on branch trunk — simple V1 function to print files, either listed, or through the pipeline. No error checking implemented (user: karl prosser size: 1088)

# encoding: ascii
# api: powershell
# title: print-file
# description: simple V1 function to print files, either listed, or through the pipeline. No error checking implemented
# version: 0.1
# type: function
# author: karl prosser
# license: CC0
# function: print-file
# x-poshcode-id: 843
# x-archived: 2016-03-06T11:35:26
# x-published: 2009-02-03T12:56:00
#
#
function print-file($file)
{
 begin  {               
    function internal-printfile($thefile)
    {    
        if ($thefile -is [string]) {$filename = $thefile } 
        else { 
                if ($thefile.FullName -is [string] ) { $filename = $THEfile.FullName } 
             }   
        $start = new-object System.Diagnostics.ProcessStartInfo $filename
        $start.Verb = "print"
        [System.Diagnostics.Process]::Start($start)                     
    }
    
if ($file -ne $null) {
                $filespecified = $true;
                internal-printfile $file
            }
       }     
process{if (!$filespecified) { write-Host process ; internal-printfile $_ } }

}