Jump to content

Traversing directories and print files from the client over WebDav ?


Recommended Posts

Posted (edited)

Hi All,

 

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

 

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 ?

 

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.

 

Thanks.

Edited by albertwt
Posted

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/"

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...