DSCClassResources/ClusterSharedVolume/ClusterSharedVolume.psm1
[DscResource()] class ClusterSharedVolume { [DscProperty(Key)] [string] $ClusterName [DscProperty(Mandatory=$false)] [String]$NodeName = $env:COMPUTERNAME [DscProperty(NotConfigurable)] [String]$StoragePoolName [DscProperty(Mandatory=$false)] [String]$CsvFriendlyName = "CSV" [DscProperty(Mandatory)] [int64]$CsvSize # Gets the resource's current state. [ClusterSharedVolume] Get() { $volume = Get-Volume -FriendlyName $this.CsvFriendlyName $this.StoragePoolName = (Get-StoragePool | Where-Object {$_.IsClustered -and $_.IsPrimordial -eq $false}).FriendlyName $this.CsvSize = $volume.Size / 1GB return $this } # Sets the desired state of the resource. [void] Set() { try { $storagePool = Get-StoragePool | Where-Object {$_.IsClustered -and $_.IsPrimordial -eq $false} $this.StoragePoolName = $storagePool.FriendlyName } catch { throw "Could not find eligable Storage Pool: $($error[0].exception.message)" } try { New-Volume -FriendlyName $this.CsvFriendlyName -FileSystem CSVFS_ReFS -StoragePoolFriendlyName $this.StoragePoolName -Size $this.CsvSize } catch { throw "Could not create Volume: $($error[0].exception.message)" } } # Tests if the resource is in the desired state. [bool] Test() { $volume = Get-Volume -FriendlyName $this.CsvFriendlyName -ErrorAction SilentlyContinue if ($volume) { return $true } else { return $false } } } |