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
    Posts
    • #197507
      Participant
      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

      OR

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

       

      Output:

      “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)}

      Output:

      “Get-TfsChildItem : The term ‘Get-TfsChildItem’ is not recognized as the name…..”

       

       

      Any help would be greatly appreciated.

       

      Thanks!

       

       

       

      • This topic was modified 8 months, 2 weeks ago by Bagman_11127.
      • This topic was modified 8 months, 2 weeks ago by Bagman_11127. Reason: Some additional tries with different TFS based cmdlets
    • #197570
      Participant
      Topics: 15
      Replies: 1761
      Points: 3,167
      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:

      Hopefully this points you in the right direction.

    • #197762
      Participant
      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”

      Output:

      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’
      Note:
      Build Agent/Server info:
      “Windows 2012 R2” , 64-bit OS
      Thanks.

       

Viewing 2 reply threads
  • The topic ‘Accessing only recently changed/committed files in TFS 2019’ is closed to new replies.