Public/ReleaseNotes/Export-ReleaseNotesFromGitToExcel.ps1
function Export-ReleaseNotesFromGitToExcel { <# .SYNOPSIS Runs compilation of release notes data from Git based project. .PARAMETER CollectionUri Url for project collection on Azure DevOps server instance. Can be ommitted if $CollectionUri was previously accessed via this API. If not specified, $global:AzureDevOpsApi_CollectionUri (set by Set-AzureDevopsVariables) is used. .PARAMETER Project Project name, identifier, full project URI, or object with any one these properties. Can be ommitted if $Project was previously accessed via this API (will be extracted from the $ArtifactUri). If not specified, $global:AzureDevOpsApi_Project (set by Set-AzureDevopsVariables) is used. .PARAMETER DateFrom Starting date for the considered PullRequests. .PARAMETER DateTo Ending date for the considered PullRequests. .PARAMETER AsOf Gets the Work Items as they were at this date and time. .PARAMETER ByUser User(s) whose PullRequests will be used. .PARAMETER TargetRepository List of target repositories. Can be passed as a name or identifier. If not specified, all repositories will be used. .PARAMETER TargetBranch Target branch for PullRequests. .PARAMETER Show Flag, whether open the exported document. .PARAMETER PassThru Flag, whether return the generated file. .PARAMETER UseConstantFileName Flag, whether to use constant file name. If $Path is a directory, the file will be named "ReleaseNotes.xlsx" Ignored if $Path is a filename. .PARAMETER Path Path or filename for the exported data to be saved to. If not specified, the file will be saved to the current directory. If points to a directory and $UseConstantFileName is specified, the file will be named "ReleaseNotes.xlsx", otherwise the filename will be "ReleaseNotes_$Project_$CreatedOnDateTime.xlsx". .PARAMETER TimeZone All times from AzureDevOps API are in UTC. Parameter determines the time zone all date times will be converted to. Uses .net TimeZoneInfo class to resolve and calculate the date times. Possible values are: IANA style zone ids, f.e. "Europe/Bratislava" Windows style zone ids, f.e. "Central Europe Standard Time" Default value is "Central Europe Standard Time". .PARAMETER ProgressPreference Determines how PowerShell responds to progress updates generated by a script, cmdlet, or provider, such as the progress bars generated by the Write-Progress cmdlet. .PARAMETER FromCommits If specified, work items associated with commits in the pull request will be also returned. #> [CmdletBinding()] param( [AllowNull()] [AllowEmptyString()] $CollectionUri, [AllowNull()] [AllowEmptyString()] $Project, [Alias('FromDate', 'From')] [Nullable[DateTime]] $DateFrom, [Alias('ToDate', 'To')] [Nullable[DateTime]] $DateTo, [Nullable[DateTime]] $AsOf, $ByUser, [Alias('Repository')] $TargetRepository, [Alias('Branch')] $TargetBranch = 'main', $Path = '.\', [string] $TimeZone = 'UTC', [Alias('IncludeFromCommits')] [switch] $FromCommits, [switch] $Show, [switch] $PassThru, [switch] $UseConstantFileName ) # Show start message Show-Host -ForegroundColor Cyan -Object 'Release list export started' # Report back provided parameters Show-Host -ForegroundColor Magenta -Object 'Provided parameters' # Show input parameters Show-Parameters -Parameters $MyInvocation.BoundParameters # Get the release notes data $data = Get-ReleaseNotesDataFromGit ` -CollectionUri $CollectionUri ` -Project $Project ` -AsOf $AsOf ` -DateFrom $DateFrom ` -DateTo $DateTo ` -ByUser $ByUser ` -TargetRepository $TargetRepository ` -TargetBranch $TargetBranch ` -FromCommits:$FromCommits # Prepare the data for export Show-Host -ForegroundColor Magenta -Object 'Preparing WorkItem data for export' $exportData = ConvertTo-ExportData ` -ItemsTable $data ` -CollectionUri $CollectionUri ` -Project $Project ` -DateFrom $DateFrom ` -DateTo $DateTo ` -AsOf $AsOf ` -ByUser $ByUser ` -TargetBranch $TargetBranch # Export the data Show-Host -ForegroundColor Magenta -Object 'Exporting data' $outputFile = AzureDevOpsApi\Export-Excel ` -ExportData $exportData ` -Path $Path ` -TimeZone $TimeZone ` -UseConstantFileName:$UseConstantFileName ` -Show:$Show ` -PassThru:$true # Report the file path ([PSCustomObject] @{ ExportedTo = $outputFile.FullName }) | Format-List | Out-Host # Return the output file if ($PassThru) { return $outputFile } } Set-Alias -Name Export-ReleaseNotesFromGit -Value Export-ReleaseNotesFromGitToExcel |