print-file (modification of post by view diff)
embed code: <script type="text/javascript" src="http://PoshCode.org/embed/843"></script>download | new post
simple V1 function to print files, either listed, or through the pipeline. No error checking implemented
- 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 $_ } }
- }
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.
PowerShell Code Repository