To Learn Programming » Discussions


Simple FTP uploader : PowerShell Script

  • Member
    June 28

    #Specify Directory of files that you want to upload on my case Desktop Directory
    $Dir="$home\Desktop"

    #ftp server
    $ftp = "ftp://yourftp.com/"
    $user = "username@yourftp.com"
    $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