This guide covers the Windows-specific details of running dtctl: PowerShell install and tips, shell completion, cmd.exe/WSL, and troubleshooting.
For the general, cross-platform installation reference (all platforms, binary downloads, updating, uninstalling), see INSTALLATION.md.
Open PowerShell and run:
irm https://raw.githubusercontent.com/Dynatrace/dtctl/main/install.ps1 | iexThis downloads the latest release, extracts it to %LOCALAPPDATA%\dtctl, and adds it to your PATH. Restart your terminal afterwards.
If you prefer to install manually:
Go to the releases page and download the Windows zip file for your architecture:
| Architecture | File |
|---|---|
| 64-bit (x86_64) | dtctl_VERSION_windows_amd64.zip |
| ARM64 | dtctl_VERSION_windows_arm64.zip |
Most Windows PCs use the amd64 variant. ARM64 is for devices like the Surface Pro X or Copilot+ PCs with Snapdragon processors.
Right-click the downloaded zip file and select Extract All, or use PowerShell:
Expand-Archive dtctl_*_windows_*.zip -DestinationPath "$env:LOCALAPPDATA\dtctl"This places dtctl.exe in %LOCALAPPDATA%\dtctl (typically C:\Users\<you>\AppData\Local\dtctl).
Add the directory to your user PATH so you can run dtctl from any terminal:
Option A -- PowerShell (recommended):
$binPath = "$env:LOCALAPPDATA\dtctl"
$userPath = [Environment]::GetEnvironmentVariable('Path', 'User')
if ($userPath -notlike "*$binPath*") {
[Environment]::SetEnvironmentVariable('Path', "$userPath;$binPath", 'User')
}Option B -- System Settings UI:
- Press
Win + R, typesysdm.cpl, and press Enter - Go to the Advanced tab and click Environment Variables
- Under User variables, select
Pathand click Edit - Click New and add:
%LOCALAPPDATA%\dtctl - Click OK to save
After changing PATH, restart your terminal (or run refreshenv if you have Chocolatey installed).
dtctl versionExpected output:
dtctl version X.Y.Z
commit: abc1234
built: 2025-01-01T00:00:00Z
Each release includes a checksums.txt file signed with cosign. To verify your download:
# Download checksums
Invoke-WebRequest "https://github.com/Dynatrace/dtctl/releases/latest/download/checksums.txt" -OutFile checksums.txt
# Compute the SHA256 of your zip file
$hash = (Get-FileHash dtctl_*_windows_*.zip -Algorithm SHA256).Hash.ToLower()
# Check it matches
Select-String $hash checksums.txtIf the Select-String command prints a matching line, the download is intact.
See INSTALLATION.md for build-from-source instructions (requires Go and Git). On Windows the build output is bin\dtctl.exe:
go build -o bin\dtctl.exe .
.\bin\dtctl.exe versionTab completion makes dtctl much faster to use. Add this line to your PowerShell profile so it loads automatically:
# Find your profile path
echo $PROFILE
# Edit it (creates the file if it doesn't exist)
if (!(Test-Path -Path $PROFILE)) { New-Item -ItemType File -Path $PROFILE -Force }
notepad $PROFILEAdd this line to the profile file:
dtctl completion powershell | Out-String | Invoke-ExpressionSave, close, and reopen PowerShell. You can now use Tab to complete commands:
dtctl get <Tab> # cycles through resource types
dtctl get workflows -o <Tab> # cycles through output formatsIf you use Git Bash, you can set up bash completions:
# Generate completion script
dtctl completion bash > ~/.dtctl-completion.bash
# Add to your ~/.bashrc
echo 'source ~/.dtctl-completion.bash' >> ~/.bashrc
source ~/.bashrcdtctl stores configuration and credentials under %LOCALAPPDATA%\dtctl:
| Item | Path |
|---|---|
| Config file | %LOCALAPPDATA%\dtctl\config |
| Cached data | %LOCALAPPDATA%\dtctl\cache |
| Credentials | Windows Credential Manager |
Credentials are stored securely in Windows Credential Manager (viewable via Control Panel > Credential Manager > Windows Credentials).
For the full configuration reference (contexts, credentials, safety levels, aliases, profiles), see CONFIGURATION.md. The example below shows the Windows/PowerShell specifics.
# OAuth login (recommended -- opens browser)
dtctl auth login --context my-env --environment "https://abc12345.apps.dynatrace.com"
# Or use a token
dtctl config set-context my-env `
--environment "https://abc12345.apps.dynatrace.com" `
--token-ref my-token
dtctl config set-credentials my-token `
--token "dt0s16.XXXXXXXX.YYYYYYYY"
# Verify connectivity
dtctl doctorNote: In PowerShell, use the backtick (`) for line continuation instead of backslash (\).
DQL string literals must use double quotes ("ERROR"); single quotes are a syntax error. Getting those double quotes through PowerShell intact is the single most common Windows problem with dtctl, so it is worth understanding the mechanism.
PS> dtctl query 'fetch logs | filter loglevel == "INFO" | limit 10' -o json
{
"records": []
}The same query returns rows in a Dynatrace notebook. Nothing is wrong with your query or your credentials — the double quotes never reached dtctl. Confirm it with -vv, which prints the request body dtctl actually sent:
PS> dtctl query 'fetch logs | filter loglevel == "INFO" | limit 10' -vv
...
BODY:
{"query":"fetch logs | filter loglevel == INFO | limit 10", ...}loglevel == INFO is valid DQL — it compares the loglevel field to a field named INFO. Both are unequal (or absent), so Grail returns an empty result and no error. That is why this fails silently instead of complaining.
dtctl detects this case by inspecting the raw command line and prints a warning before running the query, so you should not have to reach for -vv:
Warning: your shell stripped the double quotes from this query.
dtctl received: fetch logs | filter loglevel == INFO | limit 10
The query still runs — dtctl cannot know for certain that you meant a string literal — but the warning tells you why the result is empty.
Windows PowerShell 5.1 (the blue powershell.exe, still the default on most Windows machines) re-quotes every argument before handing it to a native .exe, and it does not escape double quotes that are inside the argument. dtctl receives "fetch logs | filter loglevel == "INFO" | limit 10", and the Windows command-line parser reads the inner quotes as end/start of quoting — so they vanish.
This affects every way of writing the query as an argument, including single-quoted strings and here-strings. A here-string is a plain string value, not a redirection like a bash heredoc, so dtctl query @'...'@ still goes through argument passing and still loses the quotes.
PowerShell 7.3 and later fixed this: $PSNativeCommandArgumentPassing defaults to Windows mode, which escapes arguments correctly for normal executables. Check which one you are on:
$PSVersionTable.PSVersionIf that prints 5.1.x, use one of the forms below. If it prints 7.3 or later, quoting an argument works as it does on Linux and macOS.
The pipeline sends bytes to stdin and never touches argument parsing, so quotes always survive. This is the recommended form:
@'
fetch logs
| filter loglevel == "INFO"
| limit 10
'@ | dtctl query -o jsonDo not write
dtctl query -f - @'...'@.-f -tells dtctl to read stdin while the here-string is passed as an argument, so the two disagree about where the query is. dtctl rejects that combination with a hint (older versions waited on the idle terminal and appeared to hang). Pipe it ('@ | dtctl query) instead, with or without-f -.
@'
fetch logs
| filter loglevel == "INFO"
| limit 10
'@ | Out-File -Encoding UTF8 query.dql
dtctl query -f query.dql
Get-Content query.dql | dtctl query # equivalentIf you must keep everything on one line in Windows PowerShell 5.1, escape the inner quotes with a backslash so the Windows parser hands them to dtctl:
dtctl query 'fetch logs | filter loglevel == \"INFO\" | limit 10'This is 5.1-specific: on PowerShell 7.3+ the backslashes are passed through literally and DQL rejects them. Prefer fix 1 or 2 in anything shared or scripted.
| Form | PowerShell 5.1 | PowerShell 7.3+ |
|---|---|---|
@'...'@ | dtctl query |
✅ works | ✅ works |
dtctl query -f query.dql |
✅ works | ✅ works |
dtctl query 'fetch ... "INFO"' |
❌ quotes lost | ✅ works |
dtctl query @'...'@ |
❌ quotes lost | ✅ works |
dtctl query -f - @'...'@ |
❌ rejected | ❌ rejected |
dtctl query 'fetch ... \"INFO\"' |
✅ works | ❌ literal \ |
When results look suspicious, -vv shows the exact query dtctl sent — always check there first.
See DQL Queries for more examples.
PowerShell uses the backtick (`) for line continuation, not backslash:
# Correct (PowerShell)
dtctl config set-context my-env `
--environment "https://abc12345.apps.dynatrace.com" `
--token-ref my-token
# Wrong (bash syntax -- won't work in PowerShell)
dtctl config set-context my-env \
--environment "https://abc12345.apps.dynatrace.com" \
--token-ref my-tokenPowerShell works well with JSON output for scripting:
# Parse JSON output
$workflows = dtctl get workflows -o json | ConvertFrom-Json
# Filter in PowerShell
$workflows | Where-Object { $_.title -like "*daily*" }
# Count resources
(dtctl get slos -o json | ConvertFrom-Json).CountThe environment URL lives in a context, not in an environment variable. Select a context (and point at a config file) like this:
# Temporary (current session)
$env:DTCTL_CONTEXT = "my-env"
# Persistent (current user)
[Environment]::SetEnvironmentVariable('DTCTL_CONTEXT', 'my-env', 'User')Other variables dtctl reads: DTCTL_CONFIG (explicit config path), DTCTL_TOKEN
(token, supplied out of band), DTCTL_OUTPUT, DTCTL_PROFILE, and the spill
settings. See CONFIGURATION.md for the full list.
dtctl works in all Windows Terminal profiles (PowerShell, cmd.exe, Git Bash, WSL). For the best experience, use Windows Terminal with PowerShell and enable completions as described above.
dtctl runs in cmd.exe, but shell completion is not available. Use PowerShell or Git Bash for the full experience.
rem Verify installation
dtctl version
rem Run a query (use double quotes only)
dtctl query "fetch logs | limit 5"If you use WSL, follow the Linux installation instructions instead -- install the Linux binary inside your WSL distribution, not the Windows binary.
Re-run the install script to update to the latest version:
irm https://raw.githubusercontent.com/Dynatrace/dtctl/main/install.ps1 | iexOr download the latest zip manually and extract to %LOCALAPPDATA%\dtctl.
# Remove the binary
Remove-Item -Recurse -Force "$env:LOCALAPPDATA\dtctl"
# Remove from PATH
$binPath = "$env:LOCALAPPDATA\dtctl"
$userPath = [Environment]::GetEnvironmentVariable('Path', 'User')
$newPath = ($userPath -split ';' | Where-Object { $_ -ne $binPath }) -join ';'
[Environment]::SetEnvironmentVariable('Path', $newPath, 'User')
# Remove configuration (optional -- also removes the binary if still present)
Remove-Item -Recurse -Force "$env:LOCALAPPDATA\dtctl"
# Remove stored credentials (optional)
# Open Control Panel > Credential Manager > Windows Credentials
# Delete entries starting with "dtctl"The binary is not in your PATH. Either:
- Use the full path:
& "$env:LOCALAPPDATA\dtctl\dtctl.exe" - Add the bin directory to your PATH (see step 3 above)
- Restart your terminal after modifying PATH
Check your PATH:
$env:Path -split ';' | Select-String dtctlIf extracting to Program Files or another protected location, run PowerShell as Administrator. Or install to %LOCALAPPDATA%\dtctl\bin (user-writable, no admin needed).
dtctl.exe is Authenticode-signed by Dynatrace from v0.46.0 on. If antivirus software still blocks it:
- Check the signature:
Get-AuthenticodeSignature (Get-Command dtctl).Sourceshould reportValid. A missing or invalid signature means the binary is not an official release. - Verify the checksum matches the official release (see Verify Download Integrity).
- If both check out, report the false positive to your antivirus vendor and file an issue with the product name and the detection name.
If PowerShell completions don't load, your execution policy may block profile scripts:
# Check current policy
Get-ExecutionPolicy
# Allow local scripts (recommended)
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUserIf you have both WSL and native Windows installs, make sure you're running the right binary:
# Check which dtctl you're running
Get-Command dtctl | Select-Object SourceInside WSL, use which dtctl instead.
- Quick Start Guide -- configure your environment and run your first commands
- Installation -- cross-platform installation reference
- Token Scopes -- required API permissions