CloudLink REST APIを使用したPowerShellスクリプトの例
Summary: このファイルは、教育/情報提供のみを目的としています。 PowerShellスクリプト言語を使用してCloudlinkオートメーション スクリプトを作成する際の参考として使用できます。 Dellは、このファイルがDellのお客様の環境でPowerShellスクリプトとして実行されることについて責任を負いません。 このスクリプトは、Cloudlink RestAPI呼び出しを使用して、PowerShellスクリプトからCloudlinkに登録されているマシンとそのドライブを一覧表示する方法を示しています。 スクリプトはシステムの状態を変更せず、情報を表示するだけです。 CloudLinkノード(IPアドレスで示される)へのアクセスは、「client」タイプのCloudlinkユーザーの認証情報で許可されます。 ...
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.
Symptoms
このスクリプトを使用して、CloudLink操作を自動化できます。この例では、スクリプトはCloudLink Centerに登録されているマシンを一覧表示します。
Cause
このスクリプトは、複数のCloudLink Centerを持つお客様や、PowerShellスクリプトを使用してCloudLink Centerを管理したいお客様に役立ちます。
Resolution
# 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
}
}
Affected Products
CloudLink SecureVM, CloudLinkArticle Properties
Article Number: 000202396
Article Type: Solution
Last Modified: 09 Jun 2026
Version: 7
Find answers to your questions from other Dell users
Support Services
Check if your device is covered by Support Services.