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...
- Oct 23, 2023If 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 🙂
sohailalam
Oct 23, 2023Copper Contributor
As 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
Oct 23, 2023
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
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
- sohailalamOct 23, 2023Copper ContributorFrom my understanding, If I run the following command,
Invoke-Command -ComputerName TestServer, Local Computer -ScriptBlock {Get Credential}, it will run the TestComplete which is in TestServer to the Local Computer? And then we only have to specify Username and Password of TestServer, right?
And what happens if I only use this Invoke-Command -ComputerName TestServer -ScriptBlock {Get Credential}, this means it will run the command in TestServer only right?
Thanks- Oct 23, 2023https://www.youtube.com/watch?v=1vUs_EO1AN4 is also lovely to watch and learn more.
- Oct 23, 2023Could you elaborate more about: "I have TestComplete in my Server name: TestServer, and I would like Teamcity to run the TestComplete Projects" What is TeamCity TestComplete exactly? How would you usually start that? That's the thing you insert in the scriptblock part.
- sohailalamOct 23, 2023Copper ContributorSo, ok Team city is an Integration Tool and whenever a build kicks off in Teamcity we want TestComplete (Testing tool which is in server: TestServer) to run the project for us which we created in Test Complete. TestComplete is installed in the server TestServer.
Thanks. I am sorry for confusion
- Oct 23, 2023Invoke-Command -ComputerName TestServer, Local Computer -Credential (Get-Credential) -ScriptBlock {
commands here
}
You specify all the parameters for Invoke-Command, and then in the -Scriptblock {} part, you put the commands you want to start on the remote machine.
By running the below command, you will only run it on the Testserver:
Invoke-Command -ComputerName TestServer -Credential (Get-Credential) -ScriptBlock {
commands here
}
https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/invoke-command?view=powershell-7.3 has good examples.