Skip to content

Instantly share code, notes, and snippets.

@bunelr
Last active August 29, 2015 14:05
Show Gist options
  • Save bunelr/8388057b4284f2831b6f to your computer and use it in GitHub Desktop.
Save bunelr/8388057b4284f2831b6f to your computer and use it in GitHub Desktop.
Install The datadog Agent on Azure
set log=datadog-install.log
set api_key=%1
sc query | findstr DatadogAgent
if ERRORLEVEL 1 (
echo "Datadog Agent service not detected" >> %log%
echo "Starting the installation" >> %log%
reg query "HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5"| findstr /c:"Install REG_DWORD 0x1"
if ERRORLEVEL 1 (
echo "Installing .NET 3.5" >> %log%
powershell -Command "Import-Module ServerManager;Add-WindowsFeature -Name 'Net-Framework-Core'"
) else (
echo ".NET 3.5 already installed" >> %log%
)
if exist ddagent.msi (
echo "Already has the installer" >> %log%
) else (
echo "Fetching the Agent Installer" >> %log%
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('https://s3.amazonaws.com/ddagent-windows-stable/ddagent-cli.msi', 'ddagent.msi')"
)
echo "Starting the installer" >>%log%
msiexec.exe /qn /i ddagent.msi APIKEY=%api_key% /L+ %log%
) else (
echo "Agent already exists, skipping install" >>%log%
)
echo "Finished Install" >>%log%
exit 0
<Task commandLine="installDatadogAgent.cmd YOUR_API_KEY" executionContext="elevated" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment