From f844827cacebec43ba7528a13aa9f7fa2577d218 Mon Sep 17 00:00:00 2001 From: Jon Nordstrom <35916806+jonnords@users.noreply.github.com> Date: Tue, 21 Apr 2020 12:02:15 +0200 Subject: [PATCH] Update enablesubscription.ps1 Updated it to be runs as a deployment function --- Sentinel/enablesubscription.ps1 | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Sentinel/enablesubscription.ps1 b/Sentinel/enablesubscription.ps1 index 0c3acce..3e954c3 100644 --- a/Sentinel/enablesubscription.ps1 +++ b/Sentinel/enablesubscription.ps1 @@ -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 @@ -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