# 簡介

一個 PowerShell 腳本,用於測試 Oracle Cloud 在不同地區的延遲情況。
oci-ping-test

# 如何使用

  1. 將腳本保存到一個文件中,例如 oci-ping-test.ps1
  2. 在 PowerShell 中運行該腳本:
    .\oci-ping-test.ps1
$hostData = @{
    "Chuncheon, Korea" = "objectstorage.ap-chuncheon-1.oraclecloud.com"
    "Hyderabad, India" = "objectstorage.ap-hyderabad-1.oraclecloud.com"
    "Osaka, Japan" = "objectstorage.ap-osaka-1.oraclecloud.com"
    "Seoul, Korea" = "objectstorage.ap-seoul-1.oraclecloud.com"
    "Sydney, Australia" = "objectstorage.ap-sydney-1.oraclecloud.com"
    "Tokyo, Japan" = "objectstorage.ap-tokyo-1.oraclecloud.com"
    "Melbourne, Australia" = "objectstorage.ap-melbourne-1.oraclecloud.com"
    "Mumbai, India" = "objectstorage.ap-mumbai-1.oraclecloud.com"
    "Ashburn, VA" = "objectstorage.us-ashburn-1.oraclecloud.com"
    "Phoenix, AZ" = "objectstorage.us-phoenix-1.oraclecloud.com"
    "San Jose, CA" = "objectstorage.us-sanjose-1.oraclecloud.com"
    "Montréal, Canada" = "objectstorage.ca-montreal-1.oraclecloud.com"
    "Toronto, Canada" = "objectstorage.ca-toronto-1.oraclecloud.com"
    "Cardiff, UK" = "objectstorage.uk-cardiff-1.oraclecloud.com"
    "London, UK" = "objectstorage.uk-london-1.oraclecloud.com"
    "Amsterdam, Netherlands" = "objectstorage.eu-amsterdam-1.oraclecloud.com"
    "Frankfurt, Germany" = "objectstorage.eu-frankfurt-1.oraclecloud.com"
    "Zurich, Switzerland" = "objectstorage.eu-zurich-1.oraclecloud.com"
    "Dubai, UAE" = "objectstorage.me-dubai-1.oraclecloud.com"
    "Jeddah, Saudi Arabia" = "objectstorage.me-jeddah-1.oraclecloud.com"
    "Santiago, Chile" = "objectstorage.sa-santiago-1.oraclecloud.com"
    "Sao Paulo, Brazil" = "objectstorage.sa-saopaulo-1.oraclecloud.com"
}
$results = foreach ($location in $hostData.Keys) {
    $hostName = $hostData[$location]
    $pingResult = Test-Connection -ComputerName $hostName -Count 1 -Quiet
    if ($pingResult) {
        $pingTime = (Measure-Command { Test-Connection -ComputerName $hostName -Count 1 }).TotalMilliseconds
        [PSCustomObject]@{
            Location = $location
            HostName = $hostName
            PingTime = [Math]::Round($pingTime, 2)
        }
    } else {
        [PSCustomObject]@{
            Location = $location
            HostName = $hostName
            PingTime = "Unreachable"
        }
    }
}
$results | Sort-Object -Property PingTime | Format-Table

# 地區列表

RegionEndpointChinese Region
Chuncheon, Koreaobjectstorage.ap-chuncheon-1.oraclecloud.com春川,韓國
Hyderabad, Indiaobjectstorage.ap-hyderabad-1.oraclecloud.com海德拉巴,印度
Osaka, Japanobjectstorage.ap-osaka-1.oraclecloud.com大阪,日本
Seoul, Koreaobjectstorage.ap-seoul-1.oraclecloud.com首爾,韓國
Sydney, Australiaobjectstorage.ap-sydney-1.oraclecloud.com悉尼,澳大利亞
Tokyo, Japanobjectstorage.ap-tokyo-1.oraclecloud.com東京,日本
Melbourne, Australiaobjectstorage.ap-melbourne-1.oraclecloud.com墨爾本,澳大利亞
Mumbai, Indiaobjectstorage.ap-mumbai-1.oraclecloud.com孟買,印度
Ashburn, VAobjectstorage.us-ashburn-1.oraclecloud.com阿什本,弗吉尼亞州
Phoenix, AZobjectstorage.us-phoenix-1.oraclecloud.com鳳凰城,亞利桑那州
San Jose, CAobjectstorage.us-sanjose-1.oraclecloud.com聖何塞,加利福尼亞州
Montréal, Canadaobjectstorage.ca-montreal-1.oraclecloud.com蒙特利爾,加拿大
Toronto, Canadaobjectstorage.ca-toronto-1.oraclecloud.com多倫多,加拿大
Cardiff, UKobjectstorage.uk-cardiff-1.oraclecloud.com卡地夫,英國
London, UKobjectstorage.uk-london-1.oraclecloud.com倫敦,英國
Amsterdam, Netherlandsobjectstorage.eu-amsterdam-1.oraclecloud.com阿姆斯特丹,荷蘭
Frankfurt, Germanyobjectstorage.eu-frankfurt-1.oraclecloud.com法蘭克福,德國
Zurich, Switzerlandobjectstorage.eu-zurich-1.oraclecloud.com蘇黎世,瑞士
Dubai, UAEobjectstorage.me-dubai-1.oraclecloud.com杜拜,阿聯酋
Jeddah, Saudi Arabiaobjectstorage.me-jeddah-1.oraclecloud.com吉達,沙特阿拉伯
Santiago, Chileobjectstorage.sa-santiago-1.oraclecloud.com聖地亞哥,智利
Sao Paulo, Brazilobjectstorage.sa-saopaulo-1.oraclecloud.com聖保羅,巴西

# 腳本

這個 PowerShell 腳本會測試連接到 Oracle Cloud 基礎設施對象存儲服務在世界各地不同地區的延遲情況。它使用 Test-Connection Cmdlet 來測試每個地區的可達性和 ping 時間。

腳本首先將主機信息存儲在一個關聯數組中,該數組將位置映射到相應的主機名。然後,它遍歷這個數組,對每個位置執行 ping 測試,並將結果存儲在另一個數組中。

最後,腳本將結果按 ping 時間升序排序,並以格式化的表格形式輸出到控制台,顯示位置、主機名和 ping 時間 (如果主機不可達,則顯示 "Unreachable")。

腳本將在控制台中顯示測試結果。您可以根據需要修改 $hostData 哈希表中的主機信息,以測試其他 Oracle Cloud 基礎設施對象存儲端點。