Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. function ReplaceInvalidFilenameChars {
  2. param(
  3. [string]
  4. $text,
  5. [string]
  6. $substition
  7. )
  8.  
  9. foreach ($c in [System.IO.Path]::GetInvalidFileNameChars()) {
  10. $text = $text.Replace($c, $substition)
  11. }
  12.  
  13. return $text
  14. }
  15.  
  16. function ReplaceInvalidPathChars {
  17. param(
  18. [string]
  19. $text,
  20. [string]
  21. $substition
  22. )
  23.  
  24. foreach ($c in [System.IO.Path]::GetInvalidPathChars()) {
  25. $text = $text.Replace($c, $substition)
  26. }
  27.  
  28. return $text
  29. }
  30.  
  31. Connect-ManagementServer
  32.  
  33. foreach ($recorder in Get-RecordingServer) {
  34. $cameras = $recorder | Get-Hardware | Where-Object Enabled |
  35. Get-Camera | Where-Object Enabled
  36. foreach ($camera in $cameras) {
  37. $fileName = ReplaceInvalidFilenameChars "$($camera.Name).jpg" "-"
  38. $path = ReplaceInvalidPathChars "C:\snapshots\$($recorder.Name)" "-"
  39. if (-not (Test-Path $path)) {
  40. New-Item $path -ItemType Directory
  41. }
  42. $camera | Get-Snapshot -Path $path -FileName $fileName -Live -Save
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement