Advertisement
Guest User

Untitled

a guest
Mar 27th, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. $lnum = 0
  2. $user = "username"
  3. $pass = "password"
  4. $pair = "${user}:${pass}"
  5. $bytes = [System.Text.Encoding]::ASCII.GetBytes($pair)
  6. $base64 = [System.Convert]::ToBase64String($bytes)
  7. $basicAuthValue = "Basic $base64"
  8. $headers = @{ Authorization = $basicAuthValue }
  9.  
  10. foreach($line in Get-Content \\omniavf\personel\trossi\pohjat\kalenteriautomaatio\KIRKKOKATU16A.txt) {
  11. $lnum+=1
  12. if($line -match $regex){
  13. $url = $line
  14. $Invoke-WebRequest -uri "$url" -Headers $headers
  15. $output = "\\omniavf\personel\trossi\pohjat\kalenteriautomaatio\PDF\KA16+$lnum.pdf"
  16. $start_time = Get-Date
  17.  
  18. $wc = New-Object System.Net.WebClient
  19. $Invoke-WebRequest -Uri $url -OutFile $output
  20. $wc.DownloadFile($url, $output)
  21. Write-Output "Time taken: $((Get-Date).Subtract($start_time).Seconds) second(s)"
  22.  
  23.  
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement