我正在尝试使用PowerShell任务并使用inline模式在Azure DevOps管道中执行以下PowerShell脚本。
$clientId= "xxxxxxxxx"
$clientSecret= "xxxxxxx"
$subscriptionId= "xxxxxxxx"
$tenantId= "xxxxxxxxxxxxx"
# sign in
Write-Host "Logging in...";
$SecurePassword = $clientSecret | ConvertTo-SecureString -AsPlainText -Force
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $clientId, $SecurePassword
Connect-AzAccount -ServicePrincipal -Credential $cred-Tenant $tenantId
# set azure context with subscriptionId
Set-AzContext -SubscriptionId $subscriptionId
# select subscription
Write-Host "Selecting subscription '$subscriptionId'";
Select-AzSubscription -SubscriptionId $subscriptionId;
但是我遇到了以下错误:
Connect-AzAccount:未识别该术语“Connect-AzAccount”,这可能是一个cmdlet、函数、脚本文件或可执行程序的名称。请检查名称的拼写,或者如果包含路径,请验证路径是否正确并重试。