To Learn Programming » Discussions

Simple FTP uploader : PowerShell Script

  • Member
    June 28, 2017

    #Specify Directory of files that you want to upload on my case Desktop Directory

    #ftp server
    $ftp = ""
    $user = ""
    $pass = "yourpass"

    $webclient = New-Object System.Net.WebClient

    $webclient.Credentials = New-Object System.Net.NetworkCredential($user,$pass)

    #upload files by .txt extension or whatever you want 
    foreach($item in (dir $Dir "*.txt")){
    "Uploading $item..."
    $uri = New-Object System.Uri($ftp+$item.Name)
    $webclient.UploadFile($uri, $item.FullName)

    If u have any problem try to enable execution policy for unsigned scripts in powershell console   

    set-executionpolicy remotesigned