我有 PowerShell 脚本运行手册,我想要 azure 中的图形运行手册。
我为此附上了一个小脚本,任何人都可以帮助指导如何构建图形运行手册。
param(
[Parameter (Mandatory=$true)]
[string] $AzureResourceListParam
)
$connectionName = "AzureRunAsConnection"
try {
# Get the connection "AzureRunAsConnection "
$servicePrincipalConnection=Get-AutomationConnection -Name $connectionName
Write-Output "Logging in to Azure... $servicePrincipalConnection.TenantId"
Add-AzureRmAccount `
-ServicePrincipal `
-TenantId $servicePrincipalConnection.TenantId `
-ApplicationId $servicePrincipalConnection.ApplicationId `
-CertificateThumbprint $servicePrincipalConnection.CertificateThumbprint
} catch {
if (!$servicePrincipalConnection) {
$ErrorMessage = "Connection $connectionName not found."
throw $ErrorMessage
} else {
Write-Error -Message $_.Exception
throw $_.Exception
}
}
Write-Output "Credentials are accepted."