powershell:落書き3
文書の過去の版を表示しています。
# 定義: DFビットを立ててpingを実行する関数 function Test-MTU {
param ( [string]$Target, [int]$StartMTU = 800, [int]$EndMTU = 1000 )
$results = @() for ($mtu = $StartMTU; $mtu -le $EndMTU; $mtu++) { $pingResult = Test-Connection -ComputerName $Target -Count 1 -BufferSize $mtu -DontFragment -ErrorAction SilentlyContinue if ($pingResult.StatusCode -eq 0) { $results += "MTU: $mtu - Success" } else { $results += "MTU: $mtu - Failure" } }
return $results
}
# example.comに対してMTUを800から1000の範囲でテスト $target = “example.com” $mtuResults = Test-MTU -Target $target
# 全インターフェイスのMTUおよびMRU設定を取得 $interfaces = Get-NetAdapter | Select-Object -Property Name, MacAddress, LinkSpeed, InterfaceDescription $mtuSettings = $interfaces | ForEach-Object {
$interfaceName = $_.Name $mtu = Get-NetIPInterface -InterfaceAlias $interfaceName | Select-Object -ExpandProperty NlMtu [PSCustomObject]@{ Interface = $interfaceName MTU = $mtu }
}
# 結果をファイルに書き出し $logFile = “mtu-result.txt” $mtuResults | Out-File -FilePath $logFile Add-Content -Path $logFile -Value “`nCurrent MTU Settings:`n” $mtuSettings | Format-Table -AutoSize | Out-String | Add-Content -Path $logFile
Write-Host “Results saved to $logFile”
powershell/落書き3.1720147975.txt.gz · 最終更新: 2024/07/05 02:52 by 133.106.51.50