Last active
February 10, 2020 08:32
-
-
Save codykonior/8ad20f1d9ed5b274aea65a5a7ecc6dea to your computer and use it in GitHub Desktop.
SentryOne License Scrape
This file contains 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
$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