The boss changed TFS servers and added a space in the path: D:\TFS Agent\xxx
and it's causing my powershell script to fail upon release.
We have build/release automatic integration with TFS
and I have an inline powershell task to read a file and convert it to JSON
then execute some SQL
. I had this working until this morning.
The problem is that the agent path is a system variable in TFS: $(System.DefaultWorkingDirectory)
and I'm not sure how to handle the space in the path.
I've tried this:
# Begin inline script
Param(
[string]$path,
[string]$db,
[string]$schema,
[string]$envName
)
# Create module
$formattedPath = $path -replace " ", "` ";
$conv = Get-Content -Raw -Path "$formattedPath" | ConvertFrom-Json;
But all I get is D:\TFS. The path looks like this before the replace:
D:\TFS Agent\_work\r3\a\xxx
I can't for the life of me figure out how to replace the space with a tick mark or how to ignore spaces. I'm very new to powershell so this may just be some simple thing, but my google-fu is not strong today. Any help would be appreciated. Thanks!