AppSync:如何建立 REST API 指令檔,以使用 Powershell 連線至 AppSync 伺服器
Summary: 此 KB 的目的是提供範例 Powershell REST API 指令檔,說明如何連線至 AppSync 伺服器,並以檔案形式傳回 XML 輸出。
This article applies to
This article does not apply to
This article is not tied to any specific product.
Not all product versions are identified in this article.
Instructions
下列指令檔可用於連線至任何 AppSync 伺服器,並傳回與在伺服器上建立的所有服務計劃相關詳細資料。這是一個簡化的範例,應進行修改以滿足每個使用者的特定要求。
使用 System.Net 添加類型 @“
;
使用系統.安全.密碼學.X509證書;
公開類別 TrustAllCertsPolicy:ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
“@
#Get 登入信譽和目標伺服器
$user = 讀取主機 '輸入 Appsync 系統管理員使用者 ID'
$pass = 讀取主機 '輸入 Appsync 系統管理員密碼'
$ashost = 讀取主機 '輸入 Appsync 伺服器的名稱或 IP 位址'
#create 登入 URL
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::TLS12
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
[字串] $loginuri = “https://” + $ashost + “:8444/cas-server/login”
$request = Invoke-WebRequest -Uri $loginuri -SessionVariable 會話
#Login 到 CAS 伺服器
$form = $request。表單[0]
$form。欄位 [“username”] = $user
$form。欄位[“密碼”] = $pass
[字串] $loginuri = “https://” + $ashost + “:8444/cas-server/login”+ $form。動作
$request = Invoke-WebRequest -uri $loginuri -SessionVariable session -Body $form。欄位
#Execute Rest 要求
$url= “https://”+ $ashost + “:8445/appsync/rest/types/servicePlan/instances”
$restrequest = Invoke-RestMethod -method GET -Uri $url -WebSession $session -outfile .\output1.xml
使用 System.Net 添加類型 @“
;
使用系統.安全.密碼學.X509證書;
公開類別 TrustAllCertsPolicy:ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
“@
#Get 登入信譽和目標伺服器
$user = 讀取主機 '輸入 Appsync 系統管理員使用者 ID'
$pass = 讀取主機 '輸入 Appsync 系統管理員密碼'
$ashost = 讀取主機 '輸入 Appsync 伺服器的名稱或 IP 位址'
#create 登入 URL
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::TLS12
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
[字串] $loginuri = “https://” + $ashost + “:8444/cas-server/login”
$request = Invoke-WebRequest -Uri $loginuri -SessionVariable 會話
#Login 到 CAS 伺服器
$form = $request。表單[0]
$form。欄位 [“username”] = $user
$form。欄位[“密碼”] = $pass
[字串] $loginuri = “https://” + $ashost + “:8444/cas-server/login”+ $form。動作
$request = Invoke-WebRequest -uri $loginuri -SessionVariable session -Body $form。欄位
#Execute Rest 要求
$url= “https://”+ $ashost + “:8445/appsync/rest/types/servicePlan/instances”
$restrequest = Invoke-RestMethod -method GET -Uri $url -WebSession $session -outfile .\output1.xml
Affected Products
AppSyncProducts
AppSyncArticle Properties
Article Number: 000158365
Article Type: How To
Last Modified: 18 Sept 2025
Version: 5
Find answers to your questions from other Dell users
Support Services
Check if your device is covered by Support Services.