RVR.workgroupDSCtooling.psm1
enum Ensure { Absent Present } [DscResource()] class SetDNSSuffix { [DscProperty(Key)] [String]$DomainName [void] Set() { # Set the primary DNS suffix. This is the domain portion of the FQDN. Set-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\" -Name "Domain" -Value $this.DomainName Set-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\" -Name "NV Domain" -Value $this.DomainName Write-Verbose "done setting primary DNS suffix to $($this.DomainName)" # Set the reboot flag. Write-Warning "The changes will take effect after you restart the computer." $global:DSCMachineStatus = 1 } [bool] Test() { $currentSuffix = (Get-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\" -Name "NV Domain" -ErrorAction SilentlyContinue)."NV Domain" Write-Verbose "The host FQDN is: $(([System.Net.Dns]::GetHostByName(($env:computerName))).Hostname)" if ($currentSuffix -ne $This.DomainName) { return $false } return $true } [SetDNSSuffix] Get() { #I'm not sure if i'm using this method properly. I'll have to check it out later... TODO $this.DomainName = (Get-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\" -Name "NV Domain" -ErrorAction SilentlyContinue)."NV Domain" return $this } } |