I need some help in putting my thoughts together in a working code.
This is what I have:
1st Step: I am getting the FTP user name and password as params.
param(#define parameters
[Parameter(Position=0,Mandatory=$true)]
[string]$FTPUser
[Parameter(Position=1,Mandatory=$true)]
[string]$FTPPassword
[Parameter(Position=2,Mandatory=$true)]
[string]$Version
)
I then set these variables:
$FTPServer = "ftp.servername.com"
$SetType = "bin"
Now, I want to establish a connection. I Google'd for Syntax and found this. Not sure if this will establish a FTP connection. I am yet to test,
$webclient = New-Object System.Net.WebClient
$webclient.Credentials = New-Object System.Net.NetworkCredential($FTPUser,$FTPPassword)
This is the part I do not know how to code:
$Version
is one of my input parameter. I have a zip file in FTP as:
ftp.servername.com\builds\my builds\$Version\Client\Client.zip
I want to download that Client.zip into my local machine's (where the script is run from) "C:\myApp\$Version"
folder.
So, the FTP download will create a new sub-folder with the $version
name with in C:\myApp
for every run.
Once this is done, I also need to know how to unzip this client.zip file under C:\myApp\$Version\Client\<content of the zip file will be here>