Last active
February 17, 2022 09:01
-
-
Save mkol5222/9b1de6acf3570c26a60a098f4412a8db to your computer and use it in GitHub Desktop.
Infinity Portal license query
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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