13 строки
965 B
Plaintext
13 строки
965 B
Plaintext
# Populate with App ID and Secret from your Azure AD app registration
|
||
$ClientID = "<app_id>"
|
||
$ClientSecret = "<client_secret>"
|
||
$loginURL = "https://login.microsoftonline.com/"
|
||
$tenantdomain = "<domain>.onmicrosoft.com"
|
||
# Get the tenant GUID from Properties | Directory ID under the Azure Active Directory section
|
||
$TenantGUID = "<Tenant GUID>"
|
||
$resource = "https://manage.office.com"
|
||
$body = @{grant_type="client_credentials";resource=$resource;client_id=$ClientID;client_secret=$ClientSecret}
|
||
$oauth = Invoke-RestMethod -Method Post -Uri $loginURL/$tenantdomain/oauth2/token?api-version=1.0 -Body $body
|
||
$headerParams = @{'Authorization'="$($oauth.token_type) $($oauth.access_token)"}
|
||
$publisher = New-Guid
|
||
Invoke-WebRequest -Method Post -Headers $headerParams -Uri "https://manage.office.com/api/v1.0/$tenantGuid/activity/feed/subscriptions/start?contentType=Audit.General&PublisherIdentifier=$Publisher" |