Search code examples
powershelltfstfs-power-tools

PowerShell TFS list all files which have been added within a certain timeframe


I use Microsoft Team Foundation Server 2015 Power Tools. I know that to list all files that have been deleted in timeframe we can do something like this:

Get-TfsItemHistory "$/MyProject" -Version "D29/01/2010~D03/12/2019" -Recurse -IncludeItems '-Server tfs-server-name | Select-Object -Expand "Changes" | ' Where-Object { ($_.ChangeType -eq Microsoft.TeamFoundation.VersionControl.Client.ChangeType::Delete ) } | 'Select-TfsItem | Select-Object Path | Sort-Object Path

Now I want to list all files that have been added. Based on types listed in ChangeType Enumerator I tried to replace Microsoft.TeamFoundation.VersionControl.Client.ChangeType::Delete with Microsoft.TeamFoundation.VersionControl.Client.ChangeType::Add but it doesn't work.


Solution

  • You may need to -band the ChangeType, as it's a flag enum and may contain multiple flags.

    $ChangeType =  Microsoft.TeamFoundation.VersionControl.Client.ChangeType::Delete
    (($_.ChangeType -band $ChangeType) -eq $ChangeType)
    

    The process if further explained here at the post mentioned by Patrick: