Skip to content

Instantly share code, notes, and snippets.

@hackerman518
Forked from harnerdesigns/Upload.ps1
Created October 2, 2019 17:58
Show Gist options
  • Save hackerman518/f8c1b2789cd2bf081f13404e5fdeddda to your computer and use it in GitHub Desktop.
Save hackerman518/f8c1b2789cd2bf081f13404e5fdeddda to your computer and use it in GitHub Desktop.

Revisions

  1. @harnerdesigns harnerdesigns revised this gist Sep 27, 2017. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions Upload.ps1
    Original file line number Diff line number Diff line change
    @@ -26,6 +26,12 @@ foreach($item in (dir $Dir "*.*")){
    #Move file to today's folder
    Move-Item $item.FullName -destination $path
    }
    #Beep When Finished
    function b($a,$b){
    [console]::beep($a,$b)
    }
    b 1000 100;
    b 1333 200;



  2. @harnerdesigns harnerdesigns created this gist Jun 13, 2017.
    31 changes: 31 additions & 0 deletions Upload.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    #Directory To Pull Files From
    $Dir="C:\foo\bar\toBeUploaded"

    #FTP site and credentials
    $ftp = "ftp://ftp.somesite.com/"
    $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 "*.*")){
    "Uploading $item..."
    $uri = New-Object System.Uri($ftp+$item.Name)
    $webclient.UploadFile($uri, $item.FullName)

    #Archive Uploaded Files By Date
    $date = (Get-Date).ToString('MM-dd-yyyy')
    $path = "C:\foo\bar\uploaded\" + $date
    #If Today's folder doesn't exist, make one.
    If(!(test-path $path))
    {
    New-Item -ItemType Directory -Force -Path $path
    }
    #Move file to today's folder
    Move-Item $item.FullName -destination $path
    }