Upload file to webdav using Powershell

This is small powershell script to upload a file from your local disk to a webdav server. It is also proxy capable.

#Complete path of the file to be uploaded
$file = "d:\test_file.txt"
#URL without the last "/"
$url  = "https://YOUR-SERVER/webdav"
$proxy = "http=PROXY-SERVER:PORT"  
#User and Pwd for Webdav Access
$user = "USERNAME"
$pass = "PASSWORD"
$url += "/" + $file.split('\')[(($file.split("\")).count - 1)]

# Set binary file type
Set-Variable -name adFileTypeBinary -value 1 -option Constant 
$objADOStream = New-Object -ComObject ADODB.Stream
$objADOStream.Type = $adFileTypeBinary
$buffer = $objADOStream.Read()
$objXMLHTTP = New-Object -ComObject MSXML2.ServerXMLHTTP
$objXMLHTTP.setProxy(2, $proxy,"")
$objXMLHTTP.Open("PUT", $url, $False, $user, $pass)