Powershell WebDav protocol error message 405 Method Not Allowed"

Advertisement

WinBoog
Joined:
Posts:
1
Location:
Amsterdam

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)
    }
}

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum