title: Powershell script to upload a folder and all its children to the FTP server has multiple errors
body: <p>Hi I have found this script to help me copy an entire folder with all its nested content to my FTP server, which is an Azure hosted Windows Server 2012.</p>
  
  <p>Here is the script:</p>
  
  <pre><code>$a = (Get-Host).UI.RawUI
  $a.WindowTitle = "Sync Folder To Ftp"
  
  $ftp = "ftp://igtestvm1.cloudapp.net/IQS FTP Content/IQSWS"
  $localDirectory = "C:\TeamCity\buildAgent\work\8b19187411566286\IQS Web Server"
  $user = "u"
  $pass = "p"
  
  $webclient = New-Object System.Net.WebClient 
  $webclient.Credentials = New-Object System.Net.NetworkCredential($user,$pass)
  $webclient.UsePassive = $False
  $Files = get-childitem $localDirectory -recurse -force 
  foreach ($File in $Files)
  {
      $LocalFile = $File.FullName
  
      $RemoveDirectory = $LocalFile.Replace($localDirectory,"")
      $ChangeSlashes = $RemoveDirectory.Replace('\', '/')
      $RemoveSpaces = $ChangeSlashes.Trim()
      $RemoteFile = $ftp+$RemoveSpaces
      $uri = New-Object System.Uri($RemoteFile) 
      $webclient.UploadFile($uri, $LocalFile)
  
      Write-Host "Getting $File from $localDirectory" -Foreground "Red"
      Write-Host "Puting $File to $ftp" -Foreground "Yellow"
  } 
  
  Write-Host "Finished Sync to $ftp" -Foreground "Green"
  </code></pre>
  
  <p>Now i get the following errors when i run the script:</p>
  
  <pre><code>Property 'UsePassive' cannot be found on this object; make sure it exists and is settable
  
  Exception calling "UploadFile" with "2" argument(s): "The remote server returned an error: 227 Entering Passive Mode
  
  Exception calling "UploadFile" with "2" argument(s): "An exception occurred during a WebClient request.
  </code></pre>
  
  <p>How would i fix this one?</p>