Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: Powershell WebDav protocol error message 405 Method Not Allowed"

Your WebDAV server probably does not run on HTTP root, but in some subfolder only, like /webdav.

So you need to add RootPath = "/webdav" to your $sessionOptions.

See https://winscp.net/eng/docs/library_sessionoptions#rootpath
WinBoog

Powershell WebDav protocol error message 405 Method Not Allowed"

I need to make a powershell script to put files with Webdev. I generated the code from the GUI (file transfer worked ok with GUI) and added some code. Get error message: 405 Method Not Allowed"
This is the script:
# 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)
    }
}