Accessing only recently changed/committed files in TFS 2019

Welcome Forums General PowerShell Q&A Accessing only recently changed/committed files in TFS 2019

Viewing 2 reply threads
  • Author
    • #197507
      Topics: 1
      Replies: 1
      Points: -23
      Rank: Member

      Hello team,


      Can someone please let me know how to access and retrieve only the most recent files (.bar files) when they get checked in under specific project folder in TFS 2019 version? I've tried different attempts by using different TFS based cmdlets which I've found during my research recently but it looks like the PS engine doesn't recognized them as a proper cmdlet in any PS 5.0+ versions for TFS 2019. For instance,

      select *.bar -r -version "LmyBuildLabel~T" -all | select-tfsitem | select path | out-file ChangedBARFiles.txt


      Get-TfsChangeSet . -r | Where {$_.CheckinDate -eq (Get-Date)} |
      Select TargetServerItem > recentlyChangedFiles.txt



      "The term 'tfs-item' is not recognized as the name of a cmdlet......" 

      "The term 'TFSChangeSet' is not recognized as the name of a cmdlet......" 


      Also tried with another TFS cmdlet like:

      Get-TfsChildItem . -r | Where {$_.CheckinDate -gt (Get-Date)}


      "Get-TfsChildItem : The term 'Get-TfsChildItem' is not recognized as the name....."



      Any help would be greatly appreciated.






      • This topic was modified 1 week, 6 days ago by Bagman_11127.
      • This topic was modified 1 week, 6 days ago by Bagman_11127. Reason: Some additional tries with different TFS based cmdlets
    • #197570
      Topics: 10
      Replies: 1381
      Points: 1,509
      Helping Hand
      Rank: Community Hero

      The errors you are getting are basically saying that you have not Imported the commands into the Powershell session. I've not used Powershell with TFS, but most of the code I see uses a PSSnapIn, which is a bit deprecated. Take a look at this example and ensure that you can successfully import the PSSnapIn prior to executing the commands:

      Download files from TFS server with PowerShell

      There are also some Modules available for 2015, but from what I can gather most are interfacing with an API whereas the SnapIn is referencing a DLL installed:

      PS C:\Users\rasim> Find-Module *tfs*
      Version    Name                                Repository           Description
      -------    ----                                ----------           -----------
      4.2.6      NTFSSecurity                        PSGallery            Windows PowerShell Module for managing file and ...
      1.4.1      cNtfsAccessControl                  PSGallery            The cNtfsAccessControl module contains DSC resou...  TfsCmdlets                          PSGallery            PowerShell Cmdlets for TFS and VSTS
      2016.10.20 TFS                                 PSGallery            Control TFS 2015 via REST interface  PSPlus.Tfs                          PSGallery            Team foundation server related cmdlets!    TfsCmdlets2015                      PSGallery            PowerShell cmdlets for TFS 2015
      0.4.0      TFSPowershell                       PSGallery            Functions to handle TFS Entities.   Tecman.Tfs.Tools                    PSGallery            Functions to support Microsoft Dynamics 365 Busi...
      1.0.171... PSDT.Tfs                            PSGallery            A collection of Team Foundation Server related P...
      5.2.0      FC_TFS                              PSGallery            Contains functions to interact with TFS Rest API
      1.0        cEPRSInstallTFS2015                 PSGallery            cEPRSInstallTFS2015 Module helps in Instlling TFS
      1.0        NTFSPermissionMigration             PSGallery            This module is used as a wrapper to the popular ...

      Hopefully this points you in the right direction.

    • #197762
      Topics: 1
      Replies: 1
      Points: -23
      Rank: Member

      Thanks Rob. You're right that I've missed out a PSSnapIn cmdlet first through which I could have imported the TFS based assembly first into the PS session. But the issue I'm facing now is that if I use the following cmdlet into my script:

      "Add-PSSnapin Microsoft.TeamFoundation.PowerShell"


      Add-PSSnapin : No snap-ins have been registered for Windows PowerShell version.

      And upon using 'Get-PSSnapin; cmdlet, it returns with just one module that is installed on the build server/agent:

      Name : Microsoft.PowerShell.Core
      PSVersion : 5.1.14393.3053
      Description : This Windows PowerShell snap-in contains cmdlets used to manage
      components of Windows PowerShell.
      After doing some research, came to know that it has something to do with installing/re-installing Power Tools 2015 (tftp.exe) downloaded from here:
      But when installed on the build agent, the PowerShell option is already included in it with 'Full' install option. And during Custom option, the PowerShell component doesn't come up to modify. The following component is shown up only during the 'Modify' option:
      'Storyboard Shapes Authoring Tool'
      Build Agent/Server info:
      "Windows 2012 R2" , 64-bit OS


Viewing 2 reply threads
  • You must be logged in to reply to this topic.