Skip to content

Commit

Permalink
Merge pull request #69 from PowerShell/dev
Browse files Browse the repository at this point in the history
Release of version 4.1.0.0 of DFSDsc
  • Loading branch information
kwirkykat authored Jun 13, 2018
2 parents 831fdde + d48ed39 commit 2f85d4f
Show file tree
Hide file tree
Showing 11 changed files with 589 additions and 40 deletions.
6 changes: 5 additions & 1 deletion .MetaTestOptIn.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
"Common Tests - Validate Markdown Files",
"Common Tests - Validate Example Files",
"Common Tests - Validate Module Files",
"Common Tests - Validate Script Files"
"Common Tests - Validate Script Files",
"Common Tests - Required Script Analyzer Rules",
"Common Tests - Flagged Script Analyzer Rules",
"Common Tests - New Error-Level Script Analyzer Rules",
"Common Tests - Custom Script Analyzer Rules"
]
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

## Unreleased

## 4.1.0.0

- Added Hub and Spoke replication group example - fixes [Issue #62](https://github.com/PowerShell/DFSDsc/issues/62).
- Enabled PSSA rule violations to fail build - fixes [Issue #320](https://github.com/PowerShell/DFSDsc/issues/59).
- Allow null values in resource group members or folders - fixes [Issue #27](https://github.com/PowerShell/xDFS/issues/27).
- Added a CODE\_OF\_CONDUCT.md with the same content as in the README.md - fixes
[Issue #67](https://github.com/PowerShell/DFSDsc/issues/67).

## 4.0.0.0

- BREAKING CHANGE
Expand Down
6 changes: 6 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Code of conduct

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
or contact [[email protected]](mailto:[email protected]) with any additional
questions or comments.
30 changes: 7 additions & 23 deletions Modules/DFSDsc/DFSDsc.psd1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@{
# Version number of this module.
moduleVersion = '4.0.0.0'
moduleVersion = '4.1.0.0'

# ID used to uniquely identify this module
GUID = '3bcb9c66-ea0b-4675-bd46-c390a382c388'
Expand Down Expand Up @@ -48,32 +48,16 @@
ProjectUri = 'https://github.com/PowerShell/DFSDsc'

# ReleaseNotes of this module
ReleaseNotes = '- BREAKING CHANGE
- Renamed xDFS to DFSDsc - fixes [Issue 55](https://github.com/PowerShell/xDFS/issues/55).
- Changed all MSFT_xResourceName to MSFT_DFSResourceName.
- Updated DSCResources, Examples, Modules and Tests for new naming.
- Updated Year to 2018 in License and Manifest.
- Changed all Modules\DFSDsc\Examples\Resources to DFSResourceName.
- Added the VS Code PowerShell extension formatting settings that cause PowerShell
files to be formatted as per the DSC Resource kit style guidelines.
- Improve layout of badge area in README.MD.
- Disabled MD013 rule checking to enable badge table.
- Updated Year to 2017 in License and Manifest.
- Added .github support files:
- CONTRIBUTING.md
- ISSUE_TEMPLATE.md
- PULL_REQUEST_TEMPLATE.md
- Opted into Common Tests "Validate Module Files" and "Validate Script Files".
- Converted files with UTF8 with BOM over to UTF8 - fixes [Issue 47](https://github.com/PowerShell/xDFS/issues/47).
- Added `Documentation and Examples` section to Readme.md file - see
[issue 49](https://github.com/PowerShell/xDFS/issues/49).
- Prevent unit tests from DSCResource.Tests from running during test
execution - fixes [Issue 51](https://github.com/PowerShell/xDFS/issues/51).
- Updated tests to meet Pester V4 guidelines - fixes [Issue 53](https://github.com/PowerShell/xDFS/issues/53).
ReleaseNotes = '- Added Hub and Spoke replication group example - fixes [Issue 62](https://github.com/PowerShell/DFSDsc/issues/62).
- Enabled PSSA rule violations to fail build - fixes [Issue 320](https://github.com/PowerShell/DFSDsc/issues/59).
- Allow null values in resource group members or folders - fixes [Issue 27](https://github.com/PowerShell/xDFS/issues/27).
- Added a CODE\_OF\_CONDUCT.md with the same content as in the README.md - fixes
[Issue 67](https://github.com/PowerShell/DFSDsc/issues/67).
'
} # End of PSData hashtable
} # End of PrivateData hashtable
}



Original file line number Diff line number Diff line change
Expand Up @@ -626,37 +626,83 @@ function Test-TargetResource

# Compare the Members
$existingMembers = @((Get-DfsrMember @replicationGroupParameters -ErrorAction Stop).DnsName)
if ((Compare-Object `
-ReferenceObject $fqdnMembers `
-DifferenceObject $existingMembers).Count -ne 0)
<#
check for null values before using compare-object
if one is null but not both then report difference
if neither are null then compare values
#>
if ([String]::IsNullOrEmpty($existingMembers) -and [String]::IsNullOrEmpty($fqdnMembers))
{
# There is a member different of some kind.
# both are null so no difference found
}
elseif ([String]::IsNullOrEmpty($existingMembers) -xor [String]::IsNullOrEmpty($fqdnMembers))
{
# There is a member difference of some kind.
Write-Verbose -Message ( @(
"$($MyInvocation.MyCommand): "
$($LocalizedData.ReplicationGroupMembersNeedUpdateMessage) `
-f $GroupName
) -join '' )

$desiredConfigurationMatch = $false
} # if
}
else
{
# neither variables are null so it's safe to use compare-object
if ((Compare-Object `
-ReferenceObject $fqdnMembers `
-DifferenceObject $existingMembers).Count -ne 0)
{
# There is a member difference of some kind.
Write-Verbose -Message ( @(
"$($MyInvocation.MyCommand): "
$($LocalizedData.ReplicationGroupMembersNeedUpdateMessage) `
-f $GroupName
) -join '' )

$desiredConfigurationMatch = $false
} # if
}

# Compare the Folders
$existingFolders = @((Get-DfsReplicatedFolder @replicationGroupParameters -ErrorAction Stop).FolderName)

if ((Compare-Object `
-ReferenceObject $Folders `
-DifferenceObject $existingFolders).Count -ne 0)
<#
check for null values before using compare-object
if one is null but not both then report difference
if neither are null then compare values
#>
if ([String]::IsNullOrEmpty($existingFolders) -and [String]::IsNullOrEmpty($Folders))
{
# There is a folder different of some kind.
# both are null so no difference found
}
elseif ([String]::IsNullOrEmpty($existingFolders) -xor [String]::IsNullOrEmpty($Folders))
{
# There is a folder difference of some kind.
Write-Verbose -Message ( @(
"$($MyInvocation.MyCommand): "
$($LocalizedData.ReplicationGroupFoldersNeedUpdateMessage) `
-f $GroupName
) -join '' )

$desiredConfigurationMatch = $false
} # if

}
else
{
# neither variables are null so it's safe to use compare-object
if ((Compare-Object `
-ReferenceObject $Folders `
-DifferenceObject $existingFolders).Count -ne 0)
{
# There is a folder difference of some kind.
Write-Verbose -Message ( @(
"$($MyInvocation.MyCommand): "
$($LocalizedData.ReplicationGroupFoldersNeedUpdateMessage) `
-f $GroupName
) -join '' )

$desiredConfigurationMatch = $false
} # if
}
# Get the content paths (if any were passed in the array)
if ($ContentPaths)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<#
.EXAMPLE
Create a Hub and Spoke style DFS Replication Group called WebSite
containing one Hub member and one or more Spoke members. The name of
the Hub computer is passed in the HubComputerName parameter and
defaults to 'Hub'. The Hub member contains a folder called WebSiteFiles
with the path 'd:\inetpub\wwwroot\WebSiteFiles'. This path is
replicated to all members of the SpokeComputerName parameter array
into the 'd:\inetpub\wwwroot\WebSiteFiles' folder. The spoke
computers are passed in the SpokeComputerName parameter and
defaults to 'Spoke1', 'Spoke2' and 'Spoke3'.
#>
Configuration Example
{
param
(
[Parameter()]
[System.String[]]
$NodeName = 'localhost',

[Parameter()]
[PSCredential]
$Credential,

[Parameter()]
[System.String]
$HubComputerName = 'Hub',

[Parameter()]
[System.String[]]
$SpokeComputerName = @('Spoke1','Spoke2','Spoke3')
)

Import-DscResource -Module DFSDsc

Node $NodeName
{
<#
Install the Prerequisite features first
Requires Windows Server 2012 R2 Full install
#>
WindowsFeature RSATDFSMgmtConInstall
{
Ensure = 'Present'
Name = 'RSAT-DFS-Mgmt-Con'
}

# Configure the Replication Group
DFSReplicationGroup RGWebSite
{
GroupName = 'WebSite'
Description = 'Files for web server'
Ensure = 'Present'
Members = @() + $HubComputerName + $SpokeComputerName
Folders = 'WebSiteFiles'
PSDSCRunAsCredential = $Credential
DependsOn = '[WindowsFeature]RSATDFSMgmtConInstall'
} # End of RGWebSite Resource

DFSReplicationGroupFolder RGWebSiteFolder
{
GroupName = 'WebSite'
FolderName = 'WebSiteFiles'
Description = 'DFS Share for replicating web site files'
PSDSCRunAsCredential = $Credential
DependsOn = '[DFSReplicationGroup]RGWebSite'
} # End of RGWebSiteFolder Resource

DFSReplicationGroupMembership RGWebSiteMembershipHub
{
GroupName = 'WebSite'
FolderName = 'WebSiteFiles'
ComputerName = $HubComputerName
ContentPath = 'd:\inetpub\wwwroot\WebSiteFiles'
PrimaryMember = $true
PSDSCRunAsCredential = $Credential
DependsOn = '[DFSReplicationGroupFolder]RGWebSiteFolder'
} # End of RGWebSiteMembershipHub Resource

# Configure the connection and membership for each Spoke
foreach ($spoke in $SpokeComputerName)
{
DFSReplicationGroupConnection "RGWebSiteConnection$spoke"
{
GroupName = 'WebSite'
Ensure = 'Present'
SourceComputerName = $HubComputerName
DestinationComputerName = $spoke
PSDSCRunAsCredential = $Credential
DependsOn = '[DFSReplicationGroupFolder]RGWebSiteFolder'
} # End of RGWebSiteConnection$spoke Resource

DFSReplicationGroupMembership "RGWebSiteMembership$spoke"
{
GroupName = 'WebSite'
FolderName = 'WebSiteFiles'
ComputerName = $spoke
ContentPath = 'd:\inetpub\wwwroot\WebSiteFiles'
PSDSCRunAsCredential = $Credential
DependsOn = "[DFSReplicationGroupConnection]RGWebSiteConnection$spoke"
} # End of RGWebSiteMembership$spoke Resource
}
} # End of Node
} # End of Configuration
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<#
.EXAMPLE
Create a Hub and Spoke style DFS Replication Group called WebSite
containing one Hub member and one or more Spoke members. The name of
the Hub computer is passed in the HubComputerName parameter and
defaults to 'Hub'. The Hub member contains a folder called WebSiteFiles
with the path 'd:\inetpub\wwwroot\WebSiteFiles'. This path is
replicated to all members of the SpokeComputerName parameter array
into the 'd:\inetpub\wwwroot\WebSiteFiles' folder. The spoke
computers are passed in the SpokeComputerName parameter and
defaults to 'Spoke1', 'Spoke2' and 'Spoke3'.
#>
Configuration Example
{
param
(
[Parameter()]
[System.String[]]
$NodeName = 'localhost',

[Parameter()]
[PSCredential]
$Credential,

[Parameter()]
[System.String]
$HubComputerName = 'Hub',

[Parameter()]
[System.String[]]
$SpokeComputerName = @('Spoke1','Spoke2','Spoke3')
)

Import-DscResource -Module DFSDsc

Node $NodeName
{
<#
Install the Prerequisite features first
Requires Windows Server 2012 R2 Full install
#>
WindowsFeature RSATDFSMgmtConInstall
{
Ensure = 'Present'
Name = 'RSAT-DFS-Mgmt-Con'
}

# Configure the Replication Group
DFSReplicationGroup RGWebSite
{
GroupName = 'WebSite'
Description = 'Files for web server'
Ensure = 'Present'
Members = @() + $HubComputerName + $SpokeComputerName
Folders = 'WebSiteFiles'
PSDSCRunAsCredential = $Credential
DependsOn = '[WindowsFeature]RSATDFSMgmtConInstall'
} # End of RGWebSite Resource

DFSReplicationGroupFolder RGWebSiteFolder
{
GroupName = 'WebSite'
FolderName = 'WebSiteFiles'
Description = 'DFS Share for replicating web site files'
PSDSCRunAsCredential = $Credential
DependsOn = '[DFSReplicationGroup]RGWebSite'
} # End of RGWebSiteFolder Resource

DFSReplicationGroupMembership RGWebSiteMembershipHub
{
GroupName = 'WebSite'
FolderName = 'WebSiteFiles'
ComputerName = $HubComputerName
ContentPath = 'd:\inetpub\wwwroot\WebSiteFiles'
PrimaryMember = $true
PSDSCRunAsCredential = $Credential
DependsOn = '[DFSReplicationGroupFolder]RGWebSiteFolder'
} # End of RGWebSiteMembershipHub Resource

# Configure the connection and membership for each Spoke
foreach ($spoke in $SpokeComputerName)
{
DFSReplicationGroupConnection "RGWebSiteConnection$spoke"
{
GroupName = 'WebSite'
Ensure = 'Present'
SourceComputerName = $HubComputerName
DestinationComputerName = $spoke
PSDSCRunAsCredential = $Credential
DependsOn = '[DFSReplicationGroupFolder]RGWebSiteFolder'
} # End of RGWebSiteConnection$spoke Resource

DFSReplicationGroupMembership "RGWebSiteMembership$spoke"
{
GroupName = 'WebSite'
FolderName = 'WebSiteFiles'
ComputerName = $spoke
ContentPath = 'd:\inetpub\wwwroot\WebSiteFiles'
PSDSCRunAsCredential = $Credential
DependsOn = "[DFSReplicationGroupConnection]RGWebSiteConnection$spoke"
} # End of RGWebSiteMembership$spoke Resource
}
} # End of Node
} # End of Configuration
Loading

0 comments on commit 2f85d4f

Please sign in to comment.