Shelvesets/Get-ShelvesetFiles.ps1

function Get-ShelvesetFiles
{
    Param(
        [Parameter(Mandatory=$false)]
        $Shelveset,
        [Parameter(Mandatory=$false)]
        $OutputPath = '',
        [Parameter(Mandatory=$false)]
        $ShelvesetName = ''
    )
    
    if ($ShelvesetName -ne '')
    {
        $Shelveset = Invoke-TFSAPI -Url "_apis/tfvc/shelvesets/$ShelvesetName"
    }

    if (!$Shelveset)
    {
        $Shelveset = Get-Shelvesets | Out-GridView -OutputMode Single
    }

    if ($OutputPath -eq '')
    {
        $OutputPath = '{0}\{1}.TXT' -f [Environment]::GetFolderPath('Desktop'), $Shelveset.name        
    }

    $Changes = Invoke-TFSAPI ('{0}/changes?$top=10000' -f $Shelveset.url) 
    foreach ($Change in $Changes.value)
    {
        if ($Change.item.path -like '*.TXT') 
        {
            $ChangeContent += Invoke-TFSAPI $Change.item.url
        }
    }

    if (Test-Path $OutputPath)
    {
        Remove-Item $OutputPath -Force
    }

    Add-Content -Path $OutputPath -Value $ChangeContent
}

Export-ModuleMember -Function Get-ShelvesetFiles