Skip to content

Commit 7817a0e

Browse files
committed
updated
1 parent 49c158d commit 7817a0e

File tree

1 file changed

+49
-17
lines changed

1 file changed

+49
-17
lines changed

articles/azure-monitor/vm/vminsights-enable-powershell.md

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This article describes how to enable VM insights on Azure virtual machines by us
1414
- Azure Virtual Machines
1515
- Azure Virtual Machine Scale Sets
1616

17-
This script installs VM extensions for Log Analytics/Azure Monitoring Agent (AMA) and Dependency 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 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.
1818

1919
[!INCLUDE [Log Analytics agent deprecation](../../../includes/log-analytics-agent-deprecation.md)]
2020

@@ -31,47 +31,55 @@ You need to:
3131
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:
3232

3333
- 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 group specified by `-ResourceGroup`.
35+
- A single VM or virtual machine scale set specified by `-Name`.
3636

3737

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.
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. 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.
3939

4040
For a list of the script's argument details and example usage, run `Get-Help`.
4141

4242
```powershell
4343
Get-Help Install-VMInsights.ps1 -Detailed
4444
```
4545

46-
Use the script to enable VM insights using Azure Monitoring Agent and Dependency Agent, or Log Analytics Agent.
46+
Use the script to enable VM insights using Azure Monitoring Agent and Dependency Agent, or Log Analytics Agent.
4747

4848

4949

5050
### [Azure Monitor Agent](#tab/AMA)
5151

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.
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/Virtual Machine Scale Set. The UAMI settings are passed to the Azure Monitor Agent extension.
5353

5454
```powershell
5555
Install-VMInsights.ps1 -SubscriptionId <SubscriptionId> `
5656
[-ResourceGroup <ResourceGroup>] `
5757
[-ProcessAndDependencies ] `
58-
[-Name <MV or VMSS name>] `
58+
[-Name <MV or Virtual Machine Scale Set name>] `
5959
-DcrResourceId <DataCollectionRuleResourceId> `
6060
-UserAssignedManagedIdentityName <UserAssignedIdentityName> `
6161
-UserAssignedManagedIdentityResourceGroup <UserAssignedIdentityResourceGroup>
6262
6363
```
6464

6565
Required Arguments:
66-
+ `-SubscriptionId <String>` Azure subscription ID.
67-
+ `-DcrResourceId <String> ` Data Collection Rule (DCR) Azure resource ID identifier.
68-
+ `-UserAssignedManagedIdentityResourceGroup <String> ` Name of User Assigned Managed Identity (UAMI) resource group.
69-
+ `-UserAssignedManagedIdentityName <String> ` Name of User Assigned Managed Identity (UAMI).
66+
+ `-SubscriptionId <String>` Azure subscription ID.
67+
+ `-DcrResourceId <String> ` Data Collection Rule (DCR) Azure resource ID identifier.
68+
+ `-UserAssignedManagedIdentityResourceGroup <String> ` Name of User Assigned Managed Identity (UAMI) resource group.
69+
+ `-UserAssignedManagedIdentityName <String> ` Name of User Assigned Managed Identity (UAMI).
70+
7071

7172
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.
73+
+ `-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.
74+
+ `- 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.
75+
+ `- 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.
76+
+ `-PolicyAssignmentName <String>` Only include VMs associated with this policy. When the PolicyAssignmentName parameter is specified, the VMs part of the parameter SubscriptionId are considered.
77+
+ `-TriggerVmssManualVMUpdate [<SwitchParameter>]` Trigger the update of VM instances in a scale set whose upgrade policy is set to Manual.
78+
+ `-WhatIf [<SwitchParameter>]` Get info about expected effect of the commands in the script.
79+
+ `-Confirm [<SwitchParameter>]` Confirm each VM / Virtual Machine Scale Set.
80+
+ `-Approve [<SwitchParameter>]` Provide the approval for the installation to start with no confirmation prompt for the listed VM's/Virtual Machine Scale Sets.
81+
82+
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).
7583

7684
Example:
7785
```azurepowershell
@@ -89,10 +97,10 @@ The output has the following format:
8997
```powershell
9098
Name Account SubscriptionName Environment TenantId
9199
---- ------- ---------------- ----------- --------
92-
AzMon001 12345678-abcd-123… MSI@9876 AzMon001 AzureCloud abcd1234-9876-abcd-1234-1234abcd5648
100+
AzMon001 12345678-abcd-123… MSI@9876 AzMon001 AzureCloud abcd1234-9876-abcd-1234-1234abcd5648
93101
94102
Getting list of VMs or VM Scale Sets matching specified criteria.
95-
VMs and VMSS matching selection criteria :
103+
VMs and Virtual Machine Scale Sets matching selection criteria :
96104
97105
ResourceGroup : rg-AMAPowershell
98106
vmAMAPowershellWindows
@@ -125,6 +133,30 @@ VMSS Instance Upgrade Failures : 0
125133

126134
### [Log Analytics Agent](#tab/LogAnalyticsAgent)
127135

136+
137+
Required Arguments:
138+
+ `-WorkspaceId <String>` Log Analytics WorkspaceID (GUID).
139+
+ `-WorkspaceKey <String>`Log Analytics Workspace primary or secondary key.
140+
141+
Optional Arguments:
142+
+ `-ReInstall [<SwitchParameter>]` Trigger removal of existing Log analytics extension and reinstallation to migrate log analytics workspaces with Legacy Agent (Linux) - OMSAgent.
143+
+ `- 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.
144+
+ `- 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.
145+
+ `-PolicyAssignmentName <String>` Only include VMs associated with this policy. When the PolicyAssignmentName parameter is specified, the VMs part of the parameter SubscriptionId are considered.
146+
+ `-TriggerVmssManualVMUpdate [<SwitchParameter>]` Trigger the update of VM instances in a scale set whose upgrade policy is set to Manual.
147+
+ `-WhatIf [<SwitchParameter>]` Get info about expected effect of the commands in the script.
148+
+ `-Confirm [<SwitchParameter>]` Confirm each VM / Virtual Machine Scale Set.
149+
+ `-Approve [<SwitchParameter>]` Provide the approval for the installation to start with no confirmation prompt for the listed VM's/Virtual Machine Scale Sets.
150+
151+
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).
152+
153+
154+
Example
155+
Install-VMInsights.ps1 -WorkspaceId <WorkspaceId> -WorkspaceKey <WorkspaceKey> -SubscriptionId <SubscriptionId> -ResourceGroup <ResourceGroup>
156+
Install-VMInsights.ps1 -WorkspaceId <WorkspaceId> -WorkspaceKey <WorkspaceKey> -SubscriptionId <SubscriptionId> -ResourceGroup <ResourceGroup> -ReInstall
157+
158+
159+
128160
Use the following command to enable VM insights using Log Analytics Agent and Dependency Agent.
129161

130162

@@ -184,7 +216,7 @@ Failed: (0)
184216

185217
---
186218

187-
Check your VM/VMSS in Azure portal to see if the extensions are installed or use the following command:
219+
Check your VM/Virtual Machine Scale Set in Azure portal to see if the extensions are installed or use the following command:
188220

189221
```powershell
190222

0 commit comments

Comments
 (0)