使用 Cloudlink REST API 的 PowerShell 脚本示例
Resumo: 此文件仅用于教育/信息目的。 在使用 PowerShell 脚本语言编写 Cloudlink 自动化脚本时,可以用作参考。 对于此文件在戴尔客户环境中作为 PowerShell 脚本执行,戴尔不承担任何责任 该脚本显示使用 Cloudlink RestAPI 调用从 PowerShell 脚本中列出已注册 Cloudlink 及其驱动器的计算机的方法。 该脚本不会更改任何系统的状态,只需显示信息即可。 使用类型为“client”的 Cloudlink 用户的凭据授予对 Cloudlink 节点(由 IP 地址指示)的访问权限。 ...
Este artigo aplica-se a
Este artigo não se aplica a
Este artigo não está vinculado a nenhum produto específico.
Nem todas as versões do produto estão identificadas neste artigo.
Sintomas
该脚本可用于自动执行 Cloudlink 操作。在此示例中,脚本列出了在 Cloudlink Center 中注册的计算机。
Causa
对于拥有多个 Cloudlink Center 或希望使用 PowerShell 脚本管理 Cloudlink Center 的客户,该脚本可能非常有用。
Resolução
# 版权所有 Dell © 2021, 2022
# 此文件仅用于教育/信息目的。
#在使用 PowerShell 脚本语言编写 Cloudlink 自动化脚本时,可以用作参考。
#对于在戴尔客户环境中
作为 PowerShell 脚本执行的此文件,戴尔不承担任何责任。 脚本显示了一种方法,用于使用 Cloudlink RestAPI 调用从 PowerShell 脚本
# 列出注册有 Cloudlink 的计算机及其驱动器。
#该脚本不会更改任何系统的状态,只需显示信息即可。
#使用类型为“client”的 Cloudlink 用户的凭据授予对 Cloudlink 节点(由 IP 地址指示)的访问权限。
#以下部分将模拟证书验证,证书始终有效
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
if (-not ([System.Management.Automation.PSTypeName]'ServerCertificateValidationCallback')。Type)
{
$certCallback = @“
,使用系统;
使用 System.Net;
使用 System.Net.Security;
使用 System.Security.Cryptography.X509 认证;
公共类 ServerCertificateValidationCallback
{
公共静态无效 忽略()
{
if(ServicePointManager.ServerCertificateValidationCallback ==null)
{
ServicePointManager.ServerCertificateValidationCallback +=
delegate
(
Object obj,
X509Certificate 证书,
X509Chain 链,
SslPolicyErrors 错误
)
{
返回 true;
};
} }
}
“@
Add-Type $certCallback
}
[ServerCertificateValidationCallback]:::ignore()
$server=''
$client_id=''$client
_secret=''if ($args'
$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”
写入输出 “参数: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 grant_type=$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
# 列出控制台
上的计算机
写入主机“计算机列表:” -前台Color黄色
$machine_list_txt = $machine_list |ConvertFrom-Json
$machine_list_txt |FT
#For每台计算机, 列出驱动器
前缀($machine在 $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
}
}
# 此文件仅用于教育/信息目的。
#在使用 PowerShell 脚本语言编写 Cloudlink 自动化脚本时,可以用作参考。
#对于在戴尔客户环境中
作为 PowerShell 脚本执行的此文件,戴尔不承担任何责任。 脚本显示了一种方法,用于使用 Cloudlink RestAPI 调用从 PowerShell 脚本
# 列出注册有 Cloudlink 的计算机及其驱动器。
#该脚本不会更改任何系统的状态,只需显示信息即可。
#使用类型为“client”的 Cloudlink 用户的凭据授予对 Cloudlink 节点(由 IP 地址指示)的访问权限。
#以下部分将模拟证书验证,证书始终有效
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
if (-not ([System.Management.Automation.PSTypeName]'ServerCertificateValidationCallback')。Type)
{
$certCallback = @“
,使用系统;
使用 System.Net;
使用 System.Net.Security;
使用 System.Security.Cryptography.X509 认证;
公共类 ServerCertificateValidationCallback
{
公共静态无效 忽略()
{
if(ServicePointManager.ServerCertificateValidationCallback ==null)
{
ServicePointManager.ServerCertificateValidationCallback +=
delegate
(
Object obj,
X509Certificate 证书,
X509Chain 链,
SslPolicyErrors 错误
)
{
返回 true;
};
} }
}
“@
Add-Type $certCallback
}
[ServerCertificateValidationCallback]:::ignore()
$server=''
$client_id=''$client
_secret=''if ($args'
$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”
写入输出 “参数: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 grant_type=$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
# 列出控制台
上的计算机
写入主机“计算机列表:” -前台Color黄色
$machine_list_txt = $machine_list |ConvertFrom-Json
$machine_list_txt |FT
#For每台计算机, 列出驱动器
前缀($machine在 $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
}
}
Produtos afetados
CloudLink SecureVM, CloudLinkPropriedades do artigo
Número do artigo: 000202396
Tipo de artigo: Solution
Último modificado: 13 mar. 2023
Versão: 5
Encontre as respostas de outros usuários da Dell para suas perguntas.
Serviços de suporte
Verifique se o dispositivo está coberto pelos serviços de suporte.