cWINSClient.psm1
[DSCResource(RunAsCredential = "NotSupported")] class cWINSClient { [DscProperty(Key)] [string]$InterfaceAlias [DscProperty(Mandatory)] [string]$Address <# This method is equivalent of the Get-TargetResource script function. The implementation should use the keys to find appropriate resources. This method returns an instance of this class with the updated key properties. #> [cWINSClient] Get() { $AddressVariable = (Get-WmiObject win32_networkadapterconfiguration | Where IPEnabled -eq $true | Select WINSPrimaryServer).WinsPrimaryServer if($AddressVariable -ne $null) { $AddressVariable = $AddressVariable[1] }else { $AddressVariable = $null } #Instantiate a new object of class cWINSClient $cWINSClient = [cWINSClient]::new() #Assign the variables to properties of the class $cWINSClient.Address = $AddressVariable $cWINSClient.InterfaceAlias = $this.InterfaceAlias #Return the completed object return $cWINSClient } <# This method is equivalent of the Set-TargetResource script function. It sets the resource to the desired state. #> [void] Set() { netsh interface ip set wins name="$($this.InterfaceAlias)" source=static addr=$($this.Address); } <# This method is equivalent of the Test-TargetResource script function. It should return True or False, showing whether the resource is in a desired state. #> [bool] Test() { return $this.Get().Address -eq $this.Address } } |