Public/Get-SemaphoreProjectKey.ps1
function Get-SemaphoreProjectKey { [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [ValidateRange(1, [int]::MaxValue)] [int] $ProjectId, [Parameter(Mandatory = $false)] [String] $Name ) begin { Write-Verbose -Message "Calling function $($MyInvocation.MyCommand)" if(!$Script:Session) { throw "Please run Connect-Semaphore first" } } process { try { $Data = Invoke-RestMethod -Uri "$($Script:Config.url)/project/$ProjectId/keys" -Method Get -ContentType 'application/json' -WebSession $Script:Session if($Name) { $Data = $Data | Where-Object { $_.name -eq $Name } } $Data } catch { throw $_ } } end { } } |