Fix Host FQDN building

Fixes #9 to ensure the hostname is always build properly, regardless of Domain, DNS Suffix or Hostname
This commit is contained in:
LordHepipud 2018-12-07 18:20:04 +01:00
parent 071d1f3c19
commit 09e406b90c
2 changed files with 2 additions and 10 deletions

View file

@ -17,11 +17,7 @@ $Checker | Add-Member -membertype ScriptMethod -name 'Start' -value {
$WindowsInformations = Get-CimInstance Win32_OperatingSystem; $WindowsInformations = Get-CimInstance Win32_OperatingSystem;
$this.version = $WindowsInformations.CimInstanceProperties['Version'].Value; $this.version = $WindowsInformations.CimInstanceProperties['Version'].Value;
$this.os = $WindowsInformations.CimInstanceProperties['Caption'].Value; $this.os = $WindowsInformations.CimInstanceProperties['Caption'].Value;
$this.fqdn = [string]::Format( $this.fqdn = [System.Net.Dns]::GetHostEntry('localhost').HostName;
'{0}.{1}',
(Get-WmiObject Win32_ComputerSystem).DNSHostName,
(Get-WmiObject win32_computersystem).Domain
);
$Icinga2.Log.Write( $Icinga2.Log.Write(
$Icinga2.Enums.LogState.Info, $Icinga2.Enums.LogState.Info,

View file

@ -24,11 +24,7 @@ $SSL | Add-Member -membertype ScriptMethod -name 'LoadServerCertificate' -value
# Try to discover the certificate based on our FQDN # Try to discover the certificate based on our FQDN
if ([string]::IsNullOrEmpty($CertName) -eq $TRUE -And [string]::IsNullOrEmpty($CertThumbprint) -eq $TRUE) { if ([string]::IsNullOrEmpty($CertName) -eq $TRUE -And [string]::IsNullOrEmpty($CertThumbprint) -eq $TRUE) {
$CertName = [string]::Format( $CertName = [System.Net.Dns]::GetHostEntry('localhost').HostName;
'{0}.{1}',
(Get-WmiObject Win32_ComputerSystem).DNSHostName,
(Get-WmiObject win32_computersystem).Domain
);
$Icinga2.Log.Write( $Icinga2.Log.Write(
$Icinga2.Enums.LogState.Info, $Icinga2.Enums.LogState.Info,