2

I have a TFS Build where I run PowerShell script. The problem is PowerShell.exe never stops after runnig and do nothing. Script is signed by trusted sertificate and successfully runs on my BuildAgent from PowerShell and writes logs. But it don't to anything from build or from cmd.exe. PowerShell.exe just starts and do nothing.

P.S. PS script have Exit commands but it not help.

Thanks, Roman

2
  • It could be helpful to show how you are running your PowerShell script from TFS. Commented Jul 5, 2011 at 16:48
  • <Exec Command="Powershell.exe &quot;&amp; '$(DropLocation)\$(BuildNumber)\Release\Scripts\Post-Deployment\PostBuildTasks_Lviv.ps1' '$(DropLocation)' '$(BuildNumber)' '$(BuildDefinitionName)' 'SmartDrive' 'Release' 'Dev_GLTeam1' 'smartdrive-srv2' '$(GetVersion)'&quot;" WorkingDirectory="$(DropLocation)\$(BuildNumber)\Release"/> Commented Jul 6, 2011 at 6:38

2 Answers 2

2

You can use, Stop-Process -Id $PID from within the script to end the current PowerShell process.

Sign up to request clarification or add additional context in comments.

3 Comments

Still not working from build. I run PS script from build by <Exec Command="Powershell.exe &quot;&amp; '$(DropLocation)\$(BuildNumber)\Release\Scripts\Post-Deployment\PostBuildTasks_Lviv.ps1' '$(DropLocation)' '$(BuildNumber)' '$(BuildDefinitionName)' 'SmartDrive' 'Release' 'Dev_GLTeam1' 'smartdrive-srv2' '$(GetVersion)'&quot;" WorkingDirectory="$(DropLocation)\$(BuildNumber)\Release"/>
Is there more than one PowerShell process running during the build?
Well done @Rynant, this worked for me. I have no idea why exit at the bottom of the script was not ending the process, and returning to cmd.exe
1

The issue was resolved. Problem was security settings on BuildAgent. When I run script manually from BuildAgent user's account and choose "Run always" build starts working correctly.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.