19 Apr 2022 02:58 PM - last edited on 19 Apr 2022 03:17 PM by Karolina_Linda
Hi All,
I recently did a OneAgent deployment to a large volume of Virtual Machines in Azure via PowerShell and noticed that the Dynatrace Documentation doesnt cover how to install the Dynatrace OneAgent VM Extension in Infrastructure Only Mode. (The Documentation uses the depreciated AzureRM Module and doesnt cover the syntax for the settings to enable Infrastructure Only mode on installation). Thought i would drop this here in case anyone runs into the same issue, hopefully it makes someone's life a little easier.
This script can be modified to suit any specific situation, in this example you can simply export the VM's from the Virtual Machine blade in Azure into a csv (in this case i targeted windows VM's) and change the column header "Resource Group" to "ResourceGroup". Good for large deployments where you only want to target a single subscription at a time for a rollout. Simply fill in the < >
Remember to Import the .Az module and use Get-AzSubscription to find the correct subscription ID and then Set-AzContext -Subscription <Subscription ID Here> to set the context to the desired subscription
PowerShell Script:
$Importfile=Import-csv <File Path Here>
Foreach ($Import in $Imports) {
$ResourceGroup=$Import.ResourceGroup
$VMName=$Import.Name
$Location=$Import.Location
Set-AzVmExtension -Name Dynatrace.OneAgent -Publisher dynatrace.ruxit -ResourceGroupName $ResourceGroup -Location $Location -VMName $Name -ExtensionType "oneAgentwindows" -TypeHandlerVersion "1.0" -NoWait -Settings @{ "tenantId"="<TenantID Here>"; "token"="<Token Here>"; "enableLogAnalytics"="yes"; “installerArguments”=”--set-infra-only=true --set-host-group=<Host Group Name Here>” } -erroraction continue }
11 Jan 2023 03:55 PM
Great Tip @JonathanV
02 Oct 2023 05:28 PM
Nice one Jonathan, do I require admin privileges to the VM to be able to carry out the installation? Also must I log in to the VMs be able to carry out the installation