Scripts/Get-iSpyAgentCamera.ps1
Function Get-iSpyAgentCamera { <# .SYNOPSIS Returns a collection of cameras .DESCRIPTION Returns a collection of cameras .PARAMETER iSpyHost Computer name or IP (optional, default = LOCALHOST) .PARAMETER Port Port number to access AgentDVR (optional, default = 8090) .EXAMPLE Get-iSpyAgentCamera -iSpyHost MyCamsSystem .EXAMPLE Get-iSpyAgentCamera -iSpyHost MyCamsSystem -Port 7000 .EXAMPLE Get-iSpyAgentCamera -iSpyHost 192.168.10.20 .EXAMPLE Get-iSpyAgentCamera -iSpyHost 192.168.10.20 -Port 7000 .NOTES More than one host name and port can be entered, values must be seperated by commas: Get-iSpyAgentCamera -iSpyHost MyCamsSystem1, MyCamsSystem2, MyCamsSystem3 Get-iSpyAgentCamera -iSpyHost MyCamsSystem1, MyCamsSystem2, MyCamsSystem3 -Port 7000, 8000, 9000 Get-iSpyAgentCamera -iSpyHost 192.168.10.20, 192.168.10.30, 192.168.10.40 Get-iSpyAgentCamera -iSpyHost 192.168.10.20, 192.168.10.30, 192.168.10.40 -Port 7000, 8000, 9000 .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 ) BEGIN { $Index = 0 Function Show-Output ($Values) { [PSCustomObject]@{ iSpyHost = $Values[0] CameraName = $Values[1] CameraId = $Values[2] TypeId = $Values[3] Online = $Values[4] Connected = $Values[5] SourceType = $Values[6] RecordMode = $Values[7] Recording = $Values[8] Talk = $Values[9] IgnoreAudio = $Values[10] ScheduleActive = $Values[11] AlertsActive = $Values[12] Alerted = $Values[13] Function = $Values[14] DetectorActive = $Values[15] Detected = $Values[16] Width = $Values[17] Height = $Values[18] MJPEGStreamWidth = $Values[19] MJPEGStreamHeight = $Values[20] PairId = $Values[21] MinTrigger = $Values[22] MaxTrigger = $Values[23] Gain = $Values[24] PTZId = $Values[25] PTZType = $Values[26] Status = $Values[27] } } } PROCESS { ForEach ($Computer In $iSpyHost) { Show-ProgressBar -Activity 'iSpy Agent DVR' -TotalItems $iSpyHost.Count -Counter ($Index + 1) -ProcessItem $Computer.ToUpper() If (Test-Connection -ComputerName $Computer -Count 1 -Quiet) { Try { If ($Port) { $hPort = $Port[$Index] } If ($hPort.Length -eq 0) { $hPort = '8090' } $iSpyHostURL = -join ('http://', $Computer, ":$hPort") $Results = Invoke-WebRequest -Uri $iSpyHostURL/Command/GetObjects | ConvertFrom-Json ForEach ($Item In $Results.ObjectList) { Show-Output ($Computer.ToUpper(), $Item.Name, $Item.ID, $Item.TypeID, $Item.Data.Online, $Item.Data.Connected, $Item.Data.SourceType, ` $Item.RecordMode, $Item.Data.Recording, $Item.Data.Talk, $Item.Data.IgnoreAudio, $Item.Data.ScheduleActive, $Item.Data.AlertsActive, ` $Item.Data.Alerted, $Item.Function, $Item.DetectorActive, $Item.Data.Detected, $Item.Data.Width, $Item.Data.Height, ` $Item.Data.MJPEGStreamWidth, $Item.Data.MJPEGStreamHeight, $Item.PairId, $Item.Data.MinTrigger, $Item.Data.MaxTrigger, $Item.Data.Gain, ` $Item.Data.PTZId, $Item.Data.PTZType, 'Ok') } } Catch { Show-Output ($Computer.ToUpper(), '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', $PSItem.Exception.Message) } } Else { Show-Output ($Computer.ToUpper(), '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'Unreachable') } $Index++ } } END {} } |