Skip to content

Instantly share code, notes, and snippets.

@spy86
Created August 3, 2017 10:10
Show Gist options
  • Save spy86/f5e20260d2b085886a6ed3ed710dbd75 to your computer and use it in GitHub Desktop.
Save spy86/f5e20260d2b085886a6ed3ed710dbd75 to your computer and use it in GitHub Desktop.
#we specify the directory where all files that we want to upload
$Dir="C:/Dir"
#ftp server
$ftp = "ftp://xxx.xxx.xxx/dir/"
$user = "user"
$pass = "Pass"
$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 "*.trc")){
"Uploading $item..."
$uri = New-Object System.Uri($ftp+$item.Name)
$webclient.UploadFile($uri, $item.FullName)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment