Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. <#
  2. .Synopsis
  3. Uploads file via FTP.
  4. .Parameter path
  5. URL of file to upload.
  6. .Parameter credentials
  7. Log-in credentials.
  8. #>
  9. function Set-FtpFile {
  10. [CmdletBinding()]
  11. param(
  12. [Parameter(Mandatory = $true)]
  13. [string] $path,
  14. [Parameter(Mandatory = $true, ValueFromPipeline = $true)]
  15. [String[]] $content,
  16. [Parameter(Mandatory = $false)]
  17. [Net.ICredentials] $credentials
  18. )
  19.  
  20. $request = [Net.WebRequest]::Create($path)
  21. $request.Method = [Net.WebRequestMethods+Ftp]::UploadFile
  22. if ($credentials) { $request.Credentials = $credentials }
  23. Set-Request($request, $content)
  24. try {
  25. $response = $request.GetResponse()
  26. return Get-Reponse($response);
  27. } catch [Net.WebException] {
  28. throw
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement