Skip to content

Commit 3b3485b

Browse files
committed
powershell no-logo
1 parent cb50984 commit 3b3485b

File tree

1 file changed

+4
-1
lines changed
  • apm-agent-core/src/main/java/co/elastic/apm/agent/impl/metadata

1 file changed

+4
-1
lines changed

apm-agent-core/src/main/java/co/elastic/apm/agent/impl/metadata/SystemInfo.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,10 @@ static String fallbackHostnameDiscovery(boolean isWindows) {
188188
static String discoverHostnameThroughCommand(boolean isWindows, long timeoutMillis) {
189189
String hostname;
190190
if (isWindows) {
191-
hostname = executeHostnameDiscoveryCommand(Arrays.asList("powershell.exe", "[System.Net.Dns]::GetHostEntry($env:computerName).HostName"), timeoutMillis);
191+
List<String> powershellCmd = Arrays.asList("powershell.exe",
192+
"-NoLogo", "-NonInteractive", "-NoProfile", "-ExecutionPolicy", "Bypass",
193+
"-Command", "[System.Net.Dns]::GetHostEntry($env:computerName).HostName");
194+
hostname = executeHostnameDiscoveryCommand(powershellCmd, timeoutMillis);
192195
if (hostname == null || hostname.isEmpty()) {
193196
hostname = executeHostnameDiscoveryCommand(Arrays.asList("cmd.exe", "/c", "hostname"), timeoutMillis);
194197
}

0 commit comments

Comments
 (0)