Trying to run a command in a changing command prompt
Trying to run a command in a changing command prompt
I'm writing a powershell script that remotely gets the workspace info on a remote computer's TFS.
What I need to do is either invoke-command or psexec the path of the batch file to open up the visual studio dev command prompt, and then run a command inside that prompt. What I'm having trouble with is executing the second command inside the dev command prompt. What is happing right now is I'm able to open the dev command prompt, but only when I exit it does the second command run. Below is some code I was trying.
.
Invoke-Command -ComputerName computer1 {cmd /k '"C:Program Files (x86)Microsoft Visual Studio2017EnterpriseCommon7ToolsLaunchDevCmd.bat" & tf'}
^ I get a tf is not recognized, which it isn't when in a normal command prompt. If it ran in the dev prompt I'd get some version info and help commands.
.
@echo off
"C:UsersmeDownloadsPSToolsPsExec.exe" \computer1 cmd /c "C:Program Files (x86)Microsoft Visual Studio2017EnterpriseCommon7ToolsLaunchDevCmd.bat" & "tf"
^ This opens the dev prompt, and upon exiting it gives an error that tf is not a command.
.
What I want to do is: Normal Prompt > Dev Prompt > Run Command > Leave Both. Is this possible? Is there a way to just start at the dev prompt?
tf
The full command I want to run is
tf workspaces /collection:{url}
, I'm just using tf
to see if the command is running in the VS prompt or the normal one. @Bill_Stewart– Michael
yesterday
tf workspaces /collection:{url}
tf
But why do you need to run that command?
– Bill_Stewart
yesterday
The reason for that command is to get the different workspaces of a list of remote computers and update an excel file with the found information. Why I want to do that is because sometimes jenkins will mess up and run builds in the wrong workspace after a new slave agent is added/new build project starts. Rather than having to login to the computer I'd prefer to be able to fix it by deleting the workspace remotely, as well as being able to confirm that all the projects are tied to the correct computer if possible. @Bill_Stewart
– Michael
yesterday
If you want run
tf workspace
you don't need this way: Normal Prompt > Dev Prompt, you can use the tf.exe tool.– Shayki Abramczyk
yesterday
tf workspace
1 Answer
1
You could invoke tf.exe command in your powershell directly:
PS> & "$env:Program Files (x86)Microsoft Visual Studio2017\Common7IDECommonExtensionsMicrosoftTeamFoundationTeam Explorertf.exe" @("workspace", "/new", "xxx", "/noprompt", "/login:xxx,xxx", "/collection:xxx")
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Why do you need to run the
tf
command on a remote computer?– Bill_Stewart
yesterday