You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

The following script is a Windows Powershell example on how to use the Admin Interface REST API to collect all system log files.

$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 in, drop the collected log files at the same location as the script and logout. Please not that the url, user and key are specific per admin interface instance.

 

  • No labels