Skip to content

Commit

Permalink
Update enablesubscription.ps1
Browse files Browse the repository at this point in the history
Updated it to be runs as a deployment function
  • Loading branch information
jonnords authored Apr 21, 2020
1 parent 15a1072 commit f844827
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions Sentinel/enablesubscription.ps1
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#Enable the Activity API Subscriptions

$clientID = "YOUR CLIENT ID
$clientSecret = "YOUR CLIENT SECRET"
$loginURL = "https://login.windows.net"
$tenantdomain = "YOUR TENANT"
$tenantGUID = "YOUR TENANT GUID"
$clientID = "$env:clientID"
$clientSecret = "$env:clientSecret"
$loginURL = "https://login.microsoftonline.com"
$tenantdomain = "$env:tenantdomain"
$tenantGUID = "$env:TenantGuid"
$resource = "https://manage.office.com"
$date = Get-date -format "yyyy-MM-ddTHH:mm:ss.fffZ"
# Get an Oauth 2 access token based on client id, secret and tenant domain
$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
Expand All @@ -15,3 +16,10 @@ $headerParams = @{'Authorization'="$($oauth.token_type) $($oauth.access_token)"
Invoke-RestMethod -Method Post -Headers $headerParams -Uri "https://manage.office.com/api/v1.0/$tenantGUID/activity/feed/subscriptions/start?contentType=DLP.All"
#List the active subscriptions
Invoke-WebRequest -Headers $headerParams -Uri "https://manage.office.com/api/v1.0/$tenantGUID/activity/feed/subscriptions/list"

#Sets up the Message Queue
$storeAuthContext = New-AzStorageContext -ConnectionString $env:AzureWebJobsStorage
New-AzStorageQueue -Name $env:storageQueue -context $storeAuthContext

#Generates the time stamp for the ingestion
out-file d:\home\dlp.All.log -InputObject $date

0 comments on commit f844827

Please sign in to comment.