AppSync: Sådan opretter du et REST API-script for at oprette forbindelse til en AppSync-server ved hjælp af Powershell
Summary: Formålet med denne KB er at levere et eksempel på et Powershell REST API-script, der viser, hvordan du opretter forbindelse til AppSync-serveren og returnerer XML-output som en fil.
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
Følgende script kan bruges til at oprette forbindelse til en hvilken som helst AppSync-server og returnere oplysninger om alle de serviceplaner, der er oprettet på serveren. Dette er et forenklet eksempel og bør ændres, så det passer til hver brugers specifikke krav.
add-type @"
ved hjælp af System.Net;
ved hjælp af System.Security.Cryptography.X509Certificates;
offentlig klasse TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
} }
"@
#Get Login-creds og målserver
$user = Read-Host 'Indtast AppSync-administratorbruger-id'
$pass = Read-Host 'Indtast AppSync-administratoradgangskoden'
$ashost = Read-Host 'Indtast navnet eller IP-adressen på AppSync-serveren'
#create URL-adresse
til login[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
[streng] $loginuri = "https://" + $ashost + ":8444/cas-server/login"
$request = Invoke-WebRequest -Uri $loginuri -SessionVariable session
#Login til CAS-serveren
$form = $request. Formularer[0]
$form. Felter["brugernavn"] = $user
$form. Felter["adgangskode"] = $pass
[streng] $loginuri = "https://" + $ashost + ":8444/cas-server/login"+ $form. Action
$request = Invoke-WebRequest -Uri $loginuri -SessionVariable session -Body $form. Felter
#Execute Repart-anmodningen
$url= "https://" + $ashost + ":8445/appsync/rest/types/servicePlan/instances"
$restrequest = Invoke-RestMethod -method GET -Uri $url -WebSession $session -outfile .\output1.xml
add-type @"
ved hjælp af System.Net;
ved hjælp af System.Security.Cryptography.X509Certificates;
offentlig klasse TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
} }
"@
#Get Login-creds og målserver
$user = Read-Host 'Indtast AppSync-administratorbruger-id'
$pass = Read-Host 'Indtast AppSync-administratoradgangskoden'
$ashost = Read-Host 'Indtast navnet eller IP-adressen på AppSync-serveren'
#create URL-adresse
til login[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
[streng] $loginuri = "https://" + $ashost + ":8444/cas-server/login"
$request = Invoke-WebRequest -Uri $loginuri -SessionVariable session
#Login til CAS-serveren
$form = $request. Formularer[0]
$form. Felter["brugernavn"] = $user
$form. Felter["adgangskode"] = $pass
[streng] $loginuri = "https://" + $ashost + ":8444/cas-server/login"+ $form. Action
$request = Invoke-WebRequest -Uri $loginuri -SessionVariable session -Body $form. Felter
#Execute Repart-anmodningen
$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.