Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement