It's easy to use Excel add-ins or extensions from marketplace to export the work items, right? Then why build a script in PowerShell?
To answer this in short, I manage multiple instances for multiple projects so I use PowerShell, which is a quick way for me to explore work items in one go!
Comments
- <#
- .SYNOPSIS
- A PowerShell function to export Visual Studio Team Servies work items.
- .DESCRIPTION
- A PowerShell function to export Visual Studio Team Servies work items.
- .EXAMPLE
- PS C:\> Export-VSTSWorkItem -Instance "Fabrikam" -Token "PAT -WorkItemType Bug
- Yields all the bugs in from the work items table.
- .EXAMPLE
- PS C:\> Export-VSTSWorkItem -Instance "Fabrikam" -Token "PAT" -WorkItemType Task
- Yields all the task in from the work items table.
- .EXAMPLE
- PS C:\> Export-VSTSWorkItem -Instance "Fabrikam" -Token "PAT" -WorkItemType Epic
- Yields all the epic in from the work items table.
- .EXAMPLE
- PS C:\> Export-VSTSWorkItem -Instance "Fabrikam" -Token "PAT" -WorkItemType Epic -ExportAs Csv
- Exports information as csv
- .EXAMPLE
- PS C:\> Export-VSTSWorkItem -Instance "Fabrikam" -Token "PAT" -WorkItemType Epic -ExportAs FancyHtml
- Exports information as a fancy html
- .NOTES
- @ChendrayanV
- #>
- param (
- # Visual Studio Team Services Account Name
- [Parameter(Mandatory)]
- $Instance,
- # Create a Personal Access Token
- [Parameter(Mandatory)]
- $Token,
- # Opt the Work Items Type. (Modify as required)
- [Parameter(Mandatory)]
- [ValidateSet('Bug', 'Task', 'Epic', 'Feature')]
- $WorkItemType,
- # Export in your favorite format.
- [Parameter()]
- [ValidateSet('Csv', 'HTML', 'FancyHTML')]
- $ExportAs
- )
- $Authentication = (":$Token")
- $Authentication = [System.Text.Encoding]::ASCII.GetBytes($Authentication)
- $Authentication = [System.Convert]::ToBase64String($Authentication)
- switch ($WorkItemType)
- {
- "Bug"
- {
- $Body = @{
- Query = "Select * from WorkItems WHERE [System.WorkItemType] = '$WorkItemType'"
- } | ConvertTo-Json
- }
- "Task"
- {
- $Body = @{
- Query = "Select * from WorkItems WHERE [System.WorkItemType] = '$WorkItemType'"
- } | ConvertTo-Json
- }
- "Epic"
- {
- $Body = @{
- Query = "Select * from WorkItems WHERE [System.WorkItemType] = '$WorkItemType'"
- } | ConvertTo-Json
- }
- "Feature"
- {
- $Body = @{
- Query = "Select * from WorkItems WHERE [System.WorkItemType] = '$WorkItemType'"
- } | ConvertTo-Json
- }
- }

Join the conversation! Your thoughts help the community grow.