TygerKrash
TygerKrash

Reputation: 1382

powershell script behaves differently in TeamCity

Short summary - even though Teamcity agent is setup to run under my credential and looks like it is it's still behaving as though using a less privileged account.

The build Agent service is set to run using my credential and I can see it in the services applet.

The build has a simple powershell script that loads a page in IE using the IE COM object.

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

I also have a separate command script with maps a network drive to a webDAV location.

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

Both of these run fine from the command line.

I've confirmed the scripts are executing under my account by running

echo $([Environment]::UserName)

in powershell and using the

whoami

command for the drive mapping script.

for powershell I get the error

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

for the drive mapping script I get

  "The system cannot find the drive specified."

Note I've also tried to run NET USE as part of the script to see what drives are mapped and it's not showing the drive, even if I map it manually before running the script.

Upvotes: 1

Views: 399

Answers (1)

TygerKrash
TygerKrash

Reputation: 1382

Might have just stumbled on the answer myself.

Seems running as a windows service has an impact on permissions.

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

Solution is to start the agent manually outside of the services console.

Upvotes: 1

Related Questions