Powershell脚本中的访问被拒绝错误,用于实验室管理中使用的部署 [英] Access denied error in Powershell script for deployment used in Lab management

查看:285
本文介绍了Powershell脚本中的访问被拒绝错误,用于实验室管理中使用的部署的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello,

我使用"LabdefaultTemplate"创建了一个Lab管理版本。 xaml"

When我的powershell脚本启动了一些功能意外得到"访问被拒绝"错误。我正在使用域帐户执行powershell,该帐户也是
本地计算机管理员脚本的成员。来自powershell脚本的日志确认它正在我想要的帐户下执行。

我错过了什么吗?实验室管理运行脚本时,使用哪个帐户?是否与实验室管理代理商Test / workflow / build运行
的帐户相关?

请帮忙。

谢谢和问候

Ramu

推荐答案

我没有确切的答案,但这是我在对构建工作流和启动脚本(PowerShell,VBScript或其他)进行故障排除时采用的 方法:

I don't have an exact answer but this is the approach I take when troubleshooting Build Workflows and launching scripts (PowerShell, VBScript or otherwise):

1。建立PowerShell脚本将在其中执行的用户上下文 - 它是Controller还是Build Agent以及它们在哪台机器上运行?你已经这样做了。

1. Establish the user context your PowerShell script will be executed in - is it the Controller or the Build Agent and which user are they running as and on which machine? You have done this already.

2。打开Interactive PowerShell作为构建控制器或构建代理用户。使用类似的东西:

http: //verbalprocessor.com/2007/12/05/running-a-cmd-prompt-as-local-system/
。在构建控制器或构建代理所在的机器上以及作为构建过程中启动PowerShell脚本的机器上执行此操作。

2. Open up an Interactive PowerShell as the Build Controller or Build Agent User. Using something like ie: http://verbalprocessor.com/2007/12/05/running-a-cmd-prompt-as-local-system/. Do this on the same machine as where the Build Controller or Build Agent resides and from where your PowerShell script is being launched as part of the build.

3。现在,在交互式PowerShell中手动运行PowerShell脚本,该PowerShell作为给定计算机上的Controller / Agent 安全上下文运行。很多时候,这是因为在
依赖的PowerShell上下文中没有设置某些东西:例如'Set-ExecutionContext Unrestricted -Scope Process'或者因为你试图从网络共享,他们没有签名。或者因为TfsBuild PowerShell 配置文件与您自己的配置文件和
不同,所以您已经开始依赖其设置。有两百万种可能性。无论哪种方式,这都允许您以交互方式进行实验并对其进行故障排除,以便将其嵌入到脚本中。

3. Now run your PowerShell script manually within the interactive PowerShell that is running as the Controller/Agent security context on the given machine. A lot of the time, it's because something isn't set up in that PowerShell context that you have come to rely on: such as 'Set-ExecutionContext Unrestricted -Scope Process' or because you are trying to launch scripts from a Network Share and they aren't signed. Or because the TfsBuild PowerShell profile is different from your own Profile and you have come to rely on its settings. There's a million possibilities. Either way, this allows you to experiment interactively and troubleshoot it so you can embed it in your scripts.

我遇到的每个脚本问题(PowerShell,JScript)使用TfsBuild的,VBScript)我已经设法修复了上述方法。

Every scripting issue I've had (PowerShell, JScript, VBScript) with TfsBuild I have managed to fix with the above approach.

4。理想的解决方案是在构建过程中启动一个交互式PowerShell,但是由于Session 0 Isolation,它已经变得比它在Vista和Windows Server 2008上要难得多。你需要编写一个简单的包装应用程序
这样做。这很简单,但我从来不需要使用它,所以我不会在这里详细说明。

4. The ideal solution would be launch an interactive PowerShell as part of the build process but thanks to Session 0 Isolation this has become far harder than it should be on Vista and Windows Server 2008. You'll need to write a simple wrapper application to do this. It's easy, but I've never needed to use it so I won't elaborate here.

希望有所帮助!

Grey Ham

 


这篇关于Powershell脚本中的访问被拒绝错误,用于实验室管理中使用的部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆