func_Test-CockpitPorts.psm1
<#
.Synopsis Extend Vitec Management tool with Powershell CmdLets .Description Provides scripting interface to Vitec Management tool .Parameter Target The target machine to test against .Example Test-CockpitPorts -Target 127.0.0.1 #> function Test-Port { param ( [Alias("Target")][string]$fTarget, [Alias("Port")][int]$fPort ) $fRes = Test-NetConnection $fTarget -Port $fPort -ErrorAction SilentlyContinue return $fRes.TcpTestSucceeded } function Global:Test-CockpitPorts { [CmdletBinding()] param ( # dns or ip of host to check [Parameter(Mandatory = $True)] [string]$Target ) $Testinfo = @( [PSCustomObject]@{Name = "gRPC Cockpit Cache port";Port = 5001;Response = $null} [PSCustomObject]@{Name = "gRPC Cockpit data store port";Port = 5002;Response = $Null} [PSCustomObject]@{Name = "PORTMAN PUBLIC API";Port = 8091;Response = "This is an API for PORTMAN"} ) foreach ($Row in $Testinfo) { $PortTest = Test-Port -Target $Target -Port $Row.Port if ($PortTest -eq "Success") { Write-Host "$($Row.Name) $($Row.Port) connection: $PortTest" -NoNewline if ($null -ne $Row.Response) { $Web = Invoke-WebRequest "http://$($Target):$($Row.port)/index.html" if ($web.Content -like "*$($Row.Response)*") { Write-Host " with expected respone" }else{ Write-Host " not expeted response" } }else{ Write-Host "" } }ELSE{ Write-Host "$($Row.Name) $($Row.Port) connection: $PortTest" } } if (1 -eq 2){ $Port = 5003 Write-Host "gRPC Cockpit RtPrice port ($Port) connection $(Test-Port -Dest $Target -port $Port)" $Port = 5004 Write-Host "gRPC Cockpit API port ($Port) connection $(Test-Port -Dest $Target -port $Port)" $Port = 8191 Write-Host "User API port ($Port) connection $(Test-Port -Dest $Target -port $Port)" $Port = 8192 Write-Host "UserAdm API port ($Port) connection $(Test-Port -Dest $Target -port $Port)" $Port = 8193 Write-Host "SSOJwt API port ($Port) connection $(Test-Port -Dest $Target -port $Port)" $Port = 8093 Write-Host "CP Advisor, public API port ($Port) connection $(Test-Port -Dest $Target -port $Port)" $Port = 8099 Write-Host "CP Advisor, private API port ($Port) connection $(Test-Port -Dest $Target -port $Port)" $Port = 8094 Write-Host "CP Customer, public API port ($Port) connection $(Test-Port -Dest $Target -port $Port)" $Port = 8097 Write-Host "CP Customer, private API port ($Port) connection $(Test-Port -Dest $Target -port $Port)" $Port = 8095 Write-Host "CP Mobile, public API port ($Port) connection $(Test-Port -Dest $Target -port $Port)" $Port = 8098 Write-Host "CP Mobile, privet API port ($Port) connection $(Test-Port -Dest $Target -port $Port)" }} |