gpt4 book ai didi

azure - 样板凭证代码,跨阶段、步骤、工作共享的方式?

转载 作者:行者123 更新时间:2023-12-03 06:20:35 24 4
gpt4 key购买 nike

Azure 管道
PowerShell 5.1

我发现自己在各个阶段、工作和步骤中创建相同的凭证代码。只是想知道是否有办法重用?

$myPass = '$(myPass)' 
$securePassword = ConvertTo-SecureString -String $myPass -AsPlainText -Force
$credential = New-Object -TypeName PSCredential -ArgumentList user1, $securePassword

Invoke-Command -ComputerName $computers -Credential $credential {
...
}

最佳答案

此命令Get-AutomationPSCredential使用 PSCredential 对象检索用户名、密码等数据以供重复使用。

示例代码片段如下:

$myCreds = Get-AutomationPSCredential -Name 'credential 
$userName = $myCreds.UserName
$securePassword = $myCreds.Password
$password = $myCreds.GetNetworkCredential().Password

关于azure - 样板凭证代码,跨阶段、步骤、工作共享的方式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75932728/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com