Skip to content

Commit

Permalink
DFSNamespaceRoot, DFSNamespaceFolder - Support for setting the root /…
Browse files Browse the repository at this point in the history
… folder State (#133)

- DFSNamespaceRoot
  - Added support for setting the state of the namespace root (State).
  - State and TargetState are only set to 'Online' when specifically passed in the configuration.
- DFSNamespaceFolder
  - Added support for setting the state of the namespace folder (State).
  - State and TargetState are only set to 'Online' when specifically passed in the configuration.
  • Loading branch information
Borgquite authored Feb 15, 2024
1 parent 142b485 commit 929c73d
Show file tree
Hide file tree
Showing 13 changed files with 200 additions and 36 deletions.
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- DFSNamespaceRoot
- Added support for setting the state of the namespace root (State).
- DFSNamespaceFolder
- Added support for setting the state of the namespace folder (State).
- DFSNamespaceServerConfiguration
- Added support for setting EnableSiteCostedReferrals, EnableInsiteReferrals and PreferLogonDC on a DFS namespace server
- Added support for setting EnableSiteCostedReferrals, EnableInsiteReferrals and PreferLogonDC on a DFS namespace server.

### Fixed

- DFSNamespaceRoot
- State and TargetState are only set to 'Online' when specifically passed in the configuration.
- DFSNamespaceFolder
- State and TargetState are only set to 'Online' when specifically passed in the configuration.
- Updated out of date README.MD.

## [5.0.1] - 2023-09-07
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ $script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US'
.PARAMETER Ensure
Specifies if the DFS Namespace root should exist.
.PARAMETER TargetState
Specifies the state of the DFS namespace folder target.
#>
function Get-TargetResource
{
Expand All @@ -39,12 +36,7 @@ function Get-TargetResource
[Parameter()]
[ValidateSet('Present','Absent')]
[System.String]
$Ensure = 'Present',

[Parameter()]
[ValidateSet('Offline','Online')]
[System.String]
$TargetState = 'Online'
$Ensure = 'Present'
)

Write-Verbose -Message ( @(
Expand Down Expand Up @@ -159,6 +151,9 @@ function Get-TargetResource
.PARAMETER ReferralPriorityRank
Specifies the priority rank, as an integer, for a root target of the DFS namespace.
.PARAMETER State
Specifies the state of the DFS namespace folder.
#>
function Set-TargetResource
{
Expand All @@ -181,7 +176,7 @@ function Set-TargetResource
[Parameter()]
[ValidateSet('Offline','Online')]
[System.String]
$TargetState = 'Online',
$TargetState,

[Parameter()]
[System.String]
Expand All @@ -206,7 +201,12 @@ function Set-TargetResource

[Parameter()]
[System.UInt32]
$ReferralPriorityRank
$ReferralPriorityRank,

[Parameter()]
[ValidateSet('Offline','Online')]
[System.String]
$State
)

Write-Verbose -Message ( @(
Expand All @@ -228,8 +228,16 @@ function Set-TargetResource
[System.Boolean] $folderChange = $false

# The Folder properties that will be updated
$folderProperties = @{
State = 'Online'
$folderProperties = @{}

# Check the target properties
if (($State) `
-and ($folder.State -ne $State))
{
$folderProperties += @{
State = $State
}
$folderChange = $true
}

if (($Description) `
Expand Down Expand Up @@ -445,6 +453,9 @@ function Set-TargetResource
.PARAMETER ReferralPriorityRank
Specifies the priority rank, as an integer, for a root target of the DFS namespace.
.PARAMETER State
Specifies the state of the DFS namespace folder.
#>
function Test-TargetResource
{
Expand All @@ -468,7 +479,7 @@ function Test-TargetResource
[Parameter()]
[ValidateSet('Offline','Online')]
[System.String]
$TargetState = 'Online',
$TargetState,

[Parameter()]
[System.String]
Expand All @@ -493,7 +504,12 @@ function Test-TargetResource

[Parameter()]
[System.UInt32]
$ReferralPriorityRank
$ReferralPriorityRank,

[Parameter()]
[ValidateSet('Offline','Online')]
[System.String]
$State
)

Write-Verbose -Message ( @(
Expand All @@ -517,6 +533,17 @@ function Test-TargetResource
# The Namespace Folder exists and should

# Check the Namespace parameters
if (($State) `
-and ($folder.State -ne $State))
{
Write-Verbose -Message ( @(
"$($MyInvocation.MyCommand): "
$($script:localizedData.NamespaceFolderParameterNeedsUpdateMessage) `
-f $Path,'State'
) -join '' )
$desiredConfigurationMatch = $false
}

if (($Description) `
-and ($folder.Description -ne $Description))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ class DSC_DFSNamespaceFolder : OMI_BaseResource
[Write, Description("Specifies the target priority class for a DFS namespace root."), ValueMap{"Global-High","SiteCost-High","SiteCost-Normal","SiteCost-Low","Global-Low"}, Values{"Global-High","SiteCost-High","SiteCost-Normal","SiteCost-Low","Global-Low"}] String ReferralPriorityClass;
[Write, Description("Specifies the priority rank, as an integer, for a root target of the DFS namespace.")] Uint32 ReferralPriorityRank;
[Write, Description("Specifies a TTL interval, in seconds, for referrals.")] Uint32 TimeToLiveSec;
[Read] String State;
[Write, Description("Specifies the state of the DFS namespace folder."), ValueMap{"Offline","Online"}, Values{"Offline","Online"}] String State;
};
58 changes: 43 additions & 15 deletions source/DSCResources/DSC_DFSNamespaceRoot/DSC_DFSNamespaceRoot.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ $script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US'
.PARAMETER Ensure
Specifies if the DFS Namespace root should exist.
.PARAMETER TargetState
Specifies the state of the DFS namespace root target.
.PARAMETER Type
Specifies the type of a DFS namespace as a Type object.
#>
Expand All @@ -44,11 +41,6 @@ function Get-TargetResource
[System.String]
$Ensure = 'Present',

[Parameter()]
[ValidateSet('Offline','Online')]
[System.String]
$TargetState = 'Online',

[Parameter(Mandatory = $true)]
[ValidateSet('Standalone','DomainV1','DomainV2')]
[System.String]
Expand Down Expand Up @@ -183,6 +175,9 @@ function Get-TargetResource
.PARAMETER ReferralPriorityRank
Specifies the priority rank, as an integer, for a root target of the DFS namespace.
.PARAMETER State
Specifies the state of the DFS namespace root.
#>
function Set-TargetResource
{
Expand All @@ -205,7 +200,7 @@ function Set-TargetResource
[Parameter()]
[ValidateSet('Offline','Online')]
[System.String]
$TargetState = 'Online',
$TargetState,

[Parameter(Mandatory = $true)]
[ValidateSet('Standalone','DomainV1','DomainV2')]
Expand Down Expand Up @@ -247,7 +242,12 @@ function Set-TargetResource

[Parameter()]
[System.UInt32]
$ReferralPriorityRank
$ReferralPriorityRank,

[Parameter()]
[ValidateSet('Offline','Online')]
[System.String]
$State
)

Write-Verbose -Message ( @(
Expand All @@ -269,9 +269,17 @@ function Set-TargetResource
[System.Boolean] $rootChange = $false

# The root properties that will be updated
$rootProperties = @{
State = 'Online'
}
$rootProperties = @{}

# Check the target properties
if (($State) `
-and ($root.State -ne $State))
{
$rootProperties += @{
State = $State
}
$rootChange = $true
} # if

if (($Description) `
-and ($root.Description -ne $Description))
Expand Down Expand Up @@ -526,6 +534,9 @@ function Set-TargetResource
.PARAMETER ReferralPriorityRank
Specifies the priority rank, as an integer, for a root target of the DFS namespace.
.PARAMETER State
Specifies the state of the DFS namespace root.
#>
function Test-TargetResource
{
Expand All @@ -549,7 +560,7 @@ function Test-TargetResource
[Parameter()]
[ValidateSet('Offline','Online')]
[System.String]
$TargetState = 'Online',
$TargetState,

[Parameter(Mandatory = $true)]
[ValidateSet('Standalone','DomainV1','DomainV2')]
Expand Down Expand Up @@ -591,7 +602,12 @@ function Test-TargetResource

[Parameter()]
[System.UInt32]
$ReferralPriorityRank
$ReferralPriorityRank,

[Parameter()]
[ValidateSet('Offline','Online')]
[System.String]
$State
)

Write-Verbose -Message ( @(
Expand Down Expand Up @@ -625,6 +641,18 @@ function Test-TargetResource
} # if

# Check the Namespace parameters
if (($State) `
-and ($root.State -ne $State))
{
Write-Verbose -Message ( @(
"$($MyInvocation.MyCommand): "
$($script:localizedData.NamespaceRootParameterNeedsUpdateMessage) `
-f $Type,$Path,'State'
) -join '' )

$desiredConfigurationMatch = $false
} # if

if (($Description) `
-and ($root.Description -ne $Description))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ class DSC_DFSNamespaceRoot : OMI_BaseResource
[Write, Description("Specifies the target priority class for a DFS namespace root."), ValueMap{"Global-High","SiteCost-High","SiteCost-Normal","SiteCost-Low","Global-Low"}, Values{"Global-High","SiteCost-High","SiteCost-Normal","SiteCost-Low","Global-Low"}] String ReferralPriorityClass;
[Write, Description("Specifies the priority rank, as an integer, for a root target of the DFS namespace.")] Uint32 ReferralPriorityRank;
[Write, Description("Specifies a TTL interval, in seconds, for referrals.")] Uint32 TimeToLiveSec;
[Read] String State;
[Write, Description("Specifies the state of the DFS namespace root."), ValueMap{"Offline","Online"}, Values{"Offline","Online"}] String State;
};
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Configuration DFSNamespaceFolder_Domain_MultipleTarget_Config
DFSNamespaceRoot DFSNamespaceRoot_Domain_Software_CA
{
Path = '\\contoso.com\software'
State = 'Online'
TargetPath = '\\ca-fileserver\software'
Ensure = 'Present'
Type = 'DomainV2'
Expand All @@ -67,6 +68,7 @@ Configuration DFSNamespaceFolder_Domain_MultipleTarget_Config
DFSNamespaceRoot DFSNamespaceRoot_Domain_Software_MA
{
Path = '\\contoso.com\software'
State = 'Online'
TargetPath = '\\ma-fileserver\software'
Ensure = 'Present'
Type = 'DomainV2'
Expand All @@ -77,6 +79,7 @@ Configuration DFSNamespaceFolder_Domain_MultipleTarget_Config
DFSNamespaceRoot DFSNamespaceRoot_Domain_Software_NY_01
{
Path = '\\contoso.com\software'
State = 'Online'
TargetPath = '\\ny-fileserver01\software'
Ensure = 'Present'
Type = 'DomainV2'
Expand All @@ -87,6 +90,7 @@ Configuration DFSNamespaceFolder_Domain_MultipleTarget_Config
DFSNamespaceRoot DFSNamespaceRoot_Domain_Software_NY_02
{
Path = '\\contoso.com\software'
State = 'Online'
TargetPath = '\\ny-fileserver02\software'
TargetState = 'Offline'
Ensure = 'Present'
Expand All @@ -99,6 +103,7 @@ Configuration DFSNamespaceFolder_Domain_MultipleTarget_Config
DFSNamespaceFolder DFSNamespaceFolder_Domain_SoftwareIT_CA
{
Path = '\\contoso.com\software\it'
State = 'Online'
TargetPath = '\\ca-fileserver\it'
Ensure = 'Present'
Description = 'AD Domain based DFS namespace for storing IT specific software installers'
Expand All @@ -108,6 +113,7 @@ Configuration DFSNamespaceFolder_Domain_MultipleTarget_Config
DFSNamespaceFolder DFSNamespaceFolder_Domain_SoftwareIT_MA
{
Path = '\\contoso.com\software\it'
State = 'Online'
TargetPath = '\\ma-fileserver\it'
Ensure = 'Present'
Description = 'AD Domain based DFS namespace for storing IT specific software installers'
Expand All @@ -117,6 +123,7 @@ Configuration DFSNamespaceFolder_Domain_MultipleTarget_Config
DFSNamespaceFolder DFSNamespaceFolder_Domain_SoftwareIT_NY_01
{
Path = '\\contoso.com\software\it'
State = 'Online'
TargetPath = '\\ny-fileserver01\it'
Ensure = 'Present'
Description = 'AD Domain based DFS namespace for storing IT specific software installers'
Expand All @@ -126,6 +133,7 @@ Configuration DFSNamespaceFolder_Domain_MultipleTarget_Config
DFSNamespaceFolder DFSNamespaceFolder_Domain_SoftwareIT_NY_02
{
Path = '\\contoso.com\software\it'
State = 'Online'
TargetPath = '\\ny-fileserver02\it'
Ensure = 'Present'
TargetState = 'Offline'
Expand Down
Loading

0 comments on commit 929c73d

Please sign in to comment.