TFS Get Workspaces With Pending Changes on PowerShell

I'm new at TFS, trying to get all the TFS workspaces with it's pending changes in local machine on PowerShell for administrative purpose.

I know you can get the workspaces using:

tf vc workspaces

And the something similar with pending changes:

tf vc  status

But, How can i get each workspaces with it's pending changes?

Thank you.

Upvotes: 2

Views: 1447

Answers (1)

Andy Li-MSFT
Andy Li-MSFT

Reputation: 30372

You can use below PowerShell script to get each workspace with it's pending changes:

#Set-Alias tf "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\TF.exe" #For VS 2017

Set-Alias tf "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\TF.exe" #For Visual Studio 2015

Write-Host "Workspaces in current local machine:`n" 

tf workspaces

Write-Host "`n`nPending changes for each workspace:"

ForEach ($workspace in tf workspaces | Foreach {"$(($_ -split '\s+',2)[0])"} | select-string -Pattern 'Collection:|Workspace|""|----------------' -NotMatch )
{

Write-Host "Workspace Name:" $workspace
tf status /workspace:$workspace 
Write-Host `n 
}

Besides, you can also use the tool Team Foundation Sidekicks to manage the workspaces and pending changes... Reference my answer in another thread: Visual studio 2017 Team foundation server question on checking whose working on what files

enter image description here

Upvotes: 4

Related Questions