Creating a directory on remote FTP using powershell Creating a directory on remote FTP using powershell powershell powershell

Creating a directory on remote FTP using powershell


I use function Create-FtpDirectory

function Create-FtpDirectory {  param(    [Parameter(Mandatory=$true)]    [string]    $sourceuri,    [Parameter(Mandatory=$true)]    [string]    $username,    [Parameter(Mandatory=$true)]    [string]    $password  )  if ($sourceUri -match '\\$|\\\w+$') { throw 'sourceuri should end with a file name' }  $ftprequest = [System.Net.FtpWebRequest]::Create($sourceuri);  $ftprequest.Method = [System.Net.WebRequestMethods+Ftp]::MakeDirectory  $ftprequest.UseBinary = $true  $ftprequest.Credentials = New-Object System.Net.NetworkCredential($username,$password)  $response = $ftprequest.GetResponse();  Write-Host Upload File Complete, status $response.StatusDescription  $response.Close();}

Taken from Ftp.psm1 where you can find also other functions for FTP.

To others: sorry for not following well known verb-noun pattern. ;)