【发布时间】:2020-11-10 16:23:31
【问题描述】:
我希望能够使用 Az 模块从 Azure 密钥保管库中检索机密,以用于已部署到服务器并由 Windows 任务计划程序每天运行的 PowerShell 脚本。
最初,我需要遵循 oauth(猜测)过程:
Connect-AzAccount -Tenant '69a29f45-...'
重定向到https://login.microsoftonline.com/...,要求您选择一个帐户:
最终,它表示成功:
Authentication complete. You can return to the application. Feel free to close this browser tab.
完成此操作后,检索密钥的脚本将按预期工作:
...
$AccessToken = Get-AzKeyVaultSecret -VaultName 'MyVault' -Name 'MySecret' | Select-Object -ExpandProperty SecretValue | ConvertFrom-SecureString -AsPlainText
...
我担心令牌会过期,导致我的脚本失败。
SharePoint 模块 (Pnp.PowerShell) 可以make use of a credential stored in Windows Credential Manager。 Az 模块也可以这样做吗?
如果没有,是否有其他方法可以在不交互的情况下处理此身份验证过程?
【问题讨论】:
-
嗨,这个问题有什么更新吗?
标签: powershell azure-powershell powershell-core powershell-7.0