我想在我们的TFS Release Manager环境中执行一些PowerShell脚本,这些脚本使用AzureAD模块来提供一些Azure AD组。这些脚本使用Azure Powershell任务执行。我已经安装了AzureAD模块,所以可以识别AzureAD PowerShell CmdLets。
但是,要让它们正常工作,脚本首先需要使用Connect-AzureAD CmdLet连接到AzureAD。这个CmdLet想要显示一个用于输入凭证的模式对话框,这在发布管理器任务中显然是不可能的。我也不能使用命令行参数提供凭据。我希望Connect-AzureAD以某种方式使用当前用户上下文进行连接。这个是可能的吗?
发布于 2017-09-12 22:49:30
您可以使用Connect-AzureAD的-Credential选项。
在您的AzureAD任务中,您可以使用以下代码:`
$pass=ConvertTo-SecureString $Env:password -AsPlainText -Force
$credential=New-Object PSCredential($Env:login, $pass)
Connect-AzureAD -Credential $credentialAlternatively you might get the password from a previous task in the build definition. I that case, in the **script arguments** of the task, you pass the password `-password "$(password)"` and in the `**Script** or **Script inline** you have, this time: ``
```javascriptparam(string$password)
$pass=ConvertTo-SecureString $password -AsPlainText -Force
$credential =新建-对象PSCredential($Env:login,$pass)
连接-AzureAD -Credential $credential
我通过Azure KeyVault任务从KeyVault获取密码,但如果你在本地,这可能不是你的选择。
发布于 2017-09-14 15:35:28
我们找到了答案。在official Connect-AzureAD documentation page上,它就设置在我们的面前(示例3)。
因此,我们现在使用SPN和自签名证书进行身份验证。这个很好用。
https://stackoverflow.com/questions/46176605
复制相似问题