[英]Azure Automation Runbooks using Get-Credential without parameters
There are several Runbooks examples in the Azure Runbook Gallery, such as: Azure Runbook库中有几个Runbooks示例,例如:
that use the following syntax with Get-Credential
: 将以下语法与
Get-Credential
:
$credential = Get-Credential
which implies that the command should prompt for the credentials -- but this fails in a Runbook with the following message: 这意味着该命令应提示输入凭据-但这在Runbook中失败,并显示以下消息:
Get-Credential : Cannot process command because of one or more missing mandatory parameters: Credential.
Get-Credential:由于一个或多个缺少必需参数而无法处理命令:凭据。
The credentials that are desired here are for this purpose: 为此,此处需要使用以下凭据:
# Get credentials from user to setup administrator access to new SQL Azure Server
which then should get used in downstream cmdlet calls in the Runbook such as 然后应在Runbook的下游cmdlet调用中使用它,例如
$databaseServer = New-AzureSqlDatabaseServer -AdministratorLogin $credential.UserName `
-AdministratorLoginPassword $credential.GetNetworkCredential().Password -Location $Location
But because Get-Credential
fails the downstream calls fail. 但是由于
Get-Credential
失败,因此下游调用失败。
What I am doing wrong? 我做错了什么?
Why does a Runbook in the Gallery have statements that seem to be incompatible (prompt for Credentials) with allowable Runbook behaviors? 为什么库中的Runbook的语句似乎与允许的Runbook行为不兼容(提示输入凭据)?
So with Azure Automation, you would create a credential asset (for example, named AzureAdmin) and then you would reference that in the runbook, to get those credentials: 因此,使用Azure自动化,您将创建一个凭据资产(例如,名为AzureAdmin),然后在运行手册中对其进行引用以获取这些凭据:
$cred = Get-AutomationPSCredential -Name AzureAdmin
As for the reference script, I suppose, it was just added to the runbook gallery without any verification, so in reality its not Azure Automation friendly 对于参考脚本,我想,它是未经任何验证即被添加到Runbook库中的,因此实际上它不是Azure自动化友好的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.