PowerShell Script | FTP Upload files
Sometimes we need to copy files from a Server to an FTP. In my schema I need to move files from a File Server to a FTP server.
Searching for internet I found an easy PowerShell script to do it.
#Specify the directory where all files that we want to upload $Dir="C:/Dir" #ftp Server $ftp = "ftp://ftp.contoso.com" $user ="user" $pass = "Pa$$word" $Webclient = New-Object System.Net.WebClient $Webclient.Credentials = New-Object System.Net.NetworkCredential($user,$pass) #list every sql server trace file foreach($item in (dir $Dir "*.txt")){ "Uploading $item ..." $uri = New-Object System.Uri($ftp+$item.Name) $webclient.UploadFile($uri, $item.FullName) } Remove-Item c:\Dir\*
No hay comentarios:
Publicar un comentario