Cloudlink REST API를 사용한 PowerShell 스크립트 예
Summary: 이 파일은 교육/정보용으로만 제공됩니다. PowerShell 스크립트 언어로 Cloudlink 자동화 스크립트를 작성할 때 참조로 사용할 수 있습니다. Dell은 이 파일이 Dell 고객 환경에서 PowerShell 스크립트로 실행되는 것에 대해 어떠한 책임도지지 않습니다. 이 스크립트는 Cloudlink RestAPI 호출을 사용하여 Cloudlink에 등록된 컴퓨터와 PowerShell 스크립트에서 해당 드라이브를 나열하는 방법을 보여줍니다. 스크립트는 시스템의 상태를 변경하지 않고 정보를 표시합니다. Cloudlink 노드에 대한 액세스 권한(IP 주소로 표시됨)은 '클라이언트' 유형의 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 호출을 사용하여 Cloudlink에 등록된 컴퓨터와 PowerShell 스크립트
번호의 드라이브를 나열하는 방법을 보여줍니다.
# 스크립트는 시스템의 상태를 변경하지 않고 정보를 표시합니다.
# Cloudlink 노드에 대한 액세스 권한(IP 주소로 표시됨)은 '클라이언트' 유형의 Cloudlink 사용자의 자격 증명과 함께 부여됩니다.
# 다음 부분에서는 인증서 유효성 검사, 인증서가 항상 유효합니다
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
if (-not ([System.Management.Automation.PSTypeName]'ServerCertificateValidationCallback'). 유형)
{
$certCallback = @"(
시스템 사용)
System.Net
사용 System.Net.Security
사용 System.Security.Cryptography.X509Certificates
사용 public class ServerCertificateValidationCallback
{
public static void Ignore()
{
if(ServicePointManager.ServerCertificateValidationCallback ==null)
{
ServicePointManager.ServerCertificateValidationCallback +=
delegate
(
Object obj,
X509Certificate certificate,
X509Chain 체인,
SslPolicyErrors 오류
)
{
return true;
};
}
}
"@
Add-Type $certCallback
}
[ServerCertificateValidationCallback]:ignore()
$server=''
$client_id=''$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"}
# query for the machines list
$machine_list_list_query='https://$serverport/cloudlink/rest/securevm'
$machine_list=Invoke-WebRequest -Method Get -Uri $machine_list_query -Headers $resolveSessionHeader -ContentType $Type
# list the machines on the console
Write-Host "Machine list:" -ForegroundColor 노란색
$machine_list_txt = $machine_list | ConvertFrom-Json
$machine_list_txt | FT
#For 각 시스템에서 드라이브
foreach($machine_list_txt의 $machine)
{
$drives_list = $($machine.resources)
Write-Host "$($machine.name) $($machine.ip_address) ($($machine.os_name)) group $($machine.group)" -ForegroundColor Yellow
$drives_list | FT
}
}
# 이 파일은 교육/정보용으로만 제공됩니다.
# PowerShell 스크립트 언어로 Cloudlink 자동화 스크립트를 작성할 때 참조로 사용할 수 있습니다.
# Dell은 이 파일이 Dell 고객 환경에서
PowerShell 스크립트로 실행되는 것에 대해 책임을지지 않습니다. 이 스크립트는 Cloudlink RestAPI 호출을 사용하여 Cloudlink에 등록된 컴퓨터와 PowerShell 스크립트
번호의 드라이브를 나열하는 방법을 보여줍니다.
# 스크립트는 시스템의 상태를 변경하지 않고 정보를 표시합니다.
# Cloudlink 노드에 대한 액세스 권한(IP 주소로 표시됨)은 '클라이언트' 유형의 Cloudlink 사용자의 자격 증명과 함께 부여됩니다.
# 다음 부분에서는 인증서 유효성 검사, 인증서가 항상 유효합니다
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
if (-not ([System.Management.Automation.PSTypeName]'ServerCertificateValidationCallback'). 유형)
{
$certCallback = @"(
시스템 사용)
System.Net
사용 System.Net.Security
사용 System.Security.Cryptography.X509Certificates
사용 public class ServerCertificateValidationCallback
{
public static void Ignore()
{
if(ServicePointManager.ServerCertificateValidationCallback ==null)
{
ServicePointManager.ServerCertificateValidationCallback +=
delegate
(
Object obj,
X509Certificate certificate,
X509Chain 체인,
SslPolicyErrors 오류
)
{
return true;
};
}
}
"@
Add-Type $certCallback
}
[ServerCertificateValidationCallback]:ignore()
$server=''
$client_id=''$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"}
# query for the machines list
$machine_list_list_query='https://$serverport/cloudlink/rest/securevm'
$machine_list=Invoke-WebRequest -Method Get -Uri $machine_list_query -Headers $resolveSessionHeader -ContentType $Type
# list the machines on the console
Write-Host "Machine list:" -ForegroundColor 노란색
$machine_list_txt = $machine_list | ConvertFrom-Json
$machine_list_txt | FT
#For 각 시스템에서 드라이브
foreach($machine_list_txt의 $machine)
{
$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: 13 Mar 2023
Version: 5
Find answers to your questions from other Dell users
Support Services
Check if your device is covered by Support Services.