functions/Get-ToolProject.ps1
<#
.SYNOPSIS Returns tool project ID for given project name. .DESCRIPTION Returns tool project ID for given project name using the CodeDx endpoint. .EXAMPLE Get-ToolProject "selected_project" myProject 54 https://cxprivatecloud.checkmarx.net/ username@email.com mypw1234 Output 1 #> Function Get-ToolProject { [cmdletbinding()] param( [Parameter(Mandatory=$true)] [string]$FieldName, [Parameter(Mandatory=$true)] [string]$ToolProjectName, [Parameter(Mandatory=$true)] [string]$ConnectorID, [Parameter(Mandatory=$true)] [string]$HostURL, [Parameter(Mandatory=$true)] [string]$UserName, [Parameter(Mandatory=$true)] [string]$Password ) $uri = $CDXSERVER + "/x/tool-connector-config/values/" + $ConnectorID + "/populate/" + $FieldName $body = Convertto-Json @{ host_url = $HostURL username = $UserName password = $Password } $ToolProjects = Invoke-RestMethod -Uri $uri -Method Post -Body $body -Headers $headers -ContentType "application/json" Write-Verbose ( $ToolProjects | Format-Table | Out-String ) # Get the tool project ID from the name $ToolProjects | ForEach-Object { if($_.display -eq $ToolProjectName) { $ToolProjectID = $_.value } } $ToolProjectID } |