Announcement

Collapse
No announcement yet.

Using Powershell 2.0 to traverse directory and print files on the client ?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using Powershell 2.0 to traverse directory and print files on the client ?

    Hi All,

    I'd like to know if this is possible Using Powershell 2.0 to traverse directory and print files on the client side printer ?

    i got the below powershell script it works great over the shared network drive but how to actually modify and use it in WebDav folders ?

    Thanks.

    Printing script which works for shared network folder but not WebDAV

    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 $_ } }
    }

    #dir *.pdf -r | print-file
    Script for testing the webdav protocol in use, it returns True
    function Test-WebDav ()
    {
    param ( $Url = "$( throw 'URL parameter is required.')" )
    $xhttp = New-Object -ComObject msxml2.xmlhttp
    $xhttp.open("OPTIONS", $url, $false)
    $xhttp.send()
    if ( $xhttp.getResponseHeader("DAV") ) { $true }
    else { $false }
    }

    Test-WebDav "http://vmws02.domain.com/"
    Last edited by Albertwt; 21st September 2010, 07:39.

  • #2
    Re: Using Powershell 2.0 to traverse directory and print files on the client ?

    the scenario is like this: I have a directories in the server which has got multiple PDF files and the client would like to print it using the printer on their machine which is of course only accessible using webdav protocol.

    Comment

    Working...
    X