Public/Get-ShellPhishVenueHistory.ps1
|
function Get-ShellPhishVenueHistory { <# .SYNOPSIS Shows all Phish performances at venues in a given state or matching a venue name. .PARAMETER State Two-letter US state code (e.g. NY, VT). .PARAMETER VenueName Partial venue name to search for (case-insensitive match). .PARAMETER ExportPath Optional file path (.csv or .json) to export results. .EXAMPLE PS C:\> Get-ShellPhishVenueHistory -State NY .EXAMPLE PS C:\> Get-ShellPhishVenueHistory -VenueName "Madison Square" #> [CmdletBinding()] param ( [Parameter(ParameterSetName='ByState', Mandatory=$true)] [string]$State, [Parameter(ParameterSetName='ByVenueName', Mandatory=$true)] [string]$VenueName, [Parameter()] [string]$ExportPath ) Write-Verbose "Fetching all Phish shows..." $allShows = (Get-ShellPhishShows -Artist phish -OrderBy showdate -Direction asc).data if (-not $allShows) { Write-Warning "No shows found" return } $filtered = switch ($PSCmdlet.ParameterSetName) { 'ByState' { $allShows | Where-Object { $_.state -eq $State } } 'ByVenueName' { $allShows | Where-Object { $_.venue -like "*$VenueName*" } } } if (-not $filtered) { Write-Warning "No shows matched the filter" return } $venueGroups = $filtered | Group-Object -Property venue | Sort-Object Count -Descending Write-Host "`n=== VENUE HISTORY ===" -ForegroundColor Cyan foreach ($vg in $venueGroups) { $sorted = $vg.Group | Sort-Object showdate $first = $sorted | Select-Object -First 1 $last = $sorted | Select-Object -Last 1 Write-Host "`n$($vg.Name) - $($vg.Count) show(s)" -ForegroundColor Yellow Write-Host " Location: $($first.city), $($first.state)" Write-Host " First: $($first.showdate)" Write-Host " Last: $($last.showdate)" } $exportData = foreach ($vg in $venueGroups) { $sorted = $vg.Group | Sort-Object showdate $first = $sorted | Select-Object -First 1 $last = $sorted | Select-Object -Last 1 [PSCustomObject]@{ Venue = $vg.Name City = $first.city State = $first.state ShowCount = $vg.Count FirstShow = $first.showdate LastShow = $last.showdate } } if ($ExportPath) { Export-ShellPhishData -Data $exportData -ExportPath $ExportPath } } |