1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# jqインストール Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) choco chocolatey install jq jq # パラメーター $TenantName = "vamdemicsystem.black" $ClientId = "3c0a11e5-xxxx-xxxx-xxxx-530xx6b997b4" $ClientSecret = "FJdbZxxx" $SmtpAddress = "y-kujirai@vamdemicsystem.black" # アクセストークン取得 $Result = Invoke-RestMethod -uri "https://login.microsoftonline.com/$($TenantName)/oauth2/token" -Method Post -Body @{grant_type = "client_credentials"; resource = "https://graph.microsoft.com/"; client_id = $ClientId; client_secret = $ClientSecret } $Token = $Result.access_token # 予定イベント取得 Invoke-WebRequest -Uri "https://graph.microsoft.com/v1.0/users/$SmtpAddress/calendar/events" -Headers @{Authorization = "Bearer " + $Token } -ContentType "application/json" -Method Get (Invoke-WebRequest -Uri "https://graph.microsoft.com/v1.0/users/$SmtpAddress/calendar/events" -Headers @{Authorization = "Bearer " + $Token } -ContentType " application/json" -Method Get).content | jq '.value[].subject ' |