diff --git a/lib/apm-client/http-apm-client/detect-hostname.js b/lib/apm-client/http-apm-client/detect-hostname.js index 282b528df4d..dc9be31f252 100644 --- a/lib/apm-client/http-apm-client/detect-hostname.js +++ b/lib/apm-client/http-apm-client/detect-hostname.js @@ -30,7 +30,15 @@ function detectHostname() { // https://learn.microsoft.com/en-us/dotnet/api/system.net.dns.gethostentry out = spawnSync( 'powershell.exe', - ['[System.Net.Dns]::GetHostEntry($env:computerName).HostName'], + [ + '-NoLogo', + '-NonInteractive', + '-NoProfile', + '-ExecutionPolicy', + 'Bypass', + '-Command', + '[System.Net.Dns]::GetHostEntry($env:computerName).HostName', + ], { encoding: 'utf8', shell: true, timeout: 2000 }, ); if (!out.error) {