AppSync: Powershell kullanarak bir AppSync sunucusuna bağlanmak için REST API komut dosyası oluşturma

Summary: Bu KB'nin amacı, AppSync sunucusuna nasıl bağlanılacağını ve XML çıktısının bir dosya olarak nasıl döndürüleceğini gösteren örnek bir Powershell REST api betiği sağlamaktır.

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

Aşağıdaki komut dosyası, herhangi bir AppSync sunucusuna bağlanmak ve sunucuda oluşturulan tüm Servis Planlarıyla ilgili ayrıntıları döndürmek için kullanılabilir. Bu basitleştirilmiş bir örnektir ve her kullanıcının özel gereksinimlerine uyacak şekilde değiştirilmelidir.

add-type @"
kullanarak System.Net;
    System.Security.Cryptography.X509Certificates kullanarak;
    public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate sertifikası,
WebRequest isteği, 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


[dize] $loginuri = "https://"      + $ashost + ":8444/cas-server/login"
$request = Invoke-WebRequest -Uri $loginuri -SessionVariable session


#Login öğesini CAS sunucusuna
$form = $request. Formlar[0]
$form. Alanlar["kullanıcı adı"] = $user
$form. Fields["password"] = $pass

[string] $loginuri = "https://"    + $ashost + ":8444/cas-server/login"+ $form. Action
 
$request = Invoke-WebRequest -Uri $loginuri -SessionVariable session -Body $form. Alanları
 
#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

AppSync

Products

AppSync
Article 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.