albertwt Posted September 21, 2010 Posted September 21, 2010 (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 September 21, 2010 by albertwt
albertwt Posted September 21, 2010 Author Posted September 21, 2010 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/"
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now