AppSync:如何使用 Powershell 创建 REST API 脚本以连接到 AppSync 服务器
Summary: 本知识库文章的目的是提供一个示例 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 服务器,并返回与在服务器上创建的所有服务计划相关的详细信息。这是一个简化的示例,应进行修改以满足每个用户的特定要求。
add-type @“
使用 System.Net;
使用 System.Security.Cryptography.X509Certificates;
公共类 TrustAllCertsPolicy :ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
“@
#Get Login creds and target server
$user = Read-Host 'Enter the Appsync Administrator User Id'
$pass = Read-Host 'Enter the Appsync Administrator Password'
$ashost = Read-Host 'Enter the name or IP address of the Appsync Server'
#create Login 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 session
#Login 到 CAS 服务器
$form = $request。表格[0]
$form。Fields[“username”] = $user
$form.Fields[“password”] = $pass
[string] $loginuri = “https://” + $ashost + “:8444/cas-server/login”+ $form。Action
$request = Invoke-WebRequest -Uri $loginuri -SessionVariable session -Body $form。字段
#Execute Rest request
$url= “https://”+ $ashost + “:8445/appsync/rest/types/servicePlan/instances”
$restrequest = Invoke-RestMethod -method GET -Uri $url -WebSession $session -outfile .\output1.xml
add-type @“
使用 System.Net;
使用 System.Security.Cryptography.X509Certificates;
公共类 TrustAllCertsPolicy :ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
“@
#Get Login creds and target server
$user = Read-Host 'Enter the Appsync Administrator User Id'
$pass = Read-Host 'Enter the Appsync Administrator Password'
$ashost = Read-Host 'Enter the name or IP address of the Appsync Server'
#create Login 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 session
#Login 到 CAS 服务器
$form = $request。表格[0]
$form。Fields[“username”] = $user
$form.Fields[“password”] = $pass
[string] $loginuri = “https://” + $ashost + “:8444/cas-server/login”+ $form。Action
$request = Invoke-WebRequest -Uri $loginuri -SessionVariable session -Body $form。字段
#Execute Rest request
$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.