Forum Discussion
sohailalam
Oct 23, 2023Copper Contributor
Running remote commands in server
I have TestComplete in my Server name: TestServer and I would like Teamcity to run the TestComplete Projects which is in Server: TestServer. I did some research and found Invoke-Command -ComputerName TestServer, Local Computer -ScriptBlock {}. I am confused on how to use this and I am new to Powershell. Help is highly appreciated.
- If you want to let Teamcity run a command on testserver, you must run it on the Teamcity server. You can't do a invoke-command in a scriptblock already running on a different server.
It's difficult to get the complete picture of the work flow that you're trying to achieve 🙂
15 Replies
Sort By
You can place the commands you want to run inside the ScriptBlock part, and you can use invoke-command with the -Credential (Get-Credential) parameter to get a pop-up in which you can enter the credentials for the test server.
Please click Mark as Best Response & Like if my post helped you to solve your issue.
This will help others to find the correct solution easily. It also closes the item.
If one of the posts was helpful in other ways, please consider giving it a Like.- sohailalamCopper ContributorAs you can see I have written 2 computer names, TestServer and Local. Do I really need to write both or just TestServer? And for Credential, I should be writing the credential for TestServer right? Help is highly appreciated. Thanks
- You specify the Computer or Computers in the -Computername parameter. If you don't specify the -Computername parameter, it will run the ScriptBlock locally. Identify the computer(s) on which the -ScriptBlock command should run, use the -Computername parameter, and separate computers using commas. (See it as if you would log into that server and enter the commands manually there.)
For the Credential, you should enter the username and password for the server you want to let the Scriptblock run on. (Same credentials that you use to login to that machine I guess) Specify it like Domain\Username and password or Computername\Username and password