PowerShell ile Azure Network Performance Monitor

Ağ performansını sürekli izlemek, kullanıcı deneyimini doğrudan etkileyen gecikme ve kayıp sorunlarını proaktif olarak tespit etmenizi sağlar. PowerShell ile NPM verilerini analiz edebilirsiniz.

Ağ Bağlantısını Test Etmek

PowerShell

function Test-NetworkPath {
    param(
        [string[]]$SourceIPs,
        [string[]]$DestinationHosts,
        [int]$Port = 443
    )
    
    $results = @()
    foreach ($src in $SourceIPs) {
        foreach ($dest in $DestinationHosts) {
            $latencies = @()
            1..5 | ForEach-Object {
                $start = Get-Date
                $conn  = Test-NetConnection -ComputerName $dest -Port $Port -WarningAction SilentlyContinue
                $end   = Get-Date
                if ($conn.TcpTestSucceeded) { $latencies += ($end - $start).TotalMilliseconds }
            }
            
            $results += [PSCustomObject]@{
                Kaynak    = $src
                Hedef     = $dest
                Port      = $Port
                Basarili  = ($latencies.Count -gt 0)
                OrtGecikme = if ($latencies.Count -gt 0) { [math]::Round(($latencies | Measure-Object -Average).Average, 2) } else { $null }
                MaxGecikme = if ($latencies.Count -gt 0) { [math]::Round(($latencies | Measure-Object -Maximum).Maximum, 2) } else { $null }
            }
        }
    }
    return $results
}
 
$networkTests = Test-NetworkPath `
    -SourceIPs @("10.0.1.10","10.0.2.10") `
    -DestinationHosts @("portal.azure.com","login.microsoftonline.com","myapp.azurewebsites.net") `
    -Port 443
 
$networkTests | Format-Table -AutoSize