Created
September 5, 2019 17:24
-
-
Save joshooaj/ffd8c915c628c1655ff73236d6608e35 to your computer and use it in GitHub Desktop.
MilestonePSTools snapshot example for IPVM forum post
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
function ReplaceInvalidFilenameChars { | |
param( | |
[string] | |
$text, | |
[string] | |
$substition | |
) | |
foreach ($c in [System.IO.Path]::GetInvalidFileNameChars()) { | |
$text = $text.Replace($c, $substition) | |
} | |
return $text | |
} | |
function ReplaceInvalidPathChars { | |
param( | |
[string] | |
$text, | |
[string] | |
$substition | |
) | |
foreach ($c in [System.IO.Path]::GetInvalidPathChars()) { | |
$text = $text.Replace($c, $substition) | |
} | |
return $text | |
} | |
Connect-ManagementServer | |
foreach ($recorder in Get-RecordingServer) { | |
$cameras = $recorder | Get-Hardware | Where-Object Enabled | | |
Get-Camera | Where-Object Enabled | |
foreach ($camera in $cameras) { | |
$fileName = ReplaceInvalidFilenameChars "$($camera.Name).jpg" "-" | |
$path = ReplaceInvalidPathChars "C:\snapshots\$($recorder.Name)" "-" | |
if (-not (Test-Path $path)) { | |
New-Item $path -ItemType Directory | |
} | |
$camera | Get-Snapshot -Path $path -FileName $fileName -Live -Save | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment