0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PowerShell から LINE WORKS の 監査 API で監査データをダウンロード

Posted at

PowerShell のコマンドレット操作で LINE WORKS の監査 API を用いて、監査ログを CSV 形式でダウンロードする方法です。

スクリプト ファイルをタスク スケジューラから実行するなどの方法で、監査ログの出力を自動化できます。

事前作業

LINE WORKS の監査 API を利用するため、Developer Console から以下の事前作業を行います。

API 認証の準備

  • API ID 発行
  • サーバー API のコンシューマーキー発行
  • サーバー API の Server Token

手順はこちらのページの情報を参照します。
https://developers.worksmobile.com/jp/document/1002002?lang=ja

監査 API による監査データのダウンロード

LINE WORKS の監査 API については、こちらのページに説明があります。
https://developers.worksmobile.com/jp/document/30014001?lang=ja

PowerShell の Invoke-RestMethod コマンドレットで、監査 API を実行します。

構文は次のとおりです。

Invoke-RestMethod -Uri "https://jp1-audit.worksmobile.com/works/audit/log/<service_parameter>/logs.csv?apiId=downCsvLog&serviceId=audit&rangeName=domain&_startDate=<yyyymmdd>&_endDate=<yyyymmdd&_tenantId=<tenantId>&_domainId=<domainId>&language=ja-JP" -Method Get -Headers @{Authorization = "Bearer <Server_Token>"; consumerKey = "<consumerKey>"} | Out-File C:\temp\auditlog.txt

パイプ処理で Out-File コマンドレットで、txt ファイルに出力しています。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?