Scripts/Get-iSpyAgentCameraPhoto.ps1
Function Get-iSpyAgentCameraPhoto { <# .SYNOPSIS Returns a photo frame from the specified camera (5.4.6.0+) .DESCRIPTION Returns a photo frame from the specified camera (5.4.6.0+) .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 obtain a photo frame .EXAMPLE Get-iSpyAgentCameraPhoto -iSpyHost MyCamsSystem -CameraId 1 .EXAMPLE Get-iSpyAgentCameraPhoto -iSpyHost MyCamsSystem -Port 7000 -CameraId 1, 2, 3, 4 .EXAMPLE Get-iSpyAgentCameraPhoto -iSpyHost 192.168.10.20 -CameraId 1 .EXAMPLE Get-iSpyAgentCameraPhoto -iSpyHost 192.168.10.20 -Port 7000 -CameraId 1, 2, 3, 4 .NOTES N/A .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, [Parameter (Mandatory = $True, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True, HelpMessage = 'Enter port number' ) ] [String[]]$CameraId ) 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) { Try { If ($Port) { $hPort = $Port[$Index] } If ($hPort.Length -eq 0) { $hPort = '8090' } $iSpyHostURL = -join ('http://', $iSpyHost, ":$hPort") ForEach ($Cam In $CameraId) { $ImageFile = -join ("$env:TEMP\$iSpyHost".ToUpper(), "-Cam_$Cam.jpg") $ImagePath = Split-Path -Path $ImageFile -Leaf $Results = Invoke-WebRequest -Uri $iSpyHostURL/Photo.jpg?OId=$Cam -OutFile "$ImageFile" Start $ImageFile Show-Output ($iSpyHost.ToUpper(), "Captured CameraId $Cam") } } Catch { Show-Output ($iSpyHost.ToUpper(), $PSItem.Exception.Message) } } Else { Show-Output ($iSpyHost.ToUpper(), 'Unreachable') } } END {} } |