DSCClassResources/ClusterFileServer/ClusterFileServer.psm1
[DscResource()] class ClusterFileServer { [DscProperty(Key)] [string] $FileServerName [DscProperty(Mandatory)] [string] $ClusterName [DscProperty(Mandatory=$false)] [String]$NodeName = $env:COMPUTERNAME [DscProperty(Mandatory=$false)] [String[]]$StaticAddress [DscProperty(Mandatory)] [String]$VirtualDiskName [DscProperty(NotConfigurable)] [String]$State [DscProperty(NotConfigurable)] [bool]$IsPresent # Gets the resource's current state. [ClusterFileServer] Get() { $ErrorActionPreference = "Stop" $this.IsPresent = $false try { $clusterGroup = Get-ClusterGroup -Name GLIMSQAAPPFS $this.IsPresent = $true } catch [System.Management.Automation.ActionPreferenceStopException] { throw "No such Cluster Group: $($this.FileServerName)" } $this.State = $clusterGroup.State return $this } # Sets the desired state of the resource. [void] Set() { $clusterDiskName = "Cluster Virtual Disk ($($this.VirtualDiskName))" $fsParam = @{ Storage = $clusterDiskName Name = $this.FileServerName #Cluster = $this.ClusterName } if ($this.StaticAddress) { $fsParam.Add("StaticAddress",$this.StaticAddress) } Add-ClusterFileServerRole @fsParam } # Tests if the resource is in the desired state. [bool] Test() { $clusterGroup = $this.Get() if ($clusterGroup.IsPresent) { return $true } else { return $false } } } |