Skip to content

Instantly share code, notes, and snippets.

@mkol5222
Last active February 17, 2022 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mkol5222/9b1de6acf3570c26a60a098f4412a8db to your computer and use it in GitHub Desktop.
Save mkol5222/9b1de6acf3570c26a60a098f4412a8db to your computer and use it in GitHub Desktop.
Infinity Portal license query
function New-CPPortalSession ($key, $secret) {
$body = @{
clientId = $key;
accessKey = $secret
} | ConvertTo-Json
try {
$res = Invoke-RestMethod -Uri "https://cloudinfra-gw.portal.checkpoint.com/auth/external" `
-Headers @{"Content-Type" = "application/json" } `
-Body $body -Method Post
$Script:cpPortalToken = $res.data.token
$Script:xAccessToken = $res.data.csrf
return $res
} catch {
Write-Verbose "An exception was caught: $($_.Exception.Message)"
$_.Exception.Response
}
}
function Get-CPTenantsTable ()
{
try {
$res = Invoke-RestMethod -Uri "https://cloudinfra-gw.portal.checkpoint.com/api/v1/tenant/all?limit=40&sortBy=createdAt&sortDirection=DESC" `
-Method Get `
-Headers @{
"content-type" = "application/json";
"Authorization" = "Bearer $($Script:cpPortalToken)";
"x-access-token" = $Script:xAccessToken;
"origin" = "https://portal.checkpoint.com"
}
return $res
} catch {
Write-Verbose "An exception was caught: $($_.Exception.Message)"
$_.Exception.Response
}
}
function Get-CPLicenseReports ()
{
try {
$res = Invoke-RestMethod -Uri "https://cloudinfra-gw.portal.checkpoint.com/api/v1/tenant/export/csv/create?reportType=AllAccounts" `
-Method Get `
-Headers @{
"content-type" = "application/json";
"Authorization" = "Bearer $($Script:cpPortalToken)";
"x-access-token" = $Script:xAccessToken;
"origin" = "https://portal.checkpoint.com"
}
return $res
} catch {
Write-Verbose "An exception was caught: $($_.Exception.Message)"
$_.Exception.Response
}
}
function demo
{
. ../secrets/mtest2-tenant.ps1
New-CPPortalSession $PORTALKEY $PORTALSECRET
Get-CPLicenseReports
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment