Write-Host 'Setting SecurityProtocol to TLS 1.2 and greater' -ForegroundColor Green $protocol = [Net.SecurityProtocolType]::SystemDefault [enum]::GetNames([Net.SecurityProtocolType]) | Where-Object { # Match any TLS version greater than 1.1 ($_ -match 'Tls(\d)(\d+)?') -and ([version]("$($Matches[1]).$([int]$Matches[2])")) -gt 1.1 } | Foreach-Object { $protocol = $protocol -bor [Net.SecurityProtocolType]::$_ } [Net.ServicePointManager]::SecurityProtocol = $protocol if ($null -eq (Get-PackageSource -Name NuGet -ErrorAction Ignore)) { Write-Host 'Registering NuGet package source' -ForegroundColor Green $null = Register-PackageSource -Name NuGet -Location https://www.nuget.org/api/v2 -ProviderName NuGet -Trusted -Force } $nugetProvider = Get-PackageProvider -Name NuGet -ErrorAction Ignore $requiredVersion = [Microsoft.PackageManagement.Internal.Utility.Versions.FourPartVersion]::Parse('2.8.5.201') if ($null -eq $nugetProvider -or $nugetProvider.Version -lt $requiredVersion) { Write-Host 'Installing NuGet package provider' -ForegroundColor Green $null = Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force } if ($null -eq (Get-Module -ListAvailable PowerShellGet | Where-Object Version -ge 2.2.5)) { Write-Host 'Installing PowerShellGet 2.2.5 or greater' -ForegroundColor Green $null = Install-Module PowerShellGet -MinimumVersion 2.2.5 -Scope CurrentUser -AllowClobber -Force -ErrorAction Stop } Write-Host 'Installing MilestonePSTools' -ForegroundColor Green Install-Module MilestonePSTools -Scope AllUsers -Force -ErrorAction Stop -SkipPublisherCheck -AllowClobber Set-VmsModuleConfig -EnableTelemetry $false # Get Hardware from VMS $hardwarelist = Get-VmsCameraReport -IncludeRetentionInfo # Create Empty table object with the right headers needed for CSV Data Import $table = New-Object System.Data.DataTable [void]$table.Columns.Add("company_name") [void]$table.Columns.Add("name") [void]$table.Columns.Add("Stream 1 - Frames per second (FPS)") [void]$table.Columns.Add("Stream 1 - Bitrate") [void]$table.Columns.Add("Privacy mask") [void]$table.Columns.Add("Eigendom klant") [void]$table.Columns.Add("Serienummer") [void]$table.Columns.Add("MAC-adres") [void]$table.Columns.Add("Afbeelding") [void]$table.Columns.Add("Day-Image") [void]$table.Columns.Add("Night Image") [void]$table.Columns.Add("Day / Night Mode") [void]$table.Columns.Add("Wide Dynamic Range (WDR)") [void]$table.Columns.Add("Privacy Mask omschrijving") [void]$table.Columns.Add("Opmerkingen") [void]$table.Columns.Add("IP-adres") [void]$table.Columns.Add("Model") [void]$table.Columns.Add("Installatiedatum") [void]$table.Columns.Add("Locatie") [void]$table.Columns.Add("Montage") [void]$table.Columns.Add("Exposure Time / Shutter Speed") # Loop through the Cameralist foreach ($camera in $hardwarelist) { # Match HardwareID and fetch camera settings try { $setting = Get-VmsHardware -Id $camera.HardwareId | Get-HardwareSetting } catch { Write-Host "Failed to fetch data for Camera ID:" $camera.HardwareId } # Add data rows to table [void]$table.Rows.Add( $camera.RecorderName, $camera.HardwareName, $camera.CurrentRecordedFPS, $camera.CurrentRecordedBitrate, [int][bool]::Parse($camera.PrivacyMaskEnabled), "", $setting.SerialNumber, $camera.MAC, "", "", "", "", "", "", "", $camera.Address.TrimStart('http://').TrimEnd('/'), $camera.Model, "", "", "", "") } # Output table try { $table | Export-Csv -Path .\export.csv -NoTypeInformation Write-Host "Export created" Disconnect-Vms } catch { Write-Host "Failed writing file." Disconnect-Vms }