@@ -291,15 +291,17 @@ DELETE https://management.azure.com/providers/Microsoft.Insights/monitoredObject
291
291
``` PowerShell
292
292
$TenantID = "xxxxxxxxx-xxxx-xxx" #Your Tenant ID
293
293
$SubscriptionID = "xxxxxx-xxxx-xxxxx" #Your Subscription ID
294
- $ResourceGroup = "rg-yourResourseGroup " #Your resroucegroup
294
+ $ResourceGroup = "rg-yourResourceGroup " #Your resourcegroup
295
295
296
- Connect-AzAccount -Tenant $TenantID
296
+ #If cmdlet below produces an error stating 'Interactive authentication is not supported in this session, please run cmdlet 'Connect-AzAccount -UseDeviceAuthentication
297
+ #uncomment next to -UseDeviceAuthentication below
298
+ Connect-AzAccount -Tenant $TenantID #-UseDeviceAuthentication
297
299
298
300
#Select the subscription
299
301
Select-AzSubscription -SubscriptionId $SubscriptionID
300
302
301
303
#Grant Access to User at root scope "/"
302
- $user = Get-AzADUser -UserPrincipalName (Get-AzContext).Account
304
+ $user = Get-AzADUser -SignedIn
303
305
304
306
New-AzRoleAssignment -Scope '/' -RoleDefinitionName 'Owner' -ObjectId $user.Id
305
307
@@ -336,7 +338,7 @@ Invoke-RestMethod -Uri $requestURL -Headers $AuthenticationHeader -Method PUT -B
336
338
#2. Create a monitored object
337
339
338
340
# "location" property value under the "body" section should be the Azure region where the MO object would be stored. It should be the "same region" where you created the Data Collection Rule. This is the location of the region from where agent communications would happen.
339
- $Location = "eastus" #Use your own loacation
341
+ $Location = "eastus" #Use your own location
340
342
$requestURL = "https://management.azure.com/providers/Microsoft.Insights/monitoredObjects/$TenantID`?api-version=2021-09-01-preview"
341
343
$body = @"
342
344
{
@@ -368,8 +370,9 @@ $body = @"
368
370
369
371
Invoke-RestMethod -Uri $requestURL -Headers $AuthenticationHeader -Method PUT -Body $body
370
372
371
- #(Optional example). Associate another DCR to monitored object
373
+ #(Optional example). Associate another DCR to monitored object. Remove comments around text below to use.
372
374
#See reference documentation https://learn.microsoft.com/en-us/rest/api/monitor/data-collection-rule-associations/create?tabs=HTTP
375
+ <#
373
376
$associationName = "assoc02" #You must change the association name to a unique name, if you want to associate multiple DCR to monitored object
374
377
$DCRName = "dcr-PAW-WindowsClientOS" #Your Data collection rule name
375
378
@@ -388,7 +391,7 @@ Invoke-RestMethod -Uri $requestURL -Headers $AuthenticationHeader -Method PUT -B
388
391
#4. (Optional) Get all the associatation.
389
392
$requestURL = "https://management.azure.com$RespondId/providers/microsoft.insights/datacollectionruleassociations?api-version=2021-09-01-preview"
390
393
(Invoke-RestMethod -Uri $requestURL -Headers $AuthenticationHeader -Method get).value
391
-
394
+ #>
392
395
393
396
```
394
397
## Verify successful setup
0 commit comments