CloudLink REST APIを使用したPowerShellスクリプトの例

Resumen: このファイルは、教育/情報提供のみを目的としています。 PowerShellスクリプト言語を使用してCloudlinkオートメーション スクリプトを作成する際の参考として使用できます。 Dellは、このファイルがDellのお客様の環境でPowerShellスクリプトとして実行されることについて責任を負いません。 このスクリプトは、Cloudlink RestAPI呼び出しを使用して、PowerShellスクリプトからCloudlinkに登録されているマシンとそのドライブを一覧表示する方法を示しています。 スクリプトはシステムの状態を変更せず、情報を表示するだけです。 CloudLinkノード(IPアドレスで示される)へのアクセスは、「client」タイプのCloudlinkユーザーの認証情報で許可されます。 ...

Este artículo se aplica a Este artículo no se aplica a Este artículo no está vinculado a ningún producto específico. No se identifican todas las versiones del producto en este artículo.

Síntomas

このスクリプトを使用して、CloudLink操作を自動化できます。この例では、スクリプトはCloudLink Centerに登録されているマシンを一覧表示します。

 

Causa

このスクリプトは、複数のCloudLink Centerを持つお客様や、PowerShellスクリプトを使用してCloudLink Centerを管理したいお客様に役立ちます。

 

Resolución

# Copyright Dell © 2021, 2022
# このファイルは教育/情報提供のみを目的としています。
#PowerShellスクリプト言語を使用してCloudlinkオートメーション スクリプトを作成する際の参考として使用できます。
#Dellは、このファイルがDellのお客様の環境でPowerShellスクリプトとして実行されることについて責任を負いません。

# このスクリプトは、Cloudlink RestAPI呼び出しを使用して、PowerShellスクリプトからCloudlinkに登録されているマシンとそのドライブを一覧表示する方法を示しています
#スクリプトはシステムの状態を変更せず、情報を表示するだけです。
#CloudLinkノード(IPアドレスで示される)へのアクセスは、「client」タイプのCloudlinkユーザーの認証情報で許可されます。

#次の部分は証明書の検証をモックしており、証明書は常に有効です。

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
if (-not ([System.Management.Automation.PSTypeName]'ServerCertificateValidationCallback').Type)
{
$certCallback = @"
    using System;
    using System.Net;
    using System.Net.Security;
    using System.Security.Cryptography.X509Certificates;
    public class ServerCertificateValidationCallback
    {
        public static void Ignore()
        {
            if(ServicePointManager.ServerCertificateValidationCallback ==null)
            {
                ServicePointManager.ServerCertificateValidationCallback +=
                    delegate
                    (
                        Object obj,
                        X509Certificate certificate,
                        X509Chain chain,
                        SslPolicyErrors errors
                    )
                    {
                        return true;
                    };
            }
        }
    }
"@
    Add-Type $certCallback
 }
[ServerCertificateValidationCallback]::Ignore()


$server='<cloudlink node ip>'
$client_id='<client id>'
$client_secret='<client secret>'

if ($args[0] -ne $null)
{  $server=$args[0] }

if ($args[1] -ne $null)
{  $client_id=$args[1] }

if ($args[2] -ne $null)
{  $client_secret=$args[2] }



$serverport=$server+":443"

Write-Output  "parameters: server=$server, client_id=$client_id, client_secret=$client_secret"

$responsee=Invoke-RestMethod -Uri "https://$server/cloudlink/oauth/token?grant_type=client_credentials&client_id=$client_id&client_secret=$client_secret&scope=all" -Method Get -TimeoutSec 1800
Write-Output "The response received:"
Write-Output "$responsee"



if($responsee.access_token)
{
  $mytoken=$responsee.access_token

  $Type = "application/json"
  $resolveSessionHeader = @{'Authorization' = "Bearer $mytoken"}

# マシンリストのクエリ

  $machine_list_query='https://$serverport/cloudlink/rest/securevm'
  $machine_list=Invoke-WebRequest -Method Get -Uri $machine_list_query -Headers $resolveSessionHeader -ContentType $Type

# コンソール上のマシンを一覧表示します。

  Write-Host "Machine list:" -ForegroundColor Yellow
  $machine_list_txt = $machine_list | ConvertFrom-Json
  $machine_list_txt | FT

各マシン #For、ドライブを一覧表示します。

  foreach ($machine in $machine_list_txt)
  {
    $drives_list = $($machine.resources)
    Write-Host "$($machine.name) $($machine.ip_address) ($($machine.os_name)) group $($machine.group)" -ForegroundColor Yellow
    $drives_list | FT
  }
}

 

Productos afectados

CloudLink SecureVM, CloudLink
Propiedades del artículo
Número del artículo: 000202396
Tipo de artículo: Solution
Última modificación: 09 jun 2026
Versión:  7
Encuentre respuestas a sus preguntas de otros usuarios de Dell
Servicios de soporte
Compruebe si el dispositivo está cubierto por los servicios de soporte.