Skip to content

Instantly share code, notes, and snippets.

@estib
Last active September 7, 2019 03:17
Show Gist options
  • Save estib/cabd6338f05323338f8bacf4a871e7e7 to your computer and use it in GitHub Desktop.
Save estib/cabd6338f05323338f8bacf4a871e7e7 to your computer and use it in GitHub Desktop.
powershell install dd-agent on wiindows
Write-Host "Provisioning!"
Write-Host "Downlaoding DD-agent installation immage."
$image_url = "https://s3.amazonaws.com/ddagent-windows-stable/ddagent-cli-latest.msi"
$destin = ".\ddagent-cli-latest.msi"
(New-Object System.Net.WebClient).DownloadFile($image_url, $destin)
# find time for installation schedule, one minute from now
$nowp = (Get-Date).AddMinutes(1)
$runat = Get-Date -date $nowp -format "HH:mm"
Write-Host "Scheduling install of datadog agent at time ${runat}"
schtasks /create /RU "NT AUTHORITY\SYSTEM" /sc once /tn "Install_Datadog" /tr "Powershell.exe -File .\setup_2.ps1" /st ${runat} /RL HIGHEST
$DD_API_KEY = "YOUR_API_KEY"
$HOSTNAME = "YOUR_HOST_NAME"
$TAGS = "YOUR_TAGS_COMMA_DELIMITED"
msiexec /i .\ddagent-cli-latest.msi /l*v .\installation_log.txt /quiet APIKEY="$DD_API_KEY" HOSTNAME="$HOSTNAME" TAGS="$TAG"
# let install finish, takes only a couple seconds.
Start-Sleep -s 60
# stop agent for configuration
stop-service datadogagent
# optionally copy pre-configured integration configuration files to agent directories, like so:
Copy-Item -Path C:\my_configs\wmi_check.yaml -Destination C:\ProgramData\Datadog\conf.d\wmi_check.yaml
start-service datadogagent
@vivekreddychagam
Copy link

Should I run two scripts or either of that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment