mirror of
https://github.com/jprdonnelly/qseow-scripts.git
synced 2025-12-19 17:17:04 -05:00
updates before lappy wipe
This commit is contained in:
50
getAllEvents.ps1
Normal file
50
getAllEvents.ps1
Normal file
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/pwsh
|
||||
### Set your hostname, apiKey and change paths as desired.
|
||||
|
||||
$hostname = "cg8fuxcfavt2dog.us.qlikcloud.com"
|
||||
$apiKey = "eyJhbGciOiJFUzM4NCIsImtpZCI6IjJlY2M2NWJmLTA4NzUtNDE3Mi05YzE4LTg2ZmZhNmI5Yzk5OSIsInR5cCI6IkpXVCJ9.eyJzdWJUeXBlIjoidXNlciIsInRlbmFudElkIjoiRlVPVl9vZkQ0YmRsejZBNk5PWkQ3UU9JYmF3MjFWSDciLCJqdGkiOiIyZWNjNjViZi0wODc1LTQxNzItOWMxOC04NmZmYTZiOWM5OTkiLCJhdWQiOiJxbGlrLmFwaSIsImlzcyI6InFsaWsuYXBpL2FwaS1rZXlzIiwic3ViIjoiNjIxNjU3MzJmZDIwYjVhMmYzZmVlNWY4In0.XKYFTzBiZ-huSZGVFNBqIlTkkUVw0jdGncD_pNIohzAJ5WNRHFx0lD17H68IPhC4Z1oOuuxfeaAHkqf-8fsjRAIEEGmTnX-b9NDmHk-0BtZEVqYa03LVcyRQ_Eq4bAx1"
|
||||
$json = "$HOME\events-list.json"
|
||||
$txt = "$HOME\events-list.txt"
|
||||
|
||||
### Don't change these variables
|
||||
# $URL = "https://$hostname/api/v1/reloads?limit=100"
|
||||
$URL = "https://$hostname/api/v1/audits"
|
||||
$token = $apiKey | ConvertTo-SecureString -AsPlainText -Force
|
||||
|
||||
### Invoke the first REST request to the reloads endpoint
|
||||
$reloads = (Invoke-RestMethod -Uri $URL -Authentication Bearer -Token $token -ContentType 'application/json')
|
||||
|
||||
### Check if files exist, create if not, carry-on if they already do.
|
||||
if (-not(Test-Path -Path $txt -PathType Leaf)) {
|
||||
try {
|
||||
$null = New-Item -ItemType File -Path $txt -Force -ErrorAction Stop
|
||||
Write-Host "The file [$txt] has been created."
|
||||
}
|
||||
catch {
|
||||
throw $_.Exception.Message
|
||||
}
|
||||
}
|
||||
else {
|
||||
Write-Host "Cannot create [$txt] because a file with that name already exists."
|
||||
}
|
||||
|
||||
if (-not(Test-Path -Path $json -PathType Leaf)) {
|
||||
try {
|
||||
$null = New-Item -ItemType File -Path $json -Force -ErrorAction Stop
|
||||
Write-Host "The file [$json] has been created."
|
||||
}
|
||||
catch {
|
||||
throw $_.Exception.Message
|
||||
}
|
||||
}
|
||||
else {
|
||||
Write-Host "Cannot create [$json] because a file with that name already exists."
|
||||
}
|
||||
|
||||
### While there is a value for the "next" cursor, indicating more output, run again
|
||||
while ($reloads.links.next) {
|
||||
$reloads | ConvertTo-JSON -Depth 4 >> $json
|
||||
$reloads.data | Sort-Object -Property startTime -Descending | Format-Table -Property appId,name,type,status,startTime,endTime |Tee-Object -Append -FilePath $txt
|
||||
$URL = $reloads.links.next.href
|
||||
$reloads = (Invoke-RestMethod -Uri $URL -Authentication Bearer -Token $token -ContentType 'application/json')
|
||||
}
|
||||
@@ -3,15 +3,34 @@
|
||||
|
||||
$hostname = "cg8fuxcfavt2dog.us.qlikcloud.com"
|
||||
$apiKey = "eyJhbGciOiJFUzM4NCIsImtpZCI6IjJlY2M2NWJmLTA4NzUtNDE3Mi05YzE4LTg2ZmZhNmI5Yzk5OSIsInR5cCI6IkpXVCJ9.eyJzdWJUeXBlIjoidXNlciIsInRlbmFudElkIjoiRlVPVl9vZkQ0YmRsejZBNk5PWkQ3UU9JYmF3MjFWSDciLCJqdGkiOiIyZWNjNjViZi0wODc1LTQxNzItOWMxOC04NmZmYTZiOWM5OTkiLCJhdWQiOiJxbGlrLmFwaSIsImlzcyI6InFsaWsuYXBpL2FwaS1rZXlzIiwic3ViIjoiNjIxNjU3MzJmZDIwYjVhMmYzZmVlNWY4In0.XKYFTzBiZ-huSZGVFNBqIlTkkUVw0jdGncD_pNIohzAJ5WNRHFx0lD17H68IPhC4Z1oOuuxfeaAHkqf-8fsjRAIEEGmTnX-b9NDmHk-0BtZEVqYa03LVcyRQ_Eq4bAx1"
|
||||
$json = "$HOME\reloads-list.json"
|
||||
$txt = "$HOME\reloads-list.txt"
|
||||
$json = "D:\reloads-list.json"
|
||||
$txt = "D:\reloads-list.txt"
|
||||
|
||||
### Don't change these variables
|
||||
$URL = "https://$hostname/api/v1/reloads?limit=100"
|
||||
# $URL = "https://$hostname/api/v1/reloads?limit=100"
|
||||
# $URL = "https://$hostname/api/v1/audits?eventType=com.qlik.app.reload.ended?limit=1000"
|
||||
$token = $apiKey | ConvertTo-SecureString -AsPlainText -Force
|
||||
|
||||
### Invoke the first REST request to the reloads endpoint
|
||||
$reloads = (Invoke-RestMethod -Uri $URL -Authentication Bearer -Token $token -ContentType 'application/json')
|
||||
$Body = @{
|
||||
eventType = "com.qlik.app.reload.ended"
|
||||
limit = 100
|
||||
}
|
||||
|
||||
$Params = @{
|
||||
Method = "Get"
|
||||
Uri = "https://$hostname/api/v1/audits"
|
||||
Body = $Body
|
||||
Authentication = "Bearer"
|
||||
Token = $token
|
||||
# ContentType = "application/json"
|
||||
FollowRelLink = $true
|
||||
}
|
||||
|
||||
# $reloads = (Invoke-RestMethod @Params|ConvertFrom-JSON -AsHashtable)
|
||||
$reloads = ( ( (Invoke-RestMethod @Params).ToString().Replace("Self", "self") ).ToString().Replace("Next", "next") | ConvertFrom-Json -Depth 6 )
|
||||
# $reloads = (Invoke-RestMethod -Uri $URL -Authentication Bearer -Token $token -ContentType 'application/json')
|
||||
# $reloads = (qlik raw get --context saasy --raw 'v1/audits?eventType=com.qlik.app.reload.ended?limit=10000000000')
|
||||
|
||||
### Check if files exist, create if not, carry-on if they already do.
|
||||
if (-not(Test-Path -Path $txt -PathType Leaf)) {
|
||||
@@ -43,7 +62,8 @@ else {
|
||||
### While there is a value for the "next" cursor, indicating more output, run again
|
||||
while ($reloads.links.next) {
|
||||
$reloads | ConvertTo-JSON -Depth 4 >> $json
|
||||
$reloads.data | sort -Property startTime | Format-Table -Property id,appId,type,status,startTime,endTime |Tee-Object -Append -FilePath $txt
|
||||
$reloads.data | Sort-Object -Property startTime -Descending | Format-Table -Property appId,name,type,status,startTime,endTime |Tee-Object -Append -FilePath $txt
|
||||
$URL = $reloads.links.next.href
|
||||
sleep 5
|
||||
$reloads = (Invoke-RestMethod -Uri $URL -Authentication Bearer -Token $token -ContentType 'application/json')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user