Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <#
- .Synopsis
- Uploads file via FTP.
- .Parameter path
- URL of file to upload.
- .Parameter credentials
- Log-in credentials.
- #>
- function Set-FtpFile {
- [CmdletBinding()]
- param(
- [Parameter(Mandatory = $true)]
- [string] $path,
- [Parameter(Mandatory = $true, ValueFromPipeline = $true)]
- [String[]] $content,
- [Parameter(Mandatory = $false)]
- [Net.ICredentials] $credentials
- )
- $request = [Net.WebRequest]::Create($path)
- $request.Method = [Net.WebRequestMethods+Ftp]::UploadFile
- if ($credentials) { $request.Credentials = $credentials }
- Set-Request($request, $content)
- try {
- $response = $request.GetResponse()
- return Get-Reponse($response);
- } catch [Net.WebException] {
- throw
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement