Scripts/Get-iSpyAgentSystemStatus.ps1
Function Get-iSpyAgentSystemStatus { <# .SYNOPSIS Returns the system status .DESCRIPTION Returns the system status .PARAMETER iSpyHost Computer name or IP (optional, default = LOCALHOST) .PARAMETER Port Port number to access AgentDVR (optional, default = 8090) .EXAMPLE Get-iSpyAgentSystemStatus -iSpyHost MyCamsSystem .EXAMPLE Get-iSpyAgentSystemStatus -iSpyHost MyCamsSystem -Port 7000 .EXAMPLE Get-iSpyAgentSystemStatus -iSpyHost 192.168.10.20 .EXAMPLE Get-iSpyAgentSystemStatus -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-iSpyAgentSystemStatus -iSpyHost MyCamsSystem1, MyCamsSystem2, MyCamsSystem3 Get-iSpyAgentSystemStatus -iSpyHost MyCamsSystem1, MyCamsSystem2, MyCamsSystem3 -Port 7000, 8000, 9000 Get-iSpyAgentSystemStatus -iSpyHost 192.168.10.20, 192.168.10.30, 192.168.10.40 Get-iSpyAgentSystemStatus -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] Name = $Values[1] Armed = $Values[2] Devices = $Values[3] Active = $Values[4] Recording = $Values[5] RemoteAccess = $Values[6] AgentVersion = $Values[7] ServerTime = $Values[8] Status = $Values[9] } } } 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/GetStatus | ConvertFrom-Json $ServerTime = (Get-Date $Results.ServerTimeStamp).TolocalTime() Show-Output ($Computer.ToUpper(), $Results.Name, $Results.Armed, $Results.Devices, $Results.Active, $Results.Recording, $Results.RemoteAccess, $Results.Version, $ServerTime, 'Ok') } Catch { Show-Output ($Computer.ToUpper(), '', '', '', '', '', '', '', '', $PSItem.Exception.Message) } } Else { Show-Output ($Computer.ToUpper(), '', '', '', '', '', '', '', '', 'Unreachable') } $Index++ } } END {} } |