Public/Get-ShellPhishVenues.ps1
|
function Get-ShellPhishVenues { <# .SYNOPSIS Retrieve venue records from Phish.net. .DESCRIPTION Returns all venues, or venues filtered by ID, state, or country. .PARAMETER ApiKey Your Phish.net API key. Defaults to $env:PHISH_KEY. .PARAMETER Id Numeric venue ID. .PARAMETER State Two-letter US state code (e.g. CT, NY). .PARAMETER Country Country name or code. .EXAMPLE PS C:\> Get-ShellPhishVenues .EXAMPLE PS C:\> Get-ShellPhishVenues -State CT #> [CmdletBinding(DefaultParameterSetName = 'Default')] param ( [Parameter(Position=0)] [string]$ApiKey = $env:PHISH_KEY, [Parameter()] [ValidateSet('json','xml','html')] [string]$Format = 'json', [Parameter(ParameterSetName='ById', Mandatory=$true)] [string]$Id, [Parameter(ParameterSetName='ByState', Mandatory=$true)] [string]$State, [Parameter(ParameterSetName='ByCountry', Mandatory=$true)] [string]$Country, [Parameter()][string]$OrderBy, [Parameter()][ValidateSet('asc','desc')][string]$Direction, [Parameter()][int]$Limit, [Parameter()][switch]$NoHeader ) switch ($PSCmdlet.ParameterSetName) { 'ById' { $endpoint = "venues/$Id.$Format" } 'ByState' { $endpoint = "venues/state/$State.$Format" } 'ByCountry' { $endpoint = "venues/country/$Country.$Format" } default { $endpoint = "venues.$Format" } } $qp = Get-CommonQueryParams -OrderBy $OrderBy -Direction $Direction -Limit $Limit -NoHeader:$NoHeader Invoke-ShellPhishApi -Endpoint $endpoint -QueryParams $qp -ApiKey $ApiKey } |