You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-monitor/vm/vminsights-enable-powershell.md
+62-19Lines changed: 62 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ ms.topic: conceptual
5
5
ms.custom: devx-track-azurepowershell
6
6
author: guywi-ms
7
7
ms.author: guywild
8
-
ms.date: 11/28/2023
8
+
ms.date: 12/13/2023
9
9
---
10
10
11
11
# Enable VM insights by using PowerShell
@@ -14,7 +14,7 @@ This article describes how to enable VM insights on Azure virtual machines by us
14
14
- Azure Virtual Machines
15
15
- Azure Virtual Machine Scale Sets
16
16
17
-
This script installs VM extensions for Log Analytics/Azure Monitoring Agent (AMA) andDependency Agent if needed for VM Insights. If AMA is onboarded, a Data Collection Rule (DCR) and a User Assigned Managed Identity (UAMI) is also associated with the virtual machines and virtual machine scale sets.
17
+
This script installs VM extensions for Log Analytics/Azure Monitoring Agent (AMA) and, if necessary, the Dependency Agent to enable VM Insights. If AMA is onboarded, a Data Collection Rule (DCR) and a User Assigned Managed Identity (UAMI) is also associated with the virtual machines and virtual machine scale sets.
To enable VM insights for multiple VMs or virtual machine scale set, use the PowerShell script [Install-VMInsights.ps1](https://www.powershellgallery.com/packages/Install-VMInsights). The script is available from the Azure PowerShell Gallery. This script iterates through the virtual machines or virtual machine scale sets according to the parameters that you specify. The script can be used to enable VM insights for:
32
32
33
33
- Every virtual machine and virtual machine scale set in your subscription.
34
-
- The scoped resource group that's specified by `-ResourceGroup`.
35
-
- A single VM or virtual machine scale set that's specified by `-Name`.
34
+
- The scoped resource groups specified by `-ResourceGroup`.
35
+
- A VM or virtual machine scale set specified by `-Name`.
36
+
You can specify multiple resource groups, VMs, or scale sets by using wildcards.
36
37
37
38
38
-
Verify that you're using Az PowerShell module version 1.0.0 or later with `Enable-AzureRM` compatibility aliases enabled. Run `Get-Module -ListAvailable Az` to find the version. If you need to upgrade, see [Install Azure PowerShell module](/powershell/azure/install-azure-powershell). If you're running PowerShell locally, you also need to run `Connect-AzAccount` to create a connection with Azure.
39
+
Verify that you're using Az PowerShell module version 1.0.0 or later with `Enable-AzureRM` compatibility aliases enabled. Run `Get-Module -ListAvailable Az` to find the version. To upgrade, see [Install Azure PowerShell module](/powershell/azure/install-azure-powershell). If you're running PowerShell locally, run `Connect-AzAccount` to create a connection with Azure.
39
40
40
41
For a list of the script's argument details and example usage, run `Get-Help`.
41
42
42
43
```powershell
43
44
Get-Help Install-VMInsights.ps1 -Detailed
44
45
```
45
46
46
-
Use the script to enable VM insights using Azure Monitoring Agent and Dependency Agent, or Log Analytics Agent.
47
+
Use the script to enable VM insights using Azure Monitoring Agent and Dependency Agent, or Log Analytics Agent.
47
48
48
49
49
50
50
51
### [Azure Monitor Agent](#tab/AMA)
51
52
52
-
When you enable VM insights using Azure Monitor Agent, the script associates a Data Collection Rule (DCR) and a User Assigned Managed Identity (UAMI) to the VM/VMSS, and passes the UAMI settings to the Azure Monitor Agent extension.
53
+
When you enable VM insights using Azure Monitor Agent, the script associates a Data Collection Rule (DCR) and a User Assigned Managed Identity (UAMI) to the VM/Virtual Machine Scale Set. The UAMI settings are passed to the Azure Monitor Agent extension.
+`-DcrResourceId <String> ` Data Collection Rule (DCR) Azure resource ID identifier. You can specify DCRs from different subscriptions to the VMs or virtual machine scale sets being enabled with Vm-Insights.
69
+
+`-UserAssignedManagedIdentityResourceGroup <String> ` Name of User Assigned Managed Identity (UAMI) resource group.
70
+
+`-UserAssignedManagedIdentityName <String> ` Name of User Assigned Managed Identity (UAMI).
71
+
70
72
71
73
Optional Arguments:
72
-
+`-ProcessAndDependencies` Set this flag to onboard the Dependency Agent with Azure Monitoring Agent (AMA) settings. If not specified, only Azure Monitoring Agent (AMA) will be onboarded.
73
-
+` - Name <String>` Name of the VM or VMSS to be onboarded. If not specified, all VMs and VMSS in the subscription or resource group will be onboarded.
74
-
+`- ResourceGroup <String>` Name of the resource group containing the VM or VMSS to be onboarded. If not specified, all VMs and VMSS in the subscription will be onboarded.
74
+
+`-ProcessAndDependencies` Set this flag to onboard the Dependency Agent with Azure Monitoring Agent (AMA) settings. If not specified, only the Azure Monitoring Agent (AMA) is onboarded.
75
+
+`-Name <String>` Name of the VM or Virtual Machine Scale Set to be onboarded. If not specified, all VMs and Virtual Machine Scale Set in the subscription or resource group are onboarded. Use wildcards to specify multiple VMs or Virtual Machine Scale Sets.
76
+
+`-ResourceGroup <String>` Name of the resource group containing the VM or Virtual Machine Scale Set to be onboarded. If not specified, all VMs and Virtual Machine Scale Set in the subscription are onboarded. Use wildcards to specify multiple resource groups.
77
+
+`-PolicyAssignmentName <String>` Only include VMs associated with this policy. When the PolicyAssignmentName parameter is specified, the VMs part of the parameter SubscriptionId are considered.
78
+
+`-TriggerVmssManualVMUpdate [<SwitchParameter>]` Trigger the update of VM instances in a scale set whose upgrade policy is set to Manual.
79
+
+`-WhatIf [<SwitchParameter>]` Get info about expected effect of the commands in the script.
80
+
+`-Confirm [<SwitchParameter>]` Confirm each action in the script.
81
+
+`-Approve [<SwitchParameter>]` Provide the approval for the installation to start with no confirmation prompt for the listed VM's/Virtual Machine Scale Sets.
82
+
83
+
The script supports wildcards for `-Name` and `-ResourceGroup`. For example, `-Name vm*` enables VM insights for all VMs and Virtual Machine Scale Sets that start with "vm". For more information, see [Wildcards in Windows PowerShell](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_wildcards).
+`-WorkspaceKey <String>` Log Analytics Workspace primary or secondary key.
141
+
142
+
Optional Arguments:
143
+
+`-ReInstall [<SwitchParameter>]` Trigger removal of existing Log analytics extension and reinstallation to migrate log analytics workspaces with Legacy Agent (Linux) - OMSAgent.
144
+
+`-Name <String>` Name of the VM or Virtual Machine Scale Set to be onboarded. If not specified, all VMs and Virtual Machine Scale Sets in the subscription or resource group are onboarded. Use wildcards to specify multiple VMs or Virtual Machine Scale Sets.
145
+
+`- ResourceGroup <String>` Name of the resource group containing the VM or Virtual Machine Scale Set to be onboarded. If not specified, all VMs and Virtual Machine Scale Sets in the subscription are onboarded. Use wildcards to specify multiple resource groups.
146
+
+`-PolicyAssignmentName <String>` Only include VMs associated with this policy. When the PolicyAssignmentName parameter is specified, the VMs part of the parameter SubscriptionId are considered.
147
+
+`-TriggerVmssManualVMUpdate [<SwitchParameter>]` Trigger the update of VM instances in a scale set whose upgrade policy is set to Manual.
148
+
+`-WhatIf [<SwitchParameter>]` Get info about expected effect of the commands in the script.
149
+
+`-Confirm [<SwitchParameter>]` Confirm each action in the script.
150
+
+`-Approve [<SwitchParameter>]` Provide the approval for the installation to start with no confirmation prompt for the listed VM's/Virtual Machine Scale Sets.
151
+
152
+
The script supports wildcards for `-Name` and `-ResourceGroup`. For example, `-Name vm*` enables VM insights for all VMs and Virtual Machine Scale Sets that start with "vm". For more information, see [Wildcards in Windows PowerShell](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_wildcards).
0 commit comments