Scripts/Switch-iSpyAgentAlertOff.ps1
Function Switch-iSpyAgentAlertOff { <# .SYNOPSIS Turn off alerts on the selected device .DESCRIPTION Turn off alerts on the selected device .PARAMETER iSpyHost Computer name or IP (optional, default = LOCALHOST) .PARAMETER Port Port number to access AgentDVR (optional, default = 8090) .PARAMETER CameraId The Id of the camera to trigger .PARAMETER Type Type of object: Camera, Mic (optional, default = Camera) .EXAMPLE Switch-iSpyAgentAlertOff -iSpyHost MyCamsSystem -CameraId 1 .EXAMPLE Switch-iSpyAgentAlertOff -iSpyHost 192.168.10.20 -CameraId 1 -Type Mic .EXAMPLE Switch-iSpyAgentAlertOff -iSpyHost MyCamsSystem -CameraId 1, 2, 3, 4 .EXAMPLE Switch-iSpyAgentAlertOff -iSpyHost 192.168.10.20 -CameraId 1, 2, 3, 4 .NOTES More than 1 CameraId can be entered, values must be seperated by commas .LINK N/A #> [CmdletBinding ()] Param ( [Parameter (Mandatory = $False, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True, HelpMessage = 'Enter computer name or IP' ) ] [String]$iSpyHost = 'localhost', [Parameter (Mandatory = $False, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True, HelpMessage = 'Enter port number' ) ] [String]$Port = '8090', [Parameter (Mandatory = $True, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True, HelpMessage = 'Enter camera Id' ) ] [String[]]$CameraId, [Parameter (Mandatory = $False, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True, HelpMessage = 'Enter type' ) ] [ValidateSet ('Camera', 'Mic')] [String]$Type = 'Camera' ) BEGIN { Function Show-Output ($Values) { [PSCustomObject]@{ iSpyHost = $Values[0] Status = $Values[1] } } } PROCESS { Show-ProgressBar -Activity 'iSpy Agent DVR' -TotalItems 1 -Counter 1 -ProcessItem $iSpyHost.ToUpper() If (Test-Connection -ComputerName $iSpyHost -Count 1 -Quiet) { $iSpyHostURL = -join ('http://', $iSpyHost, ":$Port") ForEach ($Camera In $CameraId) { Try { Switch ($Type) { 'Mic' { $pIndex = 1 } 'Camera' { $pIndex = 2 } } $Results = Invoke-WebRequest -Uri "$iSpyHostURL/Command/AlertOff?OId=$Camera&OT=$pIndex" | ConvertFrom-Json If ($Results.Error) { $Status = -join ('Camera ', $Camera, ' ' , $Results.Error) } Else { $Status = -join ('Camera ', $Camera, ' Alarms Off') } Show-Output ($iSpyHost.ToUpper(), $Status) } Catch { Show-Output ($iSpyHost.ToUpper(), $PSItem.Exception.Message) } } } Else { Show-Output ($iSpyHost.ToUpper(), 'Unreachable') } } END {} } |