Public/Get-ShellPhishAttendance.ps1
|
function Get-ShellPhishAttendance { <# .SYNOPSIS Retrieve attendance records from Phish.net. .DESCRIPTION This is a special method — a filter is REQUIRED. The API will reject bare calls to /attendance without a column/value filter. .PARAMETER ApiKey Your Phish.net API key. Defaults to $env:PHISH_KEY. .PARAMETER Uid Numeric user ID. .PARAMETER ShowId Numeric show ID. .PARAMETER Username Phish.net username. .PARAMETER ShowDate Show date in YYYY-MM-DD format. .EXAMPLE PS C:\> Get-ShellPhishAttendance -Username wilson .EXAMPLE PS C:\> Get-ShellPhishAttendance -ShowId 1252683584 #> [CmdletBinding()] param ( [Parameter(Position=0)] [string]$ApiKey = $env:PHISH_KEY, [Parameter()] [ValidateSet('json','xml','html')] [string]$Format = 'json', [Parameter(ParameterSetName='ByUid', Mandatory=$true)] [string]$Uid, [Parameter(ParameterSetName='ByShowId', Mandatory=$true)] [string]$ShowId, [Parameter(ParameterSetName='ByUsername', Mandatory=$true)] [string]$Username, [Parameter(ParameterSetName='ByShowDate', Mandatory=$true)] [ValidatePattern('^\d{4}-\d{2}-\d{2}$')] [string]$ShowDate, [Parameter()][string]$OrderBy, [Parameter()][ValidateSet('asc','desc')][string]$Direction, [Parameter()][int]$Limit, [Parameter()][switch]$NoHeader ) switch ($PSCmdlet.ParameterSetName) { 'ByUid' { $endpoint = "attendance/uid/$Uid.$Format" } 'ByShowId' { $endpoint = "attendance/showid/$ShowId.$Format" } 'ByUsername' { $endpoint = "attendance/username/$Username.$Format" } 'ByShowDate' { $endpoint = "attendance/showdate/$ShowDate.$Format" } } $qp = Get-CommonQueryParams -OrderBy $OrderBy -Direction $Direction -Limit $Limit -NoHeader:$NoHeader Invoke-ShellPhishApi -Endpoint $endpoint -QueryParams $qp -ApiKey $ApiKey } |