Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagepowershell
$dir = Split-Path $script:MyInvocation.MyCommand.Path
 
$url = "localhost:8080/mcid/api/v1/"
$user = "USER"
$key = "PASS"
 
$auth = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,$key)))
 
$uri = $url + "login"
 
Invoke-RestMethod -Uri $uri -Headers @{Authorization=("Basic {0}" -f $auth)} -SessionVariable session
 
$uri = $url + "systemstatus/logs/collect"
$datetime = Get-Date -UFormat %Y%m%d-%H%M%S
$file_path = $dir + "\CollectedLogFiles-" + $datetime + ".zip"
Invoke-RestMethod -Uri $uri -WebSession $session -OutFile $file_path
 
$uri = $url + "logout"
Invoke-RestMethod -Uri $uri -WebSession $session
 

The script will log logs in, drop stores the collected log files at the same location as the script and logoutlogs out. Please not note that the url, user and key are specific per admin interface instance.

...