简体   繁体   English

适用于 PowerShell 7 的 Azure 自动化混合工作者 Get-AutomationPSCredential

[英]Azure Automation Hybrid-Worker Get-AutomationPSCredential for PowerShell 7

We are moving a few Azure Automation Hybrid-worker scripts to PowerShell 7.1.我们正在将一些 Azure 自动化混合工作器脚本移至 PowerShell 7.1。 In doing so one of the commands that work in PowerShell 5.1 is: [PSCredential] $AutomationCredential = Get-AutomationPSCredential -Name 'abcdef' .为此,在 PowerShell 5.1 中工作的命令之一是: [PSCredential] $AutomationCredential = Get-AutomationPSCredential -Name 'abcdef' When we try the same command in PowerShell 7.1 we get an error The 'Get-AutomationPSCredential' command was found in the module 'Orchestrator.AssetManagement.Cmdlets', but the module could not be loaded. For more information, run 'Import-Module Orchestrator.AssetManagement.Cmdlets'当我们在 PowerShell 7.1 中尝试相同的命令时,我们收到错误The 'Get-AutomationPSCredential' command was found in the module 'Orchestrator.AssetManagement.Cmdlets', but the module could not be loaded. For more information, run 'Import-Module Orchestrator.AssetManagement.Cmdlets' The 'Get-AutomationPSCredential' command was found in the module 'Orchestrator.AssetManagement.Cmdlets', but the module could not be loaded. For more information, run 'Import-Module Orchestrator.AssetManagement.Cmdlets'

We have added the Import-Module to the code but we get Could not load file or assembly 'JobRuntimeData.Client, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified我们已将导入模块添加到代码中,但我们得到Could not load file or assembly 'JobRuntimeData.Client, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified Could not load file or assembly 'JobRuntimeData.Client, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified . Could not load file or assembly 'JobRuntimeData.Client, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified

We do find Orchestrator.AssetManagement.Cmdlets the on the hybrid-worker, in the sandbox area.我们确实在沙盒区域中的混合工作器上找到 Orchestrator.AssetManagement.Cmdlets。 We know that this module is loaded when the hybrid-worker is installed ( https://docs.microsoft.com/en-us/azure/automation/shared-resources/modules#internal-cmdlets ).我们知道这个模块是在安装 hybrid-worker 时加载的 ( https://docs.microsoft.com/en-us/azure/automation/shared-resources/modules#internal-cmdlets )。

Based on the Microsoft official document基于微软官方文档

The 'Get-AutomationPSCredential is currently supported till Azure powershell 6.6.0 'Get-AutomationPSCredential目前支持直到Azure powershell 6.6.0

在此处输入图片说明

NOTE : Powershell 7.1 is still in preview so this may be the reason for the error .注意:Powershell 7.1 仍处于预览阶段,所以这可能是错误的原因。

Please refer this MS DOC for more information.请参阅此MS DOC以获取更多信息。

We are assuming the Orchestrator.AssetManagement.Cmdlets is bugged at this point, but have not found anything to say that it is.我们假设Orchestrator.AssetManagement.Cmdlets在这一点上被窃听,但没有发现任何可以说它是。 To get around it we were going to use a runbook variable to store the password, but it needs the cmdlet to actually decode a secret/hidden value.为了解决这个问题,我们将使用 Runbook 变量来存储密码,但它需要 cmdlet 来实际解码秘密/隐藏值。

In the end, we used a key vault to store the password.最后,我们使用密钥保管库来存储密码。 The following is what was used as a workaround.以下是用作解决方法的内容。

$User = "AutomationUser"
$KeyVaultName = "KeyVault"
try {
    $Password = (ConvertTo-SecureString (Get-AzKeyVaultSecret -VaultName $KeyVaultName -Name $User -AsPlainText) -AsPlainText -Force)
    [PSCredential] $AutomationCredential = New-Object System.Management.Automation.PSCredential($User, $Password)
}
catch {
    $ErrorMessage = "Unable to retrieve credentials for user: [${$User}].  $_"
    throw $ErrorMessage
    BREAK
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Get-AutomationPSCredential 在 Azure Function App 中不可用 - Get-AutomationPSCredential not Available within Azure Function App 如何从 PowerShell 为 Azure 自动化运行手册创建自动化计划以在混合工作器上运行? - How to create automation schedule for Azure Automation Runbook from PowerShell to be run on Hybrid Worker? 无法使用 Azure Automation 在 Hybrid Worker 上运行浏览器自动化 - Can not run browser automation with head on hybrid worker using Azure Automation 无法在Azure自动化混合工作器上运行远程会话 - Cannot run remote session on Azure Automation hybrid worker 如何将VM添加到多个Azure Automation Hybrid Worker组 - How to add a vm to multiple azure automation hybrid worker group 使用来自 Azure 的 Get-VICredentialStoreItem 的 vCenter 登录失败 - vCenter logon failing using Get-VICredentialStoreItem from Azure automation runbooking with hybrid worker 有没有办法从 Azure 自动化帐户中的混合工作人员组中删除陈旧的机器工作人员? - Is there a way to delete a stale machine worker from a Hybrid Worker Group in Azure automation account? Microsoft Azure:Automation Hybrid Worker 能否用于针对不同帐户/订阅的计算机运行脚本? - Microsoft Azure : Can Automation Hybrid Worker be used to run scripts against computers on different accounts/subscriptions? Azure 自动化混合本地 Linux 工人不会接受工作 - Azure Automation Hybrid On-Prem Linux Worker won't accept jobs Azure工作者角色自动化 - Azure worker role automation
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM