Skip to content

Instantly share code, notes, and snippets.

@codykonior
Last active February 10, 2020 08:32
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 codykonior/8ad20f1d9ed5b274aea65a5a7ecc6dea to your computer and use it in GitHub Desktop.
Save codykonior/8ad20f1d9ed5b274aea65a5a7ecc6dea to your computer and use it in GitHub Desktop.
SentryOne License Scrape
$webSession = New-Object Microsoft.PowerShell.Commands.WebRequestSession
$postValues = @{ Email = "..."; Password = "..."; }
$login = Invoke-WebRequest -WebSession $webSession -Uri "https://my.sentryone.com/login" -Method POST -Body $postValues
$page = Invoke-WebRequest -WebSession $webSession -Uri "https://my.sentryone.com/"
$regex = [regex] 'id="(\d+?)" class="list-group-item serverFriendlyNameContainer sqlSentryItem"'
$ids = $regex.Matches($page.RawContent) | %{ $_.Groups[1].Value }
$keys = @()
foreach ($id in $ids) {
$postValues = @{ userKeyID = $id }
$data = Invoke-WebRequest -WebSession $webSession -Uri "https://my.sentryone.com/myaccount/getlicensedatabyid" -Method POST -Body $postValues
# ID HardwareKey FriendlyName ProductID ProductMajorVersion LicenseType IssueDate ASMExpiration
$key = ($data.Content | ConvertFrom-Json).Data.UserKeyDetails
# UserKeyId UserId HardwareKey ProductItemID Name Quantity LicenseTypeName HasLicenseUnits LicenseUnits Expired SentryOneProduct ProductPackID
foreach ($product in ($data.Content | ConvertFrom-Json).Data.SubscribedSentryOneProducts) {
$keyName = $product.Name.Replace(" ", "") + "Quantity"
$key | Add-Member -MemberType NoteProperty -Name $keyName -Value $product.Quantity
}
$keys += $key
}
$keys | Out-GridView
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment