Created
March 28, 2016 18:49
-
-
Save micmaher/4320c09722af5c53cd0c to your computer and use it in GitHub Desktop.
FTP Module for managing Foscam Recordings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Requires -Modules PSFTP | |
Function Connect-Camera | |
{ | |
<# | |
.SYNOPSIS | |
Connects to Security Camera to get video | |
.DESCRIPTION | |
Can wipe videos or download | |
.PARAMETER Delete | |
Remove all videos | |
.PARAMETER Download | |
Downloads all videos | |
.EXAMPLE | |
Connects to camera deletes all videos | |
Connect-Camera -delete | |
.EXAMPLE | |
Connects to camera and downloads videos to C:\Downloads | |
Connect-Camera -download C:\Downloads | |
.EXAMPLE | |
With not download location specified C:\temp is assumed | |
Connect-Camera -download | |
.NOTES | |
Michael Maher on 14/2/16 | |
Requires FTP Module in place | |
.LINK | |
FTP Module available from https://gallery.technet.microsoft.com/scriptcenter/PowerShell-FTP-Client-db6fe0cb | |
#> | |
param( | |
[switch] $download, | |
[switch] $delete, | |
[string] $localDir = "c:\temp") | |
Import-Module PSFTP | |
$Camera = "VideoCamera" | |
$ftpServer = "ftp://192.168.1.1:50021" | |
$mediaFolder = "/IPCamera/" | |
$userName = "user" | |
$password = "password" | |
$SecureString = ConvertTo-SecureString $password -AsPlainText -Force | |
$PSCredential = New-Object System.Management.Automation.PSCredential ($userName, $SecureString) | |
Set-FTPConnection -Credentials $PSCredential -Server $ftpServer -Session $Camera -UseBinary | |
$Session = Get-FTPConnection -Session $Camera | |
if($download){ | |
Get-FTPChildItem -Session $Session -Path $mediaFolder -Recurse | ` | |
Get-FTPItem -Session $Session -LocalPath $localDir -RecreateFolders -Overwrite | |
} | |
if ($delete) { | |
Get-FTPChildItem -Session $Session -Path $mediaFolder -Recurse | ` | |
Remove-FTPItem -Session $Session -Recurse | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment