Re: Powershell WebDav protocol error message 405 Method Not Allowed"
I have added this to the FAQ:
https://winscp.net/eng/docs/faq_root_path
https://winscp.net/eng/docs/faq_root_path
Before posting, please read how to report bug or request support effectively.
Bug reports without an attached log file are usually useless.
/webdav
.
RootPath = "/webdav"
to your $sessionOptions
.
# Parameters
$PRODUCTIE = "Ja"
$FILE = "getalladusers.csv"
$LOCALPATH = "\\data\Afdeling\filename"
$REMOTEPATH = "/webdav/import"
Write-Host "PRODUCTIE = $PRODUCTIE "
Write-Host "FILE = $FILE "
Write-Host "LOCALPATH = $LOCALPATH "
Write-host "REMOTEPATH = $REMOTEPATH"
Write-Host " "
# Load WinSCP .NET assembly
Add-Type -Path 'C:\Program Files (x86)\WinSCP\WinSCPnet.dll'
# Set up session options
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
Protocol = [WinSCP.Protocol]::Webdav
HostName = "ddd.desk.net"
PortNumber = 443
UserName = "WebDav"
Password = "32pyd-y22cq-v4ddq"
WebdavSecure = $True
}
$session = New-Object WinSCP.Session
try
{
# Connect
$session.Open($sessionOptions)
# Start Your code
$transferResult = $session.PutFiles("$LOCALPATH\$FILE", "$REMOTEPATH", $False, $transferOptions)
# Throw on any error
$transferResult.Check()
# Print results
foreach ($transfer in $transferResult.Transfers)
{
Write-Host ("Upload of {0} succeeded" -f $transfer.FileName)
}
}