From a45d0e2fbbbf1e46c4ee952408e4a0db03de7bcf Mon Sep 17 00:00:00 2001 From: Christian Stein Date: Tue, 10 Mar 2020 17:01:43 +0100 Subject: [PATCH] Use NETBIOS name for non-domain hosts instead of hostname Fixes #49 --- lib/core/icingaagent/getters/Get-IcingaNetbiosName.psm1 | 6 ++++++ lib/core/tools/Get-IcingaUserSID.psm1 | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 lib/core/icingaagent/getters/Get-IcingaNetbiosName.psm1 diff --git a/lib/core/icingaagent/getters/Get-IcingaNetbiosName.psm1 b/lib/core/icingaagent/getters/Get-IcingaNetbiosName.psm1 new file mode 100644 index 0000000..3414891 --- /dev/null +++ b/lib/core/icingaagent/getters/Get-IcingaNetbiosName.psm1 @@ -0,0 +1,6 @@ +function Get-IcingaNetbiosName() +{ + $ComputerData = Get-WmiObject Win32_ComputerSystem; + + return $ComputerData.Name; +} diff --git a/lib/core/tools/Get-IcingaUserSID.psm1 b/lib/core/tools/Get-IcingaUserSID.psm1 index a6822ac..422d784 100644 --- a/lib/core/tools/Get-IcingaUserSID.psm1 +++ b/lib/core/tools/Get-IcingaUserSID.psm1 @@ -12,7 +12,7 @@ function Get-IcingaUserSID() $Domain = $TmpArray[0]; $Username = $TmpArray[1]; } else { - $Domain = Get-IcingaHostname; + $Domain = Get-IcingaNetbiosName; $Username = $User; }