Can I get the workspace that so I can properly path scripts

Dec 9, 2011 at 2:36 PM
Edited Dec 9, 2011 at 2:39 PM

I'm running a powershell script which is really just a wrapper for another powershell script.  The core script which is wrapped does the majority of the work, the wrapper script sets parameters and calls the worker script.  Can I get the path for the workspace some how? Does TFS Deployer pass it to the script?  The worker script is invoked by ./worker.ps1, but TFS Deployer is running out of the installation folder and I get the following error back because it can not find the worker script:

ERROR: The term './worker.ps1' is not recognized as the name of a cmdlet, function, sc
ERROR: ript file, or operable program. Check the spelling of the name, or if a path wa
ERROR: s included, verify that the path is correct and try again.

Thanks, Eric

Dec 9, 2011 at 11:32 PM

TFS Deployer does not pass any details of the TFS Workspace to the PowerShell script used for deployment. Your script is free to reference the TFS API to retrieve information about workspaces on the current machine however you may find it easier to get the path of the currently running PowerShell script:

$PSScriptRoot = $MyInvocation.MyCommand.Path | Split-Path

I recommend the variable name "PSScriptRoot" for consistency because this is the name of the variable PowerShell automatically populates for you if you write a PowerShell Module.

With this variable you can then easily run other scripts in the same directory like this:

& $PSScriptRoot\MyOtherScript.ps1 -SomeParameterName 'SomeValue'



Feb 17, 2012 at 3:53 PM

Excelent worked perfectly.


Thank you