Hi I am trying to run the "tf get" command through powershell but i always get a unexpected token error when it reaches the arugments.
I was following the instructions from this post TFS commands in PowerShell script
the line where the error is happening is
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\tf.exe" @("get", $args[$i])
where $args[$i] is an argument being entered by the user, but the script stops executing after calling the tf.exe
Could someone help me out here? Thanks.
You can't execute a command in a string without using the call operator eg &
. In PowerShell a string evaluates to a string eg:
C:\> "hello world"
hello world
You have to tell PowerShell that the string contains the name of a command using the call operator.
$tf = 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\tf.exe'
& $tf get $args[$i]
Note: when using &
the string must contain just the name of the command. Arguments should be specified separately.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.