powershell脚本在TeamCity中的行为有所不同

时间:2015-10-06 13:55:38

标签: powershell teamcity-9.0

简短摘要 - 即使Teamcity代理设置为在我的凭据下运行,看起来它仍然表现得像使用权限较低的帐户一样。

构建代理服务设置为使用我的凭据运行,我可以在服务小程序中看到它。

构建有一个简单的powershell脚本,它使用IE COM对象在IE中加载页面。

$IE=new-object -com internetexplorer.application 
$IE.visible=$true 
$IE.navigate2("https://myurl.com/location")

我还有一个单独的命令脚本,可以将网络驱动器映射到webDAV位置。

NET USE Y:  https://myurl.com/location

这两个命令都可以正常运行。

我已确认脚本正在我的帐户下执行 通过运行

echo $([Environment]::UserName)
在powershell中使用

whoami

用于驱动器映射脚本的

命令。

对于powershell,我得到错误

new-object : Retrieving the COM class factory for component with CLSID 
{0002DF01-0000-0000-C000-000000000046} failed due to the following error:
 80080005 Server execution failed (Exception from HRESULT: 0x80080005
 (CO_E_SERVER_EXEC_FAILURE)).
 At line:1 char:5
 $IE=new-object -com internetexplorer.application
 CategoryInfo          : ResourceUnavailable: (:) [New-Object], COMException
 FullyQualifiedErrorId : NoCOMClassIdentified,Microsoft.PowerShell.Commands.NewObjectCommand

我得到的驱动器映射脚本

  "The system cannot find the drive specified."

注意我还尝试将.NET USE作为脚本的一部分运行,以查看映射了哪些驱动器,并且它没有显示驱动器,即使我在运行脚本之前手动映射它。

1 个答案:

答案 0 :(得分:0)

我可能自己偶然发现了答案。

似乎作为Windows服务运行会对权限产生影响。

https://confluence.jetbrains.com/display/TCD8/Known+Issues#KnownIssues-Windowsservicelimitations

解决方案是在服务控制台之外手动启动代理。