Public/Export-ShellPhishShowsByYear.ps1
|
function Export-ShellPhishShowsByYear { <# .SYNOPSIS Exports show records for a given year (or all years) to CSV or JSON. .PARAMETER Year Four-digit year. Omit and use -All for every show. .PARAMETER All Export all shows across all years. .PARAMETER ExportPath Required. File path (.csv or .json) to export to. .EXAMPLE PS C:\> Export-ShellPhishShowsByYear -Year 1997 -ExportPath ./shows-1997.csv .EXAMPLE PS C:\> Export-ShellPhishShowsByYear -All -ExportPath ./all-shows.json #> [CmdletBinding()] param ( [Parameter(ParameterSetName='ByYear', Mandatory=$true)] [ValidatePattern('^\d{4}$')] [string]$Year, [Parameter(ParameterSetName='All', Mandatory=$true)] [switch]$All, [Parameter(Mandatory=$true)] [string]$ExportPath ) if ($All) { Write-Verbose "Fetching all Phish shows..." $shows = (Get-ShellPhishShows -Artist phish -OrderBy showdate -Direction asc).data } else { Write-Verbose "Fetching shows for $Year..." $shows = (Get-ShellPhishShows -Year $Year -OrderBy showdate -Direction asc).data } if (-not $shows) { Write-Warning "No shows found" return } Export-ShellPhishData -Data $shows -ExportPath $ExportPath } |