powershell - 启 Action 业结果为 "The background process reported an error with the following message: ."

标签 powershell impersonation octopus-deploy

我有一个简单的 Powershell 脚本(正在 Octopus 部署的一个步骤中运行),我正试图以另一个用户的身份运行它。我们在以后的步骤中需要它(我们平台上的每个应用程序都以其自己的用户帐户运行,并且我需要能够在部署过程中以该用户身份运行任意脚本)。

问题是,即使是最简单的脚本也会失败并显示完全无用的错误消息,例如:

$secpasswd = ConvertTo-SecureString $OctopusParameters["runAsPassword"] -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential ($OctopusParameters["runAsUsername"] , $secpasswd)

$job = Start-Job -scriptblock {
    whoami
} -credential $credential 

$job | Receive-Job -Wait

失败并显示以下消息:

The background process reported an error with the following message: .



Octopus 触手在机器上作为具有管理员权限的域帐户运行。

我现在已经完全用尽了所有的调查途径,但我们真的需要让它发挥作用。我认为如果我们不能以某个用户身份运行部署脚本,那么我们就完蛋了。

最佳答案

将近三年后,我遇到了同样的问题……我尝试将代码写入临时文件并使用 Start-Process,但也无法使其正常工作。

最后,我将代码写入文件,然后通过 Windows 任务调度程序运行它。

关于powershell - 启 Action 业结果为 "The background process reported an error with the following message: .",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46424170/

相关文章:

.net - 在使用 select-xml 应用 XPath 表达式后,是否有可靠的方法来获取所选元素的名称

powershell - 如何在powershell的Invoke-RestMethod中转换curl命令

c# - Entity Framework 和模拟

regex - 方括号内字符的正则表达式

azure - 使用 Azure CLI 设置 Azure Function 应用程序配置时出现 ) 问题

c# - 如何使用不同的 Windows 帐户连接到 SQL Server

asp.net-mvc-2 - Web 应用程序 : Allowing super users to impersonate other users - Is there a design pattern for this?

azure-devops - VSTS + Octopus 部署?为什么我看到很多 CI/CD 设置都有这两者?

powershell - 使用经过转换的 web.config 发布后更新 Azure CSPKG

svn - TeamCity SVN 提交消息