diff --git a/.MetaTestOptIn.json b/.MetaTestOptIn.json deleted file mode 100644 index 6f385f8..0000000 --- a/.MetaTestOptIn.json +++ /dev/null @@ -1,10 +0,0 @@ -[ - "Common Tests - Validate Markdown Files", - "Common Tests - Validate Example Files", - "Common Tests - Validate Module 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" -] diff --git a/.codecov.yml b/.codecov.yml deleted file mode 100644 index 411198f..0000000 --- a/.codecov.yml +++ /dev/null @@ -1,26 +0,0 @@ -codecov: - notify: - require_ci_to_pass: no - # dev should be the baseline for reporting - branch: dev - -comment: - layout: "reach, diff" - behavior: default - -coverage: - range: 50..80 - round: down - precision: 0 - - status: - project: - default: - # Set the overall project code coverage requirement to 70% - target: 70 - patch: - default: - # Set the pull request requirement to not regress overall coverage by more than 5% - # and let codecov.io set the goal for the code changed in the patch. - target: auto - threshold: 5 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9dbbd55 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,10 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text eol=crlf + +# Ensure any exe files are treated as binary +*.exe binary +*.jpg binary +*.xl* binary +*.pfx binary diff --git a/.gitignore b/.gitignore index 508c6d5..e19cdf5 100644 --- a/.gitignore +++ b/.gitignore @@ -2,14 +2,9 @@ *.user *.coverage .vs +.vscode .psproj .sln -DscResource.Tests -DscResource.Tests/* -Modules/DFSDsc/DscResource.Tests -Modules/DFSDsc/DscResource.Tests/* -node_modules -node_modules/* markdownissues.txt TestResults.xml -*.config.json +output/ diff --git a/.vscode/analyzersettings.psd1 b/.vscode/analyzersettings.psd1 index be415e4..78312d2 100644 --- a/.vscode/analyzersettings.psd1 +++ b/.vscode/analyzersettings.psd1 @@ -1,11 +1,6 @@ @{ - <# - For the custom rules to work, the DscResource.Tests repo must be - cloned. It is automatically clone as soon as any unit or - integration tests are run. - #> - CustomRulePath = '.\DSCResource.Tests\DscResource.AnalyzerRules' - + CustomRulePath = '.\output\RequiredModules\DscResource.AnalyzerRules' + includeDefaultRules = $true IncludeRules = @( # DSC Resource Kit style guideline rules. 'PSAvoidDefaultValueForMandatoryParameter', @@ -43,11 +38,7 @@ 'PSUseDeclaredVarsMoreThanAssignments', 'PSUsePSCredentialType', - <# - This is to test all the DSC Resource Kit custom rules. - The name of the function-blocks of each custom rule start - with 'Measure*'. - #> 'Measure-*' ) + } diff --git a/.vscode/settings.json b/.vscode/settings.json index 43f01cf..a060627 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,15 +1,38 @@ -// Place your settings in this file to overwrite default and user settings. { "powershell.codeFormatting.openBraceOnSameLine": false, - "powershell.codeFormatting.newLineAfterOpenBrace": false, + "powershell.codeFormatting.newLineAfterOpenBrace": true, "powershell.codeFormatting.newLineAfterCloseBrace": true, "powershell.codeFormatting.whitespaceBeforeOpenBrace": true, "powershell.codeFormatting.whitespaceBeforeOpenParen": true, "powershell.codeFormatting.whitespaceAroundOperator": true, "powershell.codeFormatting.whitespaceAfterSeparator": true, "powershell.codeFormatting.ignoreOneLineBlock": false, + "powershell.codeFormatting.pipelineIndentationStyle": "IncreaseIndentationAfterEveryPipeline", "powershell.codeFormatting.preset": "Custom", + "powershell.codeFormatting.alignPropertyValuePairs": true, "files.trimTrailingWhitespace": true, "files.insertFinalNewline": true, - "powershell.scriptAnalysis.settingsPath": ".vscode\\analyzersettings.psd1" + "powershell.scriptAnalysis.settingsPath": ".vscode\\analyzersettings.psd1", + "powershell.scriptAnalysis.enable": true, + "files.associations": { + "*.ps1xml": "xml" + }, + "cSpell.words": [ + "COMPANYNAME", + "ICONURI", + "LICENSEURI", + "PROJECTURI", + "RELEASENOTES", + "buildhelpers", + "endregion", + "gitversion", + "icontains", + "keepachangelog", + "notin", + "pscmdlet", + "steppable" + ], + "[markdown]": { + "files.encoding": "utf8" + } } diff --git a/CHANGELOG.md b/CHANGELOG.md index 93ef816..4d18920 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,14 +1,32 @@ -# Versions +# Change log for DFSDsc -## Unreleased +The format is based on and uses the types of changes according to [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## 4.4.0.0 +## [Unreleased] + +### Changed + +- BREAKING CHANGE: Changed resource prefix from MSFT to DSC. +- Updated to use continuous delivery pattern using Azure DevOps - fixes + [Issue #41](https://github.com/dsccommunity/DFSDsc/issues/98). +- Updated build badges in README.MD. +- Renamed `DFSDsc.ResourceHelper` module to `DFSDsc.Common` to align to + other modules. +- Correct case of localization folder names. +- Update build badges in `README.md` with correct build IDs. + +## [4.4.0.0] - 2019-09-19 + +### Changed - Fix example publish to PowerShell Gallery by adding `gallery_api` environment variable to `AppVeyor.yml` - fixes [Issue #91](https://github.com/PowerShell/DfsDsc/issues/91). - Fix minor style issues in statement case. -## 4.3.0.0 +## [4.3.0.0] - 2019-02-20 + +### Changed - Fixes PSSA style violation issues resulting - fixes [Issue #84](https://github.com/PowerShell/DfsDsc/issues/84). - Added 'DscResourcesToExport' to manifest to improve information in @@ -17,7 +35,9 @@ to empty list in manifest to meet best practice. - Explicitly removed extra hidden files from release package -## 4.2.0.0 +## [4.2.0.0] - 2018-11-29 + +### Changed - Add support for modifying staging quota size in MSFT_DFSReplicationGroupMembership - fixes [Issue #77](https://github.com/PowerShell/DfsDsc/issues/77). @@ -30,7 +50,9 @@ - Updated LICENSE file to match the Microsoft Open Source Team standard - fixes [Issue #79](https://github.com/PowerShell/DFSDsc/issues/79) -## 4.1.0.0 +## [4.1.0.0] - 2018-06-13 + +### Changed - 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). @@ -38,7 +60,9 @@ - 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 +## [4.0.0.0] - 2018-05-03 + +### Changed - BREAKING CHANGE - Renamed xDFS to DFSDsc - fixes [Issue #55](https://github.com/PowerShell/xDFS/issues/55). @@ -63,7 +87,9 @@ 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). -## 3.2.0.0 +## [3.2.0.0] - 2017-06-01 + +### Changed - Converted AppVeyor.yml to pull Pester from PSGallery instead of Chocolatey. - Changed AppVeyor.yml to use default image. @@ -86,14 +112,18 @@ - Prevented ResourceHelper and Common module cmdlets from being exported to resolve conflicts with other resource modules. -## 3.1.0.0 +## [3.1.0.0] - 2016-06-29 + +### Changed - MSFT_xDFSNamespaceServerConfiguration- resource added. - Corrected names of DFS Namespace sample files to indicate that they are setting Namespace roots and folders. - Removed Pester version from AppVeyor.yml. -## 3.0.0.0 +## [3.0.0.0] - 2016-05-11 + +### Changed - RepGroup renamed to ReplicationGroup in all files. - xDFSReplicationGroupConnection- Changed DisableConnection parameter to EnsureEnabled. @@ -101,12 +131,16 @@ - xDFSReplicationGroup- Fixed bug where disabled connection was not enabled in Fullmesh topology. -## 2.2.0.0 +## [2.2.0.0] - 2016-01-01 + +### Changed - DSC Module moved to MSFT. - MSFT_xDFSNamespace- Removed. -## 2.1.0.0 +## [2.1.0.0] - 2016-01-01 + +### Changed - MSFT_xDFSRepGroup- Fixed issue when using FQDN member names. - MSFT_xDFSRepGroupMembership- Fixed issue with Get-TargetResource when using @@ -116,13 +150,17 @@ - MSFT_xDFSNamespaceRoot- Added write support to TimeToLiveSec parameter. - MSFT_xDFSNamespaceFolder- Added write support to TimeToLiveSec parameter. -## 2.0.0.0 +## [2.0.0.0] - 2016-01-01 + +### Changed - MSFT_xDFSNamespaceRoot- resource added. - MSFT_xDFSNamespaceFolder- resource added. - MSFT_xDFSNamespace- deprecated - use MSFT_xDFSNamespaceRoot instead. -## 1.5.1.0 +## [1.5.1.0] - 2016-01-01 + +### Changed - MSFT_xDFSNamespace- Add parameters: - EnableSiteCosting @@ -133,7 +171,9 @@ - ReferralPriorityClass - ReferralPriorityRank -## 1.5.0.0 +## [1.5.0.0] - 2016-01-01 + +### Changed - MSFT_xDFSNamespace- New sample files added. - MSFT_xDFSNamespace- MOF parameter descriptions corrected. @@ -146,49 +186,69 @@ until [this issue](https://windowsserver.uservoice.com/forums/301869-powershell/suggestions/11088807-get-dscconfiguration-fails-with-embedded-cim-type) is resolved. -## 1.4.2.0 +## [1.4.2.0] - 2016-01-01 + +### Changed - MSFT_xDFSRepGroup- Fixed "Cannot bind argument to parameter 'DifferenceObject' because it is null." error. - All Unit tests updated to use *_TestEnvironment functions in DSCResource.Tests\TestHelpers.psm1 -## 1.4.1.0 +## [1.4.1.0] - 2016-01-01 + +### Changed - MSFT_xDFSNamespace- Renamed Sample_DcFSNamespace.ps1 to Sample_xDFSNamespace. - MSFT_xDFSNamespace- Corrected Import-DscResouce in example. -## 1.4.0.0 +## [1.4.0.0] - 2016-01-01 + +### Changed - Community update by Erik Granneman - New DSC recource xDFSNameSpace -## 1.3.2.0 +## [1.3.2.0] - 2016-01-01 + +### Changed - Documentation and Module Manifest Update only. -## 1.3.1.0 +## [1.3.1.0] - 2016-01-01 + +### Changed - xDFSRepGroupFolder- DfsnPath parameter added for setting DFS Namespace path mapping. -## 1.3.0.0 +## [1.3.0.0] - 2016-01-01 + +### Changed - xDFSRepGroup- If ContentPaths is set, PrimaryMember is set to first member in the Members array. - xDFSRRepGroupMembership- PrimaryMembers property added so that Primary Member can be set. -## 1.2.1.0 +## [1.2.1.0] - 2016-01-01 + +### Changed - xDFSRepGroup- Fix to ContentPaths generation when more than one folder is provided. -## 1.2.0.0 +## [1.2.0.0] - 2016-01-01 + +### Changed - xDFSRepGroup- ContentPaths string array parameter. -## 1.1.0.0 +## [1.1.0.0] - 2016-01-01 + +### Changed - xDFSRepGroupConnection- Resource added. -## 1.0.0.0 +## [1.0.0.0] - 2016-01-01 + +### Changed - Initial release. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..8efc6ab --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,8 @@ + +# Contributing + +Please check out common DSC Community [contributing guidelines](https://dsccommunity.org/guidelines/contributing). + +## Running the Tests + +If want to know how to run this module's tests you can look at the [Testing Guidelines](https://dsccommunity.org/guidelines/testing-guidelines/#running-tests) diff --git a/GitVersion.yml b/GitVersion.yml new file mode 100644 index 0000000..1a5f333 --- /dev/null +++ b/GitVersion.yml @@ -0,0 +1,26 @@ +mode: ContinuousDelivery +next-version: 4.4.0 +major-version-bump-message: '\s?(breaking|major|breaking\schange)' +minor-version-bump-message: '\s?(add|feature|minor)' +patch-version-bump-message: '\s?(fix|patch)' +no-bump-message: '\+semver:\s?(none|skip)' +assembly-informational-format: '{NuGetVersionV2}+Sha.{Sha}.Date.{CommitDate}' +branches: + master: + tag: preview + pull-request: + tag: PR + feature: + tag: useBranchName + increment: Minor + regex: f(eature(s)?)?[\/-] + source-branches: ['master'] + hotfix: + tag: fix + increment: Patch + regex: (hot)?fix(es)?[\/-] + source-branches: ['master'] + +ignore: + sha: [] +merge-message-formats: {} diff --git a/LICENSE b/LICENSE index 2107107..be601b5 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,21 @@ - MIT License +MIT License - Copyright (c) Microsoft Corporation. All rights reserved. +Copyright the DSC Community contributors. All rights reserved. - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE diff --git a/Modules/DFSDsc.ResourceHelper/DFSDsc.ResourceHelper.psm1 b/Modules/DFSDsc.ResourceHelper/DFSDsc.ResourceHelper.psm1 deleted file mode 100644 index 276c747..0000000 --- a/Modules/DFSDsc.ResourceHelper/DFSDsc.ResourceHelper.psm1 +++ /dev/null @@ -1,181 +0,0 @@ -<# - .SYNOPSIS - Tests if the current machine is a Nano server. -#> -function Test-IsNanoServer -{ - if (Test-Command -Name Get-ComputerInfo) - { - $computerInfo = Get-ComputerInfo - - if ('Server' -eq $computerInfo.OsProductType ` - -and 'NanoServer' -eq $computerInfo.OsServerLevel) - { - return $true - } - } - - return $false -} - -<# - .SYNOPSIS - Tests if the the specified command is found. - - .PARAMETER Name - The name of the command to find. -#> -function Test-Command -{ - param - ( - [Parameter()] - [System.String] - $Name - ) - - return ($null -ne (Get-Command -Name $Name -ErrorAction Continue 2> $null)) -} - -<# - .SYNOPSIS - Creates and throws an invalid argument exception - - .PARAMETER Message - The message explaining why this error is being thrown - - .PARAMETER ArgumentName - The name of the invalid argument that is causing this error to be thrown -#> -function New-InvalidArgumentException -{ - [CmdletBinding()] - param - ( - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [System.String] - $Message, - - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [System.String] - $ArgumentName - ) - - $argumentException = New-Object -TypeName 'ArgumentException' -ArgumentList @( $Message, - $ArgumentName ) - $newObjectParams = @{ - TypeName = 'System.Management.Automation.ErrorRecord' - ArgumentList = @( $argumentException, $ArgumentName, 'InvalidArgument', $null ) - } - $errorRecord = New-Object @newObjectParams - - throw $errorRecord -} - -<# - .SYNOPSIS - Creates and throws an invalid operation exception - - .PARAMETER Message - The message explaining why this error is being thrown - - .PARAMETER ErrorRecord - The error record containing the exception that is causing this terminating error -#> -function New-InvalidOperationException -{ - [CmdletBinding()] - param - ( - [Parameter()] - [ValidateNotNullOrEmpty()] - [System.String] - $Message, - - [Parameter()] - [ValidateNotNull()] - [System.Management.Automation.ErrorRecord] - $ErrorRecord - ) - - if ($null -eq $Message) - { - $invalidOperationException = New-Object -TypeName 'InvalidOperationException' - } - elseif ($null -eq $ErrorRecord) - { - $invalidOperationException = - New-Object -TypeName 'InvalidOperationException' -ArgumentList @( $Message ) - } - else - { - $invalidOperationException = - New-Object -TypeName 'InvalidOperationException' -ArgumentList @( $Message, - $ErrorRecord.Exception ) - } - - $newObjectParams = @{ - TypeName = 'System.Management.Automation.ErrorRecord' - ArgumentList = @( $invalidOperationException.ToString(), 'MachineStateIncorrect', - 'InvalidOperation', $null ) - } - $errorRecordToThrow = New-Object @newObjectParams - throw $errorRecordToThrow -} - -<# - .SYNOPSIS - Retrieves the localized string data based on the machine's culture. - Falls back to en-US strings if the machine's culture is not supported. - - .PARAMETER ResourceName - The name of the resource as it appears before '.strings.psd1' of the localized string file. - - For example: - For WindowsOptionalFeature: MSFT_xWindowsOptionalFeature - For Service: MSFT_xServiceResource - For Registry: MSFT_xRegistryResource - - .PARAMETER ResourcePath - The path the resource file is located in. -#> -function Get-LocalizedData -{ - [CmdletBinding()] - param - ( - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [System.String] - $ResourceName, - - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [System.String] - $ResourcePath - ) - - $localizedStringFileLocation = Join-Path -Path $ResourcePath -ChildPath $PSUICulture - - if (-not (Test-Path -Path $localizedStringFileLocation)) - { - # Fallback to en-US - $localizedStringFileLocation = Join-Path -Path $ResourcePath -ChildPath 'en-US' - } - - Import-LocalizedData ` - -BindingVariable 'localizedData' ` - -FileName "$ResourceName.strings.psd1" ` - -BaseDirectory $localizedStringFileLocation - - return $localizedData -} - -Export-ModuleMember -Function @( - 'Test-IsNanoServer' - 'New-InvalidArgumentException' - 'New-InvalidOperationException' - 'Get-LocalizedData' - ) diff --git a/README.md b/README.md index 670c1ce..bf2ad0f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,32 @@ # DFSDsc +[![Build Status](https://dev.azure.com/dsccommunity/DFSDsc/_apis/build/status/dsccommunity.DFSDsc?branchName=master)](https://dev.azure.com/dsccommunity/DFSDsc/_build/latest?definitionId=35&branchName=master) +![Code Coverage](https://img.shields.io/azure-devops/coverage/dsccommunity/DFSDsc/35/master) +[![Azure DevOps tests](https://img.shields.io/azure-devops/tests/dsccommunity/DFSDsc/35/master)](https://dsccommunity.visualstudio.com/DFSDsc/_test/analytics?definitionId=35&contextType=build) +[![PowerShell Gallery (with prereleases)](https://img.shields.io/powershellgallery/vpre/DFSDsc?label=DFSDsc%20Preview)](https://www.powershellgallery.com/packages/DFSDsc/) +[![PowerShell Gallery](https://img.shields.io/powershellgallery/v/DFSDsc?label=DFSDsc)](https://www.powershellgallery.com/packages/DFSDsc/) + +## Code of Conduct + +This project has adopted [this code of conduct](CODE_OF_CONDUCT.md). + +## Releases + +For each merge to the branch `master` a preview release will be +deployed to [PowerShell Gallery](https://www.powershellgallery.com/). +Periodically a release version tag will be pushed which will deploy a +full release to [PowerShell Gallery](https://www.powershellgallery.com/). + +## Contributing + +Please check out common DSC Community [contributing guidelines](https://dsccommunity.org/guidelines/contributing). + +## Change log + +A full list of changes in each version can be found in the [change log](CHANGELOG.md). + +## Resources + The **DFSDsc** module contains DSC resources for configuring Distributed File System Replication and Namespaces. Currently in this version only Replication folders are supported. Namespaces will be supported in a future release. @@ -21,32 +48,11 @@ The **DFSDsc** module contains the following resources: - **[DFSReplicationGroupMembership](https://github.com/PowerShell/DFSDsc/wiki/DFSReplicationGroupMembership)**: Configure Replication Group Folder Membership. -This project has adopted [this code of conduct](CODE_OF_CONDUCT.md). - ## Documentation and Examples For a full list of resources in DFSDsc and examples on their use, check out the [DFSDsc wiki](https://github.com/PowerShell/DFSDsc/wiki). -## Branches - -### master - -[![Build status](https://ci.appveyor.com/api/projects/status/5hkcpe757hhe4583/branch/master?svg=true)](https://ci.appveyor.com/project/PowerShell/DFSDsc/branch/master) -[![codecov](https://codecov.io/gh/PowerShell/DFSDsc/branch/master/graph/badge.svg)](https://codecov.io/gh/PowerShell/DFSDsc/branch/master) - -This is the branch containing the latest release - no contributions should be made -directly to this branch. - -### dev - -[![Build status](https://ci.appveyor.com/api/projects/status/5hkcpe757hhe4583/branch/dev?svg=true)](https://ci.appveyor.com/project/PowerShell/DFSDsc/branch/dev) -[![codecov](https://codecov.io/gh/PowerShell/DFSDsc/branch/dev/graph/badge.svg)](https://codecov.io/gh/PowerShell/DFSDsc/branch/dev) - -This is the development branch to which contributions should be proposed by contributors -as pull requests. This development branch will periodically be merged to the master -branch, and be released to [PowerShell Gallery](https://www.powershellgallery.com/). - ## Requirements ### Windows Management Framework 5.0 @@ -73,7 +79,3 @@ Because this DSC Resource actually only configures information within the AD, it is only required that this resource is run on a computer that is registered in AD. It doesn't need to be run on one of the File Servers participating in the Distributed File System or Namespace. - -## Contributing - -Please check out common DSC Resources [contributing guidelines](https://github.com/PowerShell/DscResource.Kit/blob/master/CONTRIBUTING.md). diff --git a/RequiredModules.psd1 b/RequiredModules.psd1 new file mode 100644 index 0000000..c26d28d --- /dev/null +++ b/RequiredModules.psd1 @@ -0,0 +1,22 @@ +@{ + PSDependOptions = @{ + AddToPath = $true + Target = 'output\RequiredModules' + Parameters = @{ + Repository = '' + } + } + + InvokeBuild = 'latest' + PSScriptAnalyzer = 'latest' + Pester = 'latest' + Plaster = 'latest' + ModuleBuilder = 'latest' + ChangelogManagement = 'latest' + Sampler = 'latest' + MarkdownLinkCheck = 'latest' + 'DscResource.Test' = 'latest' + 'DscResource.AnalyzerRules' = 'latest' + 'DscResource.DocGenerator' = 'latest' + xDscResourceDesigner = 'latest' +} diff --git a/Resolve-Dependency.ps1 b/Resolve-Dependency.ps1 new file mode 100644 index 0000000..ec909b8 --- /dev/null +++ b/Resolve-Dependency.ps1 @@ -0,0 +1,288 @@ +[CmdletBinding()] +param +( + [Parameter()] + [String] + $DependencyFile = 'RequiredModules.psd1', + + [Parameter()] + [String] + # Path for PSDepend to be bootstrapped and save other dependencies. + # Can also be CurrentUser or AllUsers if you wish to install the modules in such scope + # Default to $PWD.Path/output/modules + $PSDependTarget = (Join-Path $PSScriptRoot './output/RequiredModules'), + + [Parameter()] + [uri] + # URI to use for Proxy when attempting to Bootstrap PackageProvider & PowerShellGet + $Proxy, + + [Parameter()] + # Credential to contact the Proxy when provided + [PSCredential]$ProxyCredential, + + [Parameter()] + [ValidateSet('CurrentUser', 'AllUsers')] + [String] + # Scope to bootstrap the PackageProvider and PSGet if not available + $Scope = 'CurrentUser', + + [Parameter()] + [String] + # Gallery to use when bootstrapping PackageProvider, PSGet and when calling PSDepend (can be overridden in Dependency files) + $Gallery = 'PSGallery', + + [Parameter()] + [PSCredential] + # Credentials to use with the Gallery specified above + $GalleryCredential, + + + [Parameter()] + [switch] + # Allow you to use a locally installed version of PowerShellGet older than 1.6.0 (not recommended, default to $false) + $AllowOldPowerShellGetModule, + + [Parameter()] + [String] + # Allow you to specify a minimum version fo PSDepend, if you're after specific features. + $MinimumPSDependVersion, + + [Parameter()] + [Switch] + $AllowPrerelease, + + [Parameter()] + [Switch] + $WithYAML +) + +# Load Defaults for parameters values from Resolve-Dependency.psd1 if not provided as parameter +try +{ + Write-Verbose -Message "Importing Bootstrap default parameters from '$PSScriptRoot/Resolve-Dependency.psd1'." + $ResolveDependencyDefaults = Import-PowerShellDataFile -Path (Join-Path $PSScriptRoot '.\Resolve-Dependency.psd1' -Resolve -ErrorAction Stop) + $ParameterToDefault = $MyInvocation.MyCommand.ParameterSets.Where{ $_.Name -eq $PSCmdlet.ParameterSetName }.Parameters.Keys + if ($ParameterToDefault.Count -eq 0) + { + $ParameterToDefault = $MyInvocation.MyCommand.Parameters.Keys + } + # Set the parameters available in the Parameter Set, or it's not possible to choose yet, so all parameters are an option + foreach ($ParamName in $ParameterToDefault) + { + if (-Not $PSBoundParameters.Keys.Contains($ParamName) -and $ResolveDependencyDefaults.ContainsKey($ParamName)) + { + Write-Verbose -Message "Setting $ParamName with $($ResolveDependencyDefaults[$ParamName])" + try + { + $variableValue = $ResolveDependencyDefaults[$ParamName] + if ($variableValue -is [string]) + { + $variableValue = $ExecutionContext.InvokeCommand.ExpandString($variableValue) + } + $PSBoundParameters.Add($ParamName, $variableValue) + Set-Variable -Name $ParamName -value $variableValue -Force -ErrorAction SilentlyContinue + } + catch + { + Write-Verbose -Message "Error adding default for $ParamName : $($_.Exception.Message)" + } + } + } +} +catch +{ + Write-Warning -Message "Error attempting to import Bootstrap's default parameters from $(Join-Path $PSScriptRoot '.\Resolve-Dependency.psd1'): $($_.Exception.Message)." +} + +Write-Progress -Activity "Bootstrap:" -PercentComplete 0 -CurrentOperation "NuGet Bootstrap" + +if (!(Get-PackageProvider -Name NuGet -ForceBootstrap -ErrorAction SilentlyContinue)) +{ + $providerBootstrapParams = @{ + Name = 'nuget' + force = $true + ForceBootstrap = $true + ErrorAction = 'Stop' + } + + switch ($PSBoundParameters.Keys) + { + 'Proxy' + { + $providerBootstrapParams.Add('Proxy', $Proxy) + } + 'ProxyCredential' + { + $providerBootstrapParams.Add('ProxyCredential', $ProxyCredential) + } + 'Scope' + { + $providerBootstrapParams.Add('Scope', $Scope) + } + } + + if ($AllowPrerelease) + { + $providerBootstrapParams.Add('AllowPrerelease', $true) + } + + Write-Information "Bootstrap: Installing NuGet Package Provider from the web (Make sure Microsoft addresses/ranges are allowed)" + $null = Install-PackageProvider @providerBootstrapParams + $latestNuGetVersion = (Get-PackageProvider -Name NuGet -ListAvailable | Select-Object -First 1).Version.ToString() + Write-Information "Bootstrap: Importing NuGet Package Provider version $latestNuGetVersion to current session." + $Null = Import-PackageProvider -Name NuGet -RequiredVersion $latestNuGetVersion -Force +} + +Write-Progress -Activity "Bootstrap:" -PercentComplete 10 -CurrentOperation "Ensuring Gallery $Gallery is trusted" + +# Fail if the given PSGallery is not Registered +$Policy = (Get-PSRepository $Gallery -ErrorAction Stop).InstallationPolicy +Set-PSRepository -Name $Gallery -InstallationPolicy Trusted -ErrorAction Ignore +try +{ + Write-Progress -Activity "Bootstrap:" -PercentComplete 25 -CurrentOperation "Checking PowerShellGet" + # Ensure the module is loaded and retrieve the version you have + $PowerShellGetVersion = (Import-Module PowerShellGet -PassThru -ErrorAction SilentlyContinue).Version + + Write-Verbose "Bootstrap: The PowerShellGet version is $PowerShellGetVersion" + # Versions below 1.6.0 are considered old, unreliable & not recommended + if (!$PowerShellGetVersion -or ($PowerShellGetVersion -lt [System.version]'1.6.0' -and !$AllowOldPowerShellGetModule)) + { + Write-Progress -Activity "Bootstrap:" -PercentComplete 40 -CurrentOperation "Installing newer version of PowerShellGet" + $InstallPSGetParam = @{ + Name = 'PowerShellGet' + Force = $true + SkipPublisherCheck = $true + AllowClobber = $true + Scope = $Scope + Repository = $Gallery + } + + switch ($PSBoundParameters.Keys) + { + 'Proxy' + { + $InstallPSGetParam.Add('Proxy', $Proxy) + } + 'ProxyCredential' + { + $InstallPSGetParam.Add('ProxyCredential', $ProxyCredential) + } + 'GalleryCredential' + { + $InstallPSGetParam.Add('Credential', $GalleryCredential) + } + } + + Install-Module @InstallPSGetParam + Remove-Module PowerShellGet -force -ErrorAction SilentlyContinue + Import-Module PowerShellGet -Force + $NewLoadedVersion = (Get-Module PowerShellGet).Version.ToString() + Write-Information "Bootstrap: PowerShellGet version loaded is $NewLoadedVersion" + Write-Progress -Activity "Bootstrap:" -PercentComplete 60 -CurrentOperation "Installing newer version of PowerShellGet" + } + + # Try to import the PSDepend module from the available modules + try + { + $ImportPSDependParam = @{ + Name = 'PSDepend' + ErrorAction = 'Stop' + Force = $true + } + + if ($MinimumPSDependVersion) + { + $ImportPSDependParam.add('MinimumVersion', $MinimumPSDependVersion) + } + $null = Import-Module @ImportPSDependParam + } + catch + { + # PSDepend module not found, installing or saving it + if ($PSDependTarget -in 'CurrentUser', 'AllUsers') + { + Write-Debug "PSDepend module not found. Attempting to install from Gallery $Gallery" + Write-Warning "Installing PSDepend in $PSDependTarget Scope" + $InstallPSDependParam = @{ + Name = 'PSDepend' + Repository = $Gallery + Force = $true + Scope = $PSDependTarget + SkipPublisherCheck = $true + AllowClobber = $true + } + + if ($MinimumPSDependVersion) + { + $InstallPSDependParam.add('MinimumVersion', $MinimumPSDependVersion) + } + + Write-Progress -Activity "Bootstrap:" -PercentComplete 75 -CurrentOperation "Installing PSDepend from $Gallery" + Install-Module @InstallPSDependParam + } + else + { + Write-Debug "PSDepend module not found. Attempting to Save from Gallery $Gallery to $PSDependTarget" + $SaveModuleParam = @{ + Name = 'PSDepend' + Repository = $Gallery + Path = $PSDependTarget + } + + if ($MinimumPSDependVersion) + { + $SaveModuleParam.add('MinimumVersion', $MinimumPSDependVersion) + } + + Write-Progress -Activity "Bootstrap:" -PercentComplete 75 -CurrentOperation "Saving & Importing PSDepend from $Gallery to $Scope" + Save-Module @SaveModuleParam + } + } + finally + { + Write-Progress -Activity "Bootstrap:" -PercentComplete 100 -CurrentOperation "Loading PSDepend" + # We should have successfully bootstrapped PSDepend. Fail if not available + Import-Module PSDepend -ErrorAction Stop + } + + if ($WithYAML) + { + if (-Not (Get-Module -ListAvailable -Name 'PowerShell-Yaml')) + { + Write-Verbose "PowerShell-Yaml module not found. Attempting to Save from Gallery $Gallery to $PSDependTarget" + $SaveModuleParam = @{ + Name = 'PowerShell-Yaml' + Repository = $Gallery + Path = $PSDependTarget + } + + Save-Module @SaveModuleParam + Import-Module "PowerShell-Yaml" -ErrorAction Stop + } + else + { + Write-Verbose "PowerShell-Yaml is already available" + } + } + + Write-Progress -Activity "PSDepend:" -PercentComplete 0 -CurrentOperation "Restoring Build Dependencies" + if (Test-Path $DependencyFile) + { + $PSDependParams = @{ + Force = $true + Path = $DependencyFile + } + + # TODO: Handle when the Dependency file is in YAML, and -WithYAML is specified + Invoke-PSDepend @PSDependParams + } + Write-Progress -Activity "PSDepend:" -PercentComplete 100 -CurrentOperation "Dependencies restored" -Completed +} +finally +{ + # Reverting the Installation Policy for the given gallery + Set-PSRepository -Name $Gallery -InstallationPolicy $Policy + Write-Verbose "Project Bootstrapped, returning to Invoke-Build" +} diff --git a/Resolve-Dependency.psd1 b/Resolve-Dependency.psd1 new file mode 100644 index 0000000..2ae8c0d --- /dev/null +++ b/Resolve-Dependency.psd1 @@ -0,0 +1,5 @@ +@{ + Gallery = 'PSGallery' + AllowPrerelease = $false + WithYAML = $true +} diff --git a/Tests/Integration/MSFT_DFSNamespaceFolder.Integration.Tests.ps1 b/Tests/Integration/MSFT_DFSNamespaceFolder.Integration.Tests.ps1 deleted file mode 100644 index 0ef5b55..0000000 --- a/Tests/Integration/MSFT_DFSNamespaceFolder.Integration.Tests.ps1 +++ /dev/null @@ -1,159 +0,0 @@ -$script:DSCModuleName = 'DFSDsc' -$script:DSCResourceName = 'MSFT_DFSNamespaceFolder' - -#region HEADER -# Integration Test Template Version: 1.1.0 -[System.String] $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) - -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) -{ - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) -} - -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath "$($script:DSCModuleName).psd1") -Force -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Integration -#endregion - -# Using try/finally to always cleanup even if something awful happens. -try -{ - # Ensure that the tests can be performed on this computer - $productType = (Get-CimInstance Win32_OperatingSystem).ProductType - Describe 'Environment' { - Context 'Operating System' { - It 'Should be a Server OS' { - $productType | Should -Be 3 - } - } - } - - if ($productType -ne 3) - { - break - } - - $featureInstalled = (Get-WindowsFeature -Name FS-DFS-Namespace).Installed - Describe 'Environment' { - Context 'Windows Features' { - It 'Should have the DFS Namespace Feature Installed' { - $featureInstalled | Should -Be $true - } - } - } - if ($featureInstalled -eq $false) - { - break - } - - #region Integration Tests - $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1" - . $configFile - - Describe "$($script:DSCResourceName)_Integration" { - # Create a SMB share for the Namespace - [System.String] $RandomFileName = [System.IO.Path]::GetRandomFileName() - - [System.String] $ShareFolderRoot = Join-Path -Path $env:Temp -ChildPath "$($script:DSCResourceName)_$RandomFileName" - - New-Item ` - -Path $ShareFolderRoot ` - -Type Directory - - New-SMBShare ` - -Name $NamespaceRootName ` - -Path $ShareFolderRoot ` - -FullAccess 'Everyone' - - [System.String] $RandomFileName = [System.IO.Path]::GetRandomFileName() - - [System.String] $ShareFolderFolder = Join-Path -Path $env:Temp -ChildPath "$($script:DSCResourceName)_$RandomFileName" - - New-Item ` - -Path $ShareFolderFolder ` - -Type Directory - - New-SMBShare ` - -Name $NamespaceFolderName ` - -Path $ShareFolderFolder ` - -FullAccess 'Everyone' - - New-DFSNRoot ` - -Path $NamespaceRoot.Path ` - -TargetPath $NamespaceRoot.TargetPath ` - -Type Standalone - - #region DEFAULT TESTS - It 'Should compile and apply the MOF without throwing' { - { - & "$($script:DSCResourceName)_Config" -OutputPath $TestDrive - Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force - } | Should -Not -Throw - } - - It 'Should be able to call Get-DscConfiguration without throwing' { - { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw - } - #endregion - - It 'Should have set the resource and all the folder parameters should match' { - # Get the Rule details - $NamespaceFolderNew = Get-DfsnFolder -Path $NamespaceFolder.Path - $NamespaceFolderNew.Path | Should -Be $NamespaceFolder.Path - $NamespaceFolderNew.TimeToLiveSec | Should -Be 300 - $NamespaceFolderNew.State | Should -Be 'Online' - $NamespaceFolderNew.Description | Should -Be $NamespaceFolder.Description - $NamespaceFolderNew.NamespacePath | Should -Be $NamespaceFolder.Path - $NamespaceFolderNew.Flags | Should -Be @('Target Failback','Insite Referrals') - } - - It 'Should have set the resource and all the folder target parameters should match' { - $NamespaceFolderTargetNew = Get-DfsnFolderTarget -Path $NamespaceFolder.Path -TargetPath $NamespaceFolder.TargetPath - $NamespaceFolderTargetNew.Path | Should -Be $NamespaceFolder.Path - $NamespaceFolderTargetNew.NamespacePath | Should -Be $NamespaceFolder.Path - $NamespaceFolderTargetNew.TargetPath | Should -Be $NamespaceFolder.TargetPath - $NamespaceFolderTargetNew.ReferralPriorityClass | Should -Be $NamespaceFolder.ReferralPriorityClass - $NamespaceFolderTargetNew.ReferralPriorityRank | Should -Be $NamespaceFolder.ReferralPriorityRank - } - - # Clean up - Remove-DFSNFolder ` - -Path $NamespaceFolder.Path ` - -Force ` - -Confirm:$false - - Remove-DFSNRoot ` - -Path $NamespaceRoot.Path ` - -Force ` - -Confirm:$false - - Remove-SMBShare ` - -Name $NamespaceFolderName ` - -Confirm:$false - - Remove-Item ` - -Path $ShareFolderFolder ` - -Recurse ` - -Force - - Remove-SMBShare ` - -Name $NamespaceRootName ` - -Confirm:$false - - Remove-Item ` - -Path $ShareFolderRoot ` - -Recurse ` - -Force - } - #endregion -} -finally -{ - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion -} diff --git a/Tests/Integration/MSFT_DFSNamespaceFolder.config.ps1 b/Tests/Integration/MSFT_DFSNamespaceFolder.config.ps1 deleted file mode 100644 index 5fc55b1..0000000 --- a/Tests/Integration/MSFT_DFSNamespaceFolder.config.ps1 +++ /dev/null @@ -1,32 +0,0 @@ -$NamespaceRootName = 'IntegrationTestNamespace' -$NamespaceFolderName = 'TestFolder' -$NamespaceRoot = @{ - Path = "\\$($env:COMPUTERNAME)\$NamespaceRootName" - TargetPath = "\\$($env:COMPUTERNAME)\$NamespaceRootName" -} -$NamespaceFolder = @{ - Path = "$($NamespaceRoot.Path)\$NamespaceFolderName" - TargetPath = "\\$($env:COMPUTERNAME)\$NamespaceFolderName" - Ensure = 'Present' - Description = 'Integration test namespace folder' - EnableInsiteReferrals = $true - EnableTargetFailback = $true - ReferralPriorityClass = 'Global-Low' - ReferralPriorityRank = 10 -} - -Configuration MSFT_DFSNamespaceFolder_Config { - Import-DscResource -ModuleName DFSDsc - node localhost { - DFSNamespaceFolder Integration_Test { - Path = $NamespaceFolder.Path - TargetPath = $NamespaceFolder.TargetPath - Ensure = $NamespaceFolder.Ensure - Description = $NamespaceFolder.Description - EnableInsiteReferrals = $NamespaceFolder.EnableInsiteReferrals - EnableTargetFailback = $NamespaceFolder.EnableTargetFailback - ReferralPriorityClass = $NamespaceFolder.ReferralPriorityClass - ReferralPriorityRank = $NamespaceFolder.ReferralPriorityRank - } - } -} diff --git a/Tests/Integration/MSFT_DFSNamespaceRoot.Integration.Tests.ps1 b/Tests/Integration/MSFT_DFSNamespaceRoot.Integration.Tests.ps1 deleted file mode 100644 index 5c12ee7..0000000 --- a/Tests/Integration/MSFT_DFSNamespaceRoot.Integration.Tests.ps1 +++ /dev/null @@ -1,129 +0,0 @@ -$script:DSCModuleName = 'DFSDsc' -$script:DSCResourceName = 'MSFT_DFSNamespaceRoot' - -#region HEADER -# Integration Test Template Version: 1.1.0 -[System.String] $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) - -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) -{ - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) -} - -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath "$($script:DSCModuleName).psd1") -Force -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Integration -#endregion - -# Using try/finally to always cleanup even if something awful happens. -try -{ - # Ensure that the tests can be performed on this computer - $productType = (Get-CimInstance Win32_OperatingSystem).ProductType - Describe 'Environment' { - Context 'Operating System' { - It 'Should be a Server OS' { - $productType | Should -Be 3 - } - } - } - - if ($productType -ne 3) - { - break - } - - $featureInstalled = (Get-WindowsFeature -Name FS-DFS-Namespace).Installed - Describe 'Environment' { - Context 'Windows Features' { - It 'Should have the DFS Namespace Feature Installed' { - $featureInstalled | Should -Be $true - } - } - } - - if ($featureInstalled -eq $false) - { - break - } - - #region Integration Tests - $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1" - . $configFile - - Describe "$($script:DSCResourceName)_Integration" { - # Create a SMB share for the Namespace - [System.String] $RandomFileName = [System.IO.Path]::GetRandomFileName() - - [System.String] $ShareFolderRoot = Join-Path -Path $env:Temp -ChildPath "$($script:DSCResourceName)_$RandomFileName" - - New-Item ` - -Path $ShareFolderRoot ` - -Type Directory - - New-SMBShare ` - -Name $NamespaceRootName ` - -Path $ShareFolderRoot ` - -FullAccess 'Everyone' - - #region DEFAULT TESTS - It 'Should compile and apply the MOF without throwing' { - { - & "$($script:DSCResourceName)_Config" -OutputPath $TestDrive - Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force - } | Should -Not -Throw - } - - It 'Should be able to call Get-DscConfiguration without throwing' { - { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw - } - #endregion - - It 'Should have set the resource and all the folder parameters should match' { - # Get the Rule details - $NamespaceRootNew = Get-DfsnRoot -Path $NamespaceRoot.Path - $NamespaceRootNew.Path | Should -Be $NamespaceRoot.Path - $NamespaceRootNew.Type | Should -Be $NamespaceRoot.Type - $NamespaceRootNew.TimeToLiveSec | Should -Be $NamespaceRoot.TimeToLiveSec - $NamespaceRootNew.State | Should -Be 'Online' - $NamespaceRootNew.Description | Should -Be $NamespaceRoot.Description - $NamespaceRootNew.NamespacePath | Should -Be $NamespaceRoot.Path - $NamespaceRootNew.Flags | Should -Be @('Target Failback','Site Costing','Insite Referrals','AccessBased Enumeration') - } - - It 'Should have set the resource and all the folder target parameters should match' { - $NamespaceRootTargetNew = Get-DfsnRootTarget -Path $NamespaceRoot.Path -TargetPath $NamespaceRoot.TargetPath - $NamespaceRootTargetNew.Path | Should -Be $NamespaceRoot.Path - $NamespaceRootTargetNew.NamespacePath | Should -Be $NamespaceRoot.Path - $NamespaceRootTargetNew.TargetPath | Should -Be $NamespaceRoot.TargetPath - $NamespaceRootTargetNew.ReferralPriorityClass | Should -Be $NamespaceRoot.ReferralPriorityClass - $NamespaceRootTargetNew.ReferralPriorityRank | Should -Be $NamespaceRoot.ReferralPriorityRank - } - - # Clean up - Remove-DFSNRoot ` - -Path $NamespaceRoot.Path ` - -Force ` - -Confirm:$false - - Remove-SMBShare ` - -Name $NamespaceRootName ` - -Confirm:$false - - Remove-Item ` - -Path $ShareFolderRoot ` - -Recurse ` - -Force - } - #endregion -} -finally -{ - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion -} diff --git a/Tests/Integration/MSFT_DFSNamespaceRoot.config.ps1 b/Tests/Integration/MSFT_DFSNamespaceRoot.config.ps1 deleted file mode 100644 index f3c1e24..0000000 --- a/Tests/Integration/MSFT_DFSNamespaceRoot.config.ps1 +++ /dev/null @@ -1,38 +0,0 @@ -$NamespaceRootName = 'IntegrationTestNamespace' -$NamespaceRoot = @{ - Path = "\\$($env:COMPUTERNAME)\$NamespaceRootName" - TargetPath = "\\$($env:COMPUTERNAME)\$NamespaceRootName" - Ensure = 'Present' - Type = 'Standalone' - Description = 'Integration test namespace' - TimeToLiveSec = 500 - EnableSiteCosting = $true - EnableInsiteReferrals = $true - EnableAccessBasedEnumeration = $true - EnableRootScalability = $true - EnableTargetFailback = $true - ReferralPriorityClass = 'Global-Low' - ReferralPriorityRank = 10 -} - -Configuration MSFT_DFSNamespaceRoot_Config { - Import-DscResource -ModuleName DFSDsc - node localhost { - DFSNamespaceRoot Integration_Test { - Path = $NamespaceRoot.Path - TargetPath = $NamespaceRoot.TargetPath - Ensure = $NamespaceRoot.Ensure - Type = $NamespaceRoot.Type - Description = $NamespaceRoot.Description - TimeToLiveSec = $NamespaceRoot.TimeToLiveSec - EnableSiteCosting = $NamespaceRoot.EnableSiteCosting - EnableInsiteReferrals = $NamespaceRoot.EnableInsiteReferrals - EnableAccessBasedEnumeration = $NamespaceRoot.EnableAccessBasedEnumeration - # Not supported by Standalone Namespaces - # EnableRootScalability = $NamespaceRoot.EnableRootScalability - EnableTargetFailback = $NamespaceRoot.EnableTargetFailback - ReferralPriorityClass = $NamespaceRoot.ReferralPriorityClass - ReferralPriorityRank = $NamespaceRoot.ReferralPriorityRank - } - } -} diff --git a/Tests/Integration/MSFT_DFSNamespaceServerConfiguration.Integration.Tests.ps1 b/Tests/Integration/MSFT_DFSNamespaceServerConfiguration.Integration.Tests.ps1 deleted file mode 100644 index a54c653..0000000 --- a/Tests/Integration/MSFT_DFSNamespaceServerConfiguration.Integration.Tests.ps1 +++ /dev/null @@ -1,98 +0,0 @@ -$script:DSCModuleName = 'DFSDsc' -$script:DSCResourceName = 'MSFT_DFSNamespaceServerConfiguration' - -#region HEADER -# Integration Test Template Version: 1.1.0 -[System.String] $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) - -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) -{ - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) -} - -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath "$($script:DSCModuleName).psd1") -Force -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Integration -#endregion - -# Using try/finally to always cleanup even if something awful happens. -try -{ - # Ensure that the tests can be performed on this computer - $productType = (Get-CimInstance Win32_OperatingSystem).ProductType - Describe 'Environment' { - Context 'Operating System' { - It 'Should be a Server OS' { - $productType | Should -Be 3 - } - } - } - - if ($productType -ne 3) - { - break - } - - $featureInstalled = (Get-WindowsFeature -Name FS-DFS-Namespace).Installed - Describe 'Environment' { - Context 'Windows Features' { - It 'Should have the DFS Namespace Feature Installed' { - $featureInstalled | Should -Be $true - } - } - } - - if ($featureInstalled -eq $false) - { - break - } - - # Backup the existing settings - $ServerConfigurationBackup = Get-DFSNServerConfiguration ` - -ComputerName $($env:COMPUTERNAME) - - #region Integration Tests - $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1" - . $configFile - - Describe "$($script:DSCResourceName)_Integration" { - #region DEFAULT TESTS - It 'Should compile and apply the MOF without throwing' { - { - & "$($script:DSCResourceName)_Config" -OutputPath $TestDrive - Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force - } | Should -Not -Throw - } - - It 'Should be able to call Get-DscConfiguration without throwing' { - { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw - } - #endregion - - It 'Should have set the resource and all the parameters should match' { - # Get the Rule details - $NamespaceServerConfigurationNew = Get-DfsnServerConfiguration -ComputerName $env:COMPUTERNAME - $NamespaceServerConfigurationNew.LdapTimeoutSec = $NamespaceServerConfiguration.LdapTimeoutSec - $NamespaceServerConfigurationNew.SyncIntervalSec = $NamespaceServerConfiguration.SyncIntervalSec - $NamespaceServerConfigurationNew.UseFQDN = $NamespaceServerConfiguration.UseFQDN - } - - # Clean up - Set-DFSNServerConfiguration ` - -ComputerName $env:COMPUTERNAME ` - -LdapTimeoutSec $ServerConfigurationBackup.LdapTimeoutSec ` - -SyncIntervalSec $ServerConfigurationBackup.SyncIntervalSec ` - -UseFQDN $ServerConfigurationBackup.UseFQDN - } - #endregion -} -finally -{ - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion -} diff --git a/Tests/Integration/MSFT_DFSNamespaceServerConfiguration.config.ps1 b/Tests/Integration/MSFT_DFSNamespaceServerConfiguration.config.ps1 deleted file mode 100644 index ad72b09..0000000 --- a/Tests/Integration/MSFT_DFSNamespaceServerConfiguration.config.ps1 +++ /dev/null @@ -1,17 +0,0 @@ -$NamespaceServerConfiguration = @{ - LdapTimeoutSec = 45 - SyncIntervalSec = 5000 - UseFQDN = $True -} - -Configuration MSFT_DFSNamespaceServerConfiguration_Config { - Import-DscResource -ModuleName DFSDsc - node localhost { - DFSNamespaceServerConfiguration Integration_Test { - IsSingleInstance = 'Yes' - LdapTimeoutSec = $NamespaceServerConfiguration.LdapTimeoutSec - SyncIntervalSec = $NamespaceServerConfiguration.SyncIntervalSec - UseFQDN = $NamespaceServerConfiguration.UseFQDN - } - } -} diff --git a/Tests/Integration/MSFT_DFSReplicationGroup.Integration.Tests.ps1 b/Tests/Integration/MSFT_DFSReplicationGroup.Integration.Tests.ps1 deleted file mode 100644 index 0eeaf2c..0000000 --- a/Tests/Integration/MSFT_DFSReplicationGroup.Integration.Tests.ps1 +++ /dev/null @@ -1,143 +0,0 @@ -<# -These integration tests can only be run on a computer that: -1. Is a member of an Active Directory domain. -2. Has access to two Windows Server 2012 or greater servers with - the FS-DFS-Replication and RSAT-DFS-Mgmt-Con features installed. -3. An AD User account that has the required permissions that are needed - to create a DFS Replication Group. - -If the above are available then to allow these tests to be run a -MSFT_DFSReplicationGroup.config.json file must be created in the same folder as -this file. The content should be a customized version of the following: -{ - "Username": "contoso.com\\Administrator", - "Folders": [ - "TestFolder1", - "TestFolder2" - ], - "Members": [ - "Server1", - "Server2" - ], - "ContentPaths": [ - "c:\\IntegrationTests\\TestFolder1", - "c:\\IntegrationTests\\TestFolder2" - ], - "Password": "MyPassword" -} - -If the above are available and configured these integration tests will run. -#> -$script:DSCModuleName = 'DFSDsc' -$script:DSCResourceName = 'MSFT_DFSReplicationGroup' - -# Test to see if the config file is available. -$configFile = "$([System.IO.Path]::GetDirectoryName($MyInvocation.MyCommand.Path))\$($script:DSCResourceName).config.json" - -if (! (Test-Path -Path $configFile)) -{ - return -} - -#region HEADER -# Integration Test Template Version: 1.1.0 -[System.String] $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) - -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) -{ - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) -} - -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath "$($script:DSCModuleName).psd1") -Force -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Integration -#endregion - -# Using try/finally to always cleanup even if something awful happens. -try -{ - #region Integration Tests - $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1" - . $configFile - - Describe "$($script:DSCResourceName)_Integration" { - #region DEFAULT TESTS - It 'Should compile and apply the MOF without throwing' { - { - $ConfigData = @{ - AllNodes = @( - @{ - NodeName = 'localhost' - PSDscAllowPlainTextPassword = $true - } - ) - } - - & "$($script:DSCResourceName)_Config" -OutputPath $TestDrive -ConfigurationData $ConfigData - Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force - } | Should -Not -Throw - } - - It 'Should be able to call Get-DscConfiguration without throwing' { - { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw - } - #endregion - - It 'Should have set the resource and all the parameters should match' { - $ReplicationGroupNew = Get-DfsReplicationGroup ` - -GroupName $ReplicationGroup.GroupName ` - -ErrorAction Stop - $ReplicationGroupNew.GroupName | Should -Be $ReplicationGroup.GroupName - $ReplicationGroupNew.Description | Should -Be $ReplicationGroup.Description - - # Check the members are in the Replication Group - foreach ($Member in $ReplicationGroup.Members) - { - $ReplicationGroupMemberNew = Get-DfsrMember ` - -GroupName $ReplicationGroup.GroupName ` - -ComputerName $Member ` - -ErrorAction Stop - $ReplicationGroupMemberNew.GroupName | Should -Be $ReplicationGroup.GroupName - - # If Member name was an FQDN then match the DNSName property, otherwise the ComputerName property - if ($Member.Contains('.')) - { - $ReplicationGroupMemberNew.DnsName | Should -Be $Member - } - else - { - $ReplicationGroupMemberNew.ComputerName | Should -Be $Member - } - } - - # Check the folders are in the Replication Group - foreach ($Folder in $ReplicationGroup.Folders) - { - $ReplicationGroupFolderNew = Get-DfsReplicatedFolder ` - -GroupName $ReplicationGroup.GroupName ` - -FolderName $Folder ` - -ErrorAction Stop - $ReplicationGroupFolderNew.GroupName | Should -Be $ReplicationGroup.GroupName - $ReplicationGroupFolderNew.FolderName | Should -Be $Folder - } - } - - # Clean up - Remove-DFSReplicationGroup ` - -GroupName $ReplicationGroup.GroupName ` - -RemoveReplicatedFolders ` - -Force ` - -Confirm:$false - } - #endregion -} -finally -{ - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion -} diff --git a/Tests/Integration/MSFT_DFSReplicationGroup.config.ps1 b/Tests/Integration/MSFT_DFSReplicationGroup.config.ps1 deleted file mode 100644 index d0ae8d5..0000000 --- a/Tests/Integration/MSFT_DFSReplicationGroup.config.ps1 +++ /dev/null @@ -1,46 +0,0 @@ -# If there is a .config.json file for these tests, read the test parameters from it. -$configFile = [System.IO.Path]::ChangeExtension($MyInvocation.MyCommand.Path,'json') -if (Test-Path -Path $configFile) -{ - $TestConfig = Get-Content -Path $configFile | ConvertFrom-Json -} -else -{ - # Example config parameters. - $TestConfig = @{ - Username = 'contoso.com\Administrator' - Password = 'MyP@ssw0rd!1' - Members = @('Server1','Server1') - Folders = @('TestFolder1','TestFolder2') - ContentPaths = @("$(ENV:Temp)TestFolder1","$(ENV:Temp)TestFolder2") - } -} - -$TestPassword = New-Object -Type SecureString [char[]] $TestConfig.Password | - ForEach-Object { $Password.AppendChar( $_ ) } - -$ReplicationGroup = @{ - GroupName = 'IntegrationTestReplicationGroup' - Description = 'Integration Test Replication Group' - Ensure = 'Present' - Members = $TestConfig.Members - Folders = $TestConfig.Folders - Topology = 'Fullmesh' - PSDSCRunAsCredential = New-Object System.Management.Automation.PSCredential ($TestConfig.Username, $TestPassword) -} - -Configuration MSFT_DFSReplicationGroup_Config { - Import-DscResource -ModuleName DFSDsc - node localhost { - DFSReplicationGroup Integration_Test { - GroupName = $ReplicationGroup.GroupName - Description = $ReplicationGroup.Description - Ensure = $ReplicationGroup.Ensure - Members = $ReplicationGroup.Members - Folders = $ReplicationGroup.Folders - ContentPaths = $ReplicationGroup.ContentPaths - Topology = $ReplicationGroup.Topology - PSDSCRunAsCredential = $ReplicationGroup.PSDSCRunAsCredential - } - } -} diff --git a/Tests/Integration/MSFT_DFSReplicationGroupConnection.Integration.Tests.ps1 b/Tests/Integration/MSFT_DFSReplicationGroupConnection.Integration.Tests.ps1 deleted file mode 100644 index 2c0a396..0000000 --- a/Tests/Integration/MSFT_DFSReplicationGroupConnection.Integration.Tests.ps1 +++ /dev/null @@ -1,133 +0,0 @@ -<# -These integration tests can only be run on a computer that: -1. Is a member of an Active Directory domain. -2. Has access to two Windows Server 2012 or greater servers with - the FS-DFS-Replication and RSAT-DFS-Mgmt-Con features installed. -3. An AD User account that has the required permissions that are needed - to create a DFS Replication Group. - -If the above are available then to allow these tests to be run a -MSFT_DFSReplicationGroupFolder.config.json file must be created in the same folder as -this file. The content should be a customized version of the following: -{ - "Username": "contoso.com\\Administrator", - "Folders": [ - "TestFolder1", - "TestFolder2" - ], - "Members": [ - "Server1", - "Server2" - ], - "ContentPaths": [ - "c:\\IntegrationTests\\TestFolder1", - "c:\\IntegrationTests\\TestFolder2" - ], - "Password": "MyPassword" -} - -If the above are available and configured these integration tests will run. -#> -$script:DSCModuleName = 'DFSDsc' -$script:DSCResourceName = 'MSFT_DFSReplicationGroupConnection' - -# Test to see if the config file is available. -$configFile = "$([System.IO.Path]::GetDirectoryName($MyInvocation.MyCommand.Path))\$($script:DSCResourceName).config.json" - -if (! (Test-Path -Path $configFile)) -{ - return -} - -#region HEADER -# Integration Test Template Version: 1.1.0 -[System.String] $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) - -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) -{ - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) -} - -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath "$($script:DSCModuleName).psd1") -Force -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Integration -#endregion - -# Using try/finally to always cleanup even if something awful happens. -try -{ - #region Integration Tests - $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1" - . $configFile - - Describe "$($script:DSCResourceName)_Integration" { - # Create the Replication group to work with - New-DFSReplicationGroup ` - -GroupName $ReplicationGroupConnection.GroupName - - foreach ($Member in $ReplicationGroupConnection.Members) - { - Add-DFSRMember ` - -GroupName $ReplicationGroupConnection.GroupName ` - -ComputerName $Member - } - - foreach ($Folder in $ReplicationGroupConnection.Folders) - { - New-DFSReplicatedFolder ` - -GroupName $ReplicationGroupConnection.GroupName ` - -FolderName $Folder - } - - #region DEFAULT TESTS - It 'Should compile and apply the MOF without throwing' { - { - $ConfigData = @{ - AllNodes = @( - @{ - NodeName = 'localhost' - PSDscAllowPlainTextPassword = $true - } - ) - } - - & "$($script:DSCResourceName)_Config" -OutputPath $TestDrive -ConfigurationData $ConfigData - Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force - } | Should -Not -Throw - } - - It 'Should be able to call Get-DscConfiguration without throwing' { - { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw - } - #endregion - - It 'Should have set the resource and all the parameters should match' { - $ReplicationGroupConnectionNew = Get-DfsrConnection ` - -GroupName $ReplicationGroupConnection.GroupName ` - -SourceComputerName $ReplicationGroupConnection.SourceComputerName ` - -DestinationComputerName $ReplicationGroupConnection.DestinationComputerName ` - -ErrorAction Stop - $ReplicationGroupConnectionNew.GroupName | Should -Be $ReplicationGroupConnection.GroupName - $ReplicationGroupConnectionNew.SourceComputerName | Should -Be $ReplicationGroupConnection.SourceComputerName - $ReplicationGroupConnectionNew.DestinationComputerName | Should -Be $ReplicationGroupConnection.DestinationComputerName - } - - # Clean up - Remove-DFSReplicationGroup ` - -GroupName $ReplicationGroupConnection.GroupName ` - -RemoveReplicatedFolders ` - -Force ` - -Confirm:$false - } - #endregion -} -finally -{ - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion -} diff --git a/Tests/Integration/MSFT_DFSReplicationGroupConnection.config.ps1 b/Tests/Integration/MSFT_DFSReplicationGroupConnection.config.ps1 deleted file mode 100644 index 22385fd..0000000 --- a/Tests/Integration/MSFT_DFSReplicationGroupConnection.config.ps1 +++ /dev/null @@ -1,43 +0,0 @@ -# If there is a .config.json file for these tests, read the test parameters from it. -$configFile = [System.IO.Path]::ChangeExtension($MyInvocation.MyCommand.Path,'json') -if (Test-Path -Path $configFile) -{ - $TestConfig = Get-Content -Path $configFile | ConvertFrom-Json -} -else -{ - # Example config parameters. - $TestConfig = @{ - Username = 'contoso.com\Administrator' - Password = 'MyP@ssw0rd!1' - Members = @('Server1','Server1') - Folders = @('TestFolder1','TestFolder2') - ContentPaths = @("$(ENV:Temp)TestFolder1","$(ENV:Temp)TestFolder2") - } -} - -$TestPassword = New-Object -Type SecureString [char[]] $TestConfig.Password | - Foreach-Object { $Password.AppendChar( $_ ) } - -$ReplicationGroupConnection = @{ - GroupName = 'IntegrationTestReplicationGroup' - Folders = $TestConfig.Folders - Members = $TestConfig.Members - Ensure = 'Present' - SourceComputerName = $TestConfig.Members[0] - DestinationComputerName = $TestConfig.Members[1] - PSDSCRunAsCredential = New-Object System.Management.Automation.PSCredential ($TestConfig.Username, $TestPassword) -} - -Configuration MSFT_DFSReplicationGroupConnection_Config { - Import-DscResource -ModuleName DFSDsc - node localhost { - DFSReplicationGroupConnection Integration_Test { - GroupName = $ReplicationGroupConnection.GroupName - Ensure = 'Present' - SourceComputerName = $ReplicationGroupConnection.SourceComputerName - DestinationComputerName = $ReplicationGroupConnection.DestinationComputerName - PSDSCRunAsCredential = $ReplicationGroupConnection.PSDSCRunAsCredential - } - } -} diff --git a/Tests/Integration/MSFT_DFSReplicationGroupFolder.Integration.Tests.ps1 b/Tests/Integration/MSFT_DFSReplicationGroupFolder.Integration.Tests.ps1 deleted file mode 100644 index d2b07a4..0000000 --- a/Tests/Integration/MSFT_DFSReplicationGroupFolder.Integration.Tests.ps1 +++ /dev/null @@ -1,134 +0,0 @@ -<# -These integration tests can only be run on a computer that: -1. Is a member of an Active Directory domain. -2. Has access to two Windows Server 2012 or greater servers with - the FS-DFS-Replication and RSAT-DFS-Mgmt-Con features installed. -3. An AD User account that has the required permissions that are needed - to create a DFS Replication Group. - -If the above are available then to allow these tests to be run a -MSFT_DFSReplicationGroupFolder.config.json file must be created in the same folder as -this file. The content should be a customized version of the following: -{ - "Username": "contoso.com\\Administrator", - "Folders": [ - "TestFolder1", - "TestFolder2" - ], - "Members": [ - "Server1", - "Server2" - ], - "ContentPaths": [ - "c:\\IntegrationTests\\TestFolder1", - "c:\\IntegrationTests\\TestFolder2" - ], - "Password": "MyPassword" -} - -If the above are available and configured these integration tests will run. -#> -$script:DSCModuleName = 'DFSDsc' -$script:DSCResourceName = 'MSFT_DFSReplicationGroupFolder' - -# Test to see if the config file is available. -$configFile = "$([System.IO.Path]::GetDirectoryName($MyInvocation.MyCommand.Path))\$($script:DSCResourceName).config.json" - -if (! (Test-Path -Path $configFile)) -{ - return -} - -#region HEADER -# Integration Test Template Version: 1.1.0 -[System.String] $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) - -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) -{ - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) -} - -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath "$($script:DSCModuleName).psd1") -Force -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Integration -#endregion - -# Using try/finally to always cleanup even if something awful happens. -try -{ - #region Integration Tests - $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1" - . $configFile - - Describe "$($script:DSCResourceName)_Integration" { - # Create the Replication group to work with - New-DFSReplicationGroup ` - -GroupName $ReplicationGroupFolder.GroupName - - foreach ($Member in $ReplicationGroupFolder.Members) - { - Add-DFSRMember ` - -GroupName $ReplicationGroupFolder.GroupName ` - -ComputerName $Member - } - - foreach ($Folder in $ReplicationGroupFolder.Folders) - { - New-DFSReplicatedFolder ` - -GroupName $ReplicationGroupFolder.GroupName ` - -FolderName $Folder - } - - #region DEFAULT TESTS - It 'Should compile and apply the MOF without throwing' { - { - $ConfigData = @{ - AllNodes = @( - @{ - NodeName = 'localhost' - PSDscAllowPlainTextPassword = $true - } - ) - } - - & "$($script:DSCResourceName)_Config" -OutputPath $TestDrive -ConfigurationData $ConfigData - Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force - } | Should -Not -Throw - } - - It 'Should be able to call Get-DscConfiguration without throwing' { - { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw - } - #endregion - - It 'Should have set the resource and all the parameters should match' { - $ReplicationGroupFolderNew = Get-DfsReplicatedFolder ` - -GroupName $ReplicationGroupFolder.GroupName ` - -FolderName $ReplicationGroupFolder.FolderName ` - -ErrorAction Stop - $ReplicationGroupFolderNew.GroupName | Should -Be $ReplicationGroupFolder.GroupName - $ReplicationGroupFolderNew.FolderName | Should -Be $ReplicationGroupFolder.FolderName - $ReplicationGroupFolderNew.Description | Should -Be $ReplicationGroupFolder.Description - $ReplicationGroupFolderNew.DirectoryNameToExclude | Should -Be $ReplicationGroupFolder.DirectoryNameToExclude - $ReplicationGroupFolderNew.FilenameToExclude | Should -Be $ReplicationGroupFolder.FilenameToExclude - } - - # Clean up - Remove-DFSReplicationGroup ` - -GroupName $ReplicationGroupFolder.GroupName ` - -RemoveReplicatedFolders ` - -Force ` - -Confirm:$false - } - #endregion -} -finally -{ - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion -} diff --git a/Tests/Integration/MSFT_DFSReplicationGroupFolder.config.ps1 b/Tests/Integration/MSFT_DFSReplicationGroupFolder.config.ps1 deleted file mode 100644 index 37c8ad2..0000000 --- a/Tests/Integration/MSFT_DFSReplicationGroupFolder.config.ps1 +++ /dev/null @@ -1,45 +0,0 @@ -# If there is a .config.json file for these tests, read the test parameters from it. -$configFile = [System.IO.Path]::ChangeExtension($MyInvocation.MyCommand.Path,'json') -if (Test-Path -Path $configFile) -{ - $TestConfig = Get-Content -Path $configFile | ConvertFrom-Json -} -else -{ - # Example config parameters. - $TestConfig = @{ - Username = 'contoso.com\Administrator' - Password = 'MyP@ssw0rd!1' - Members = @('Server1','Server1') - Folders = @('TestFolder1','TestFolder2') - ContentPaths = @("$(ENV:Temp)TestFolder1","$(ENV:Temp)TestFolder2") - } -} - -$TestPassword = New-Object -Type SecureString [char[]] $TestConfig.Password | - Foreach-Object { $Password.AppendChar( $_ ) } - -$ReplicationGroupFolder = @{ - GroupName = 'IntegrationTestReplicationGroup' - Folders = $TestConfig.Folders - Members = $TestConfig.Members - FolderName = $TestConfig.Folders[0] - Description = "Integration Test Rep Group Folder $($TestConfig.Folders[0])" - DirectoryNameToExclude = @('Temp') - FilenameToExclude = @('*.bak','*.tmp') - PSDSCRunAsCredential = New-Object System.Management.Automation.PSCredential ($TestConfig.Username, $TestPassword) -} - -Configuration MSFT_DFSReplicationGroupFolder_Config { - Import-DscResource -ModuleName DFSDsc - node localhost { - DFSReplicationGroupFolder Integration_Test { - GroupName = $ReplicationGroupFolder.GroupName - FolderName = $ReplicationGroupFolder.FolderName - Description = $ReplicationGroupFolder.Description - DirectoryNameToExclude = $ReplicationGroupFolder.DirectoryNameToExclude - FilenameToExclude = $ReplicationGroupFolder.FilenameToExclude - PSDSCRunAsCredential = $ReplicationGroupFolder.PSDSCRunAsCredential - } - } -} diff --git a/Tests/Integration/MSFT_DFSReplicationGroupMembership.Integration.Tests.ps1 b/Tests/Integration/MSFT_DFSReplicationGroupMembership.Integration.Tests.ps1 deleted file mode 100644 index c9dc764..0000000 --- a/Tests/Integration/MSFT_DFSReplicationGroupMembership.Integration.Tests.ps1 +++ /dev/null @@ -1,136 +0,0 @@ -<# -These integration tests can only be run on a computer that: -1. Is a member of an Active Directory domain. -2. Has access to two Windows Server 2012 or greater servers with - the FS-DFS-Replication and RSAT-DFS-Mgmt-Con features installed. -3. An AD User account that has the required permissions that are needed - to create a DFS Replication Group. - -If the above are available then to allow these tests to be run a -MSFT_DFSReplicationGroupMembership.config.json file must be created in the same folder as -this file. The content should be a customized version of the following: -{ - "Username": "contoso.com\\Administrator", - "Folders": [ - "TestFolder1", - "TestFolder2" - ], - "Members": [ - "Server1", - "Server2" - ], - "ContentPaths": [ - "c:\\IntegrationTests\\TestFolder1", - "c:\\IntegrationTests\\TestFolder2" - ], - "Password": "MyPassword" -} - -If the above are available and configured these integration tests will run. -#> -$script:DSCModuleName = 'DFSDsc' -$script:DSCResourceName = 'MSFT_DFSReplicationGroupMembership' - -# Test to see if the config file is available. -$configFile = "$([System.IO.Path]::GetDirectoryName($MyInvocation.MyCommand.Path))\$($script:DSCResourceName).config.json" - -if (! (Test-Path -Path $configFile)) -{ - return -} - -#region HEADER -# Integration Test Template Version: 1.1.0 -[System.String] $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) - -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) -{ - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) -} - -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath "$($script:DSCModuleName).psd1") -Force -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Integration -#endregion - -# Using try/finally to always cleanup even if something awful happens. -try -{ - #region Integration Tests - $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1" - . $configFile - - Describe "$($script:DSCResourceName)_Integration" { - # Create the Replication group to work with - New-DFSReplicationGroup ` - -GroupName $ReplicationGroupMembership.GroupName - - foreach ($Member in $ReplicationGroupMembership.Members) - { - Add-DFSRMember ` - -GroupName $ReplicationGroupMembership.GroupName ` - -ComputerName $Member - } - - foreach ($Folder in $ReplicationGroupMembership.Folders) - { - New-DFSReplicatedFolder ` - -GroupName $ReplicationGroupMembership.GroupName ` - -FolderName $Folder - } - - #region DEFAULT TESTS - It 'Should compile and apply the MOF without throwing' { - { - $ConfigData = @{ - AllNodes = @( - @{ - NodeName = 'localhost' - PSDscAllowPlainTextPassword = $true - } - ) - } - - & "$($script:DSCResourceName)_Config" -OutputPath $TestDrive -ConfigurationData $ConfigData - Start-DscConfiguration -Path $TestDrive -ComputerName localhost -Wait -Verbose -Force - } | Should -Not -Throw - } - - It 'Should be able to call Get-DscConfiguration without throwing' { - { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw - } - #endregion - - It 'Should have set the resource and all the parameters should match' { - $ReplicationGroupMembershipNew = Get-DfsrMembership ` - -GroupName $ReplicationGroupMembership.GroupName ` - -ComputerName $ReplicationGroupMembership.Members[0] ` - -ErrorAction Stop | Where-Object -Property FolderName -eq $ReplicationGroupMembership.Folders[0] - $ReplicationGroupMembershipNew.GroupName | Should -Be $ReplicationGroupMembership.GroupName - $ReplicationGroupMembershipNew.ComputerName | Should -Be $ReplicationGroupMembership.Members[0] - $ReplicationGroupMembershipNew.FolderName | Should -Be $ReplicationGroupMembership.Folders[0] - $ReplicationGroupMembershipNew.ContentPath | Should -Be $ReplicationGroupMembership.ContentPath - $ReplicationGroupMembershipNew.StagingPathQuotaInMB | Should -Be $ReplicationGroupMembership.StagingPathQuotaInMB - $ReplicationGroupMembershipNew.ReadOnly | Should -Be $ReplicationGroupMembership.ReadOnly - $ReplicationGroupMembershipNew.PrimaryMember | Should -Be $ReplicationGroupMembership.PrimaryMember - } - - # Clean up - Remove-DFSReplicationGroup ` - -GroupName $ReplicationGroupMembership.GroupName ` - -RemoveReplicatedFolders ` - -Force ` - -Confirm:$false - } - #endregion -} -finally -{ - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion -} diff --git a/Tests/Integration/MSFT_DFSReplicationGroupMembership.config.ps1 b/Tests/Integration/MSFT_DFSReplicationGroupMembership.config.ps1 deleted file mode 100644 index 67cffc5..0000000 --- a/Tests/Integration/MSFT_DFSReplicationGroupMembership.config.ps1 +++ /dev/null @@ -1,47 +0,0 @@ -# If there is a .config.json file for these tests, read the test parameters from it. -$configFile = [System.IO.Path]::ChangeExtension($MyInvocation.MyCommand.Path,'json') -if (Test-Path -Path $configFile) -{ - $TestConfig = Get-Content -Path $configFile | ConvertFrom-Json -} -else -{ - # Example config parameters. - $TestConfig = @{ - Username = 'contoso.com\Administrator' - Password = 'MyP@ssw0rd!1' - Members = @('Server1','Server1') - Folders = @('TestFolder1','TestFolder2') - ContentPaths = @("$(ENV:Temp)TestFolder1","$(ENV:Temp)TestFolder2") - } -} - -$TestPassword = New-Object -Type SecureString [char[]] $TestConfig.Password | - Foreach-Object { $Password.AppendChar( $_ ) } - -$ReplicationGroupMembership = @{ - GroupName = 'IntegrationTestReplicationGroup' - Folders = $TestConfig.Folders - FolderName = $TestConfig.Folders[0] - Members = $TestConfig.Members - ComputerName = $TestConfig.Members[0] - ContentPath = $TestConfig.ContentPaths[0] - ReadOnly = $false - PrimaryMember = $true - PSDSCRunAsCredential = New-Object System.Management.Automation.PSCredential ($TestConfig.Username, $TestPassword) -} - -Configuration MSFT_DFSReplicationGroupMembership_Config { - Import-DscResource -ModuleName DFSDsc - node localhost { - DFSReplicationGroupMembership Integration_Test { - GroupName = $ReplicationGroupMembership.GroupName - FolderName = $ReplicationGroupMembership.FolderName - ComputerName = $ReplicationGroupMembership.ComputerName - ContentPath = $ReplicationGroupMembership.ContentPath - ReadOnly = $ReplicationGroupMembership.ReadOnly - PrimaryMember = $ReplicationGroupMembership.PrimaryMember - PSDSCRunAsCredential = $ReplicationGroupMembership.PSDSCRunAsCredential - } - } -} diff --git a/Tests/Integration/ModuleConflict.Tests.ps1 b/Tests/Integration/ModuleConflict.Tests.ps1 deleted file mode 100644 index d63c7ec..0000000 --- a/Tests/Integration/ModuleConflict.Tests.ps1 +++ /dev/null @@ -1,47 +0,0 @@ -$script:DSCModuleName = 'DFSDsc' -<# - These integration tests ensure that exported cmdlets names do not conflict - with any other names that are exposed by other common resource kit modules. -#> -$script:ModulesToTest = @( 'NetworkingDsc','ComputerManagementDsc' ) - -#region HEADER -# Integration Test Template Version: 1.1.0 -[System.String] $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) - -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) -{ - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) -} - -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath "$($script:DSCModuleName).psd1") -Force -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName 'All' ` - -TestType Integration - -#endregion - -# Using try/finally to always cleanup even if something awful happens. -try -{ - Describe "$($script:DSCModuleName)_CommonModuleConflict" { - - foreach ($moduleToTest in $script:ModulesToTest) - { - It "Should be able to install DSC Resource module '$moduleToTest'" { - { - Install-Module -Name $moduleToTest -ErrorAction Stop - } | Should -Not -Throw - } - } - } -} -finally -{ - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion -} diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 0023793..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,45 +0,0 @@ -#---------------------------------# -# environment configuration # -#---------------------------------# -version: 3.1.{build}.0 -environment: - gallery_api: - secure: 9ekJzfsPCDBkyLrfmov83XbbhZ6E2N3z+B/Io8NbDetbHc6hWS19zsDmy7t0Vvxv -install: - - git clone https://github.com/PowerShell/DscResource.Tests - - - ps: | - Install-WindowsFeature FS-DFS-Namespace,FS-DFS-Replication,RSAT-DFS-Mgmt-Con - $moduleName = 'DFSDsc' - $mainModuleFolder = "Modules\$moduleName" - Import-Module "$env:APPVEYOR_BUILD_FOLDER\DscResource.Tests\AppVeyor.psm1" - Invoke-AppveyorInstallTask - -#---------------------------------# -# build configuration # -#---------------------------------# - -build: false - -#---------------------------------# -# test configuration # -#---------------------------------# - -test_script: - - ps: | - Invoke-AppveyorTestScriptTask ` - -CodeCoverage ` - -CodeCovIo - -#---------------------------------# -# deployment configuration # -#---------------------------------# - -# scripts to run before deployment -deploy_script: - - ps: | - Invoke-AppveyorAfterTestTask ` - -Type 'Wiki' ` - -ResourceModuleName $moduleName - - Invoke-AppVeyorDeployTask diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000..a57bfa9 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,321 @@ +trigger: + branches: + include: + - master + paths: + include: + - source/* + tags: + include: + - "v*" + exclude: + - "*-*" + +stages: + - stage: Build + jobs: + - job: Package_Module + displayName: 'Package Module' + pool: + vmImage: 'ubuntu 16.04' + steps: + - task: GitVersion@5 + name: gitversion + displayName: 'Evaluate Next Version' + inputs: + runtime: 'core' + configFilePath: 'GitVersion.yml' + + - task: PowerShell@2 + name: package + displayName: 'Build & Package Module' + inputs: + filePath: './build.ps1' + arguments: '-Tasks pack -ResolveDependency' + pwsh: true + env: + ModuleVersion: $(gitVersion.Informationalversion) + + - task: PublishBuildArtifacts@1 + displayName: 'Publish Build Artifact' + inputs: + PathtoPublish: 'output/' + ArtifactName: 'output' + publishLocation: 'Container' + + - stage: Test + dependsOn: Build + jobs: + - job: Test_HQRM + displayName: 'HQRM' + pool: + vmImage: 'windows-2019' + timeoutInMinutes: 0 + steps: + - task: DownloadBuildArtifacts@0 + displayName: 'Download Build Artifact' + inputs: + buildType: 'current' + downloadType: 'single' + artifactName: 'output' + downloadPath: '$(Build.SourcesDirectory)' + + - task: PowerShell@2 + name: test + displayName: 'Run HQRM Test' + inputs: + filePath: './build.ps1' + arguments: '-Tasks hqrmtest' + pwsh: false + + - task: PublishTestResults@2 + displayName: 'Publish Test Results' + inputs: + testResultsFormat: 'NUnit' + testResultsFiles: 'output/testResults/NUnit*.xml' + testRunTitle: 'HQRM' + condition: succeededOrFailed() + + - job: Test_Unit_2016 + displayName: 'Unit (Windows Server 2016)' + pool: + vmImage: 'vs2017-win2016' + timeoutInMinutes: 0 + steps: + - powershell: | + $repositoryOwner,$repositoryName = $env:BUILD_REPOSITORY_NAME -split '/' + echo "##vso[task.setvariable variable=RepositoryOwner;isOutput=true]$repositoryOwner" + echo "##vso[task.setvariable variable=RepositoryName;isOutput=true]$repositoryName" + name: dscBuildVariable + displayName: 'Set Environment Variables' + + - task: DownloadBuildArtifacts@0 + displayName: 'Download Build Artifact' + inputs: + buildType: 'current' + downloadType: 'single' + artifactName: 'output' + downloadPath: '$(Build.SourcesDirectory)' + + - task: PowerShell@2 + name: installDFSFeatures + displayName: 'Install DFS Features' + inputs: + targetType: 'inline' + script: 'Install-WindowsFeature FS-DFS-Namespace, FS-DFS-Replication, RSAT-DFS-Mgmt-Con' + pwsh: false + + - task: PowerShell@2 + name: test + displayName: 'Run Unit Test' + inputs: + filePath: './build.ps1' + arguments: "-Tasks test -PesterScript 'tests/Unit'" + pwsh: false + + - task: PublishTestResults@2 + displayName: 'Publish Test Results' + inputs: + testResultsFormat: 'NUnit' + testResultsFiles: 'output/testResults/NUnit*.xml' + testRunTitle: 'Unit (Windows Server 2016)' + condition: succeededOrFailed() + + - task: PublishCodeCoverageResults@1 + displayName: 'Publish Code Coverage' + condition: succeededOrFailed() + inputs: + codeCoverageTool: 'JaCoCo' + summaryFileLocation: 'output/testResults/CodeCov*.xml' + pathToSources: '$(Build.SourcesDirectory)/output/$(DscBuildVariable.RepositoryName)' + + - job: Test_Integration_2016 + displayName: 'Integration (Windows Server 2016)' + pool: + vmImage: 'vs2017-win2016' + timeoutInMinutes: 0 + steps: + - task: DownloadBuildArtifacts@0 + displayName: 'Download Build Artifact' + inputs: + buildType: 'current' + downloadType: 'single' + artifactName: 'output' + downloadPath: '$(Build.SourcesDirectory)' + + - task: PowerShell@2 + name: configureWinRM + displayName: 'Configure WinRM' + inputs: + targetType: 'inline' + script: 'winrm quickconfig -quiet' + pwsh: false + + - task: PowerShell@2 + name: installDFSFeatures + displayName: 'Install DFS Features' + inputs: + targetType: 'inline' + script: 'Install-WindowsFeature FS-DFS-Namespace, FS-DFS-Replication, RSAT-DFS-Mgmt-Con' + pwsh: false + + - task: PowerShell@2 + name: test + displayName: 'Run Integration Test' + inputs: + filePath: './build.ps1' + arguments: "-Tasks test -PesterScript 'tests/Integration' -CodeCoverageThreshold 0" + pwsh: false + + - task: PublishTestResults@2 + displayName: 'Publish Test Results' + inputs: + testResultsFormat: 'NUnit' + testResultsFiles: 'output/testResults/NUnit*.xml' + testRunTitle: 'Integration (Windows Server 2016)' + condition: succeededOrFailed() + + - job: Test_Unit_2019 + displayName: 'Unit (Windows Server 2019)' + pool: + vmImage: 'windows-2019' + timeoutInMinutes: 0 + steps: + - powershell: | + $repositoryOwner,$repositoryName = $env:BUILD_REPOSITORY_NAME -split '/' + echo "##vso[task.setvariable variable=RepositoryOwner;isOutput=true]$repositoryOwner" + echo "##vso[task.setvariable variable=RepositoryName;isOutput=true]$repositoryName" + name: dscBuildVariable + displayName: 'Set Environment Variables' + + - task: DownloadBuildArtifacts@0 + displayName: 'Download Build Artifact' + inputs: + buildType: 'current' + downloadType: 'single' + artifactName: 'output' + downloadPath: '$(Build.SourcesDirectory)' + + - task: PowerShell@2 + name: installDFSFeatures + displayName: 'Install DFS Features' + inputs: + targetType: 'inline' + script: 'Install-WindowsFeature FS-DFS-Namespace, FS-DFS-Replication, RSAT-DFS-Mgmt-Con' + pwsh: false + + - task: PowerShell@2 + name: test + displayName: 'Run Unit Test' + inputs: + filePath: './build.ps1' + arguments: "-Tasks test -PesterScript 'tests/Unit'" + pwsh: false + + - task: PublishTestResults@2 + displayName: 'Publish Test Results' + inputs: + testResultsFormat: 'NUnit' + testResultsFiles: 'output/testResults/NUnit*.xml' + testRunTitle: 'Unit (Windows Server 2019)' + condition: succeededOrFailed() + + - task: PublishCodeCoverageResults@1 + displayName: 'Publish Code Coverage' + condition: succeededOrFailed() + inputs: + codeCoverageTool: 'JaCoCo' + summaryFileLocation: 'output/testResults/CodeCov*.xml' + pathToSources: '$(Build.SourcesDirectory)/output/$(dscBuildVariable.RepositoryName)' + + - job: Test_Integration_2019 + displayName: 'Integration (Windows Server 2019)' + pool: + vmImage: 'windows-2019' + timeoutInMinutes: 0 + steps: + - task: DownloadBuildArtifacts@0 + displayName: 'Download Build Artifact' + inputs: + buildType: 'current' + downloadType: 'single' + artifactName: 'output' + downloadPath: '$(Build.SourcesDirectory)' + + - task: PowerShell@2 + name: configureWinRM + displayName: 'Configure WinRM' + inputs: + targetType: 'inline' + script: 'winrm quickconfig -quiet' + pwsh: false + + - task: PowerShell@2 + name: installDFSFeatures + displayName: 'Install DFS Features' + inputs: + targetType: 'inline' + script: 'Install-WindowsFeature FS-DFS-Namespace, FS-DFS-Replication, RSAT-DFS-Mgmt-Con' + pwsh: false + + - task: PowerShell@2 + name: test + displayName: 'Run Integration Test' + inputs: + filePath: './build.ps1' + arguments: "-Tasks test -PesterScript 'tests/Integration' -CodeCoverageThreshold 0" + pwsh: false + + - task: PublishTestResults@2 + displayName: 'Publish Test Results' + inputs: + testResultsFormat: 'NUnit' + testResultsFiles: 'output/testResults/NUnit*.xml' + testRunTitle: 'Integration (Windows Server 2019)' + condition: succeededOrFailed() + + - stage: Deploy + dependsOn: Test + condition: | + and( + succeeded(), + or( + eq(variables['Build.SourceBranch'], 'refs/heads/master'), + startsWith(variables['Build.SourceBranch'], 'refs/tags/') + ), + contains(variables['System.TeamFoundationCollectionUri'], 'dsccommunity') + ) + jobs: + - job: Deploy_Module + displayName: 'Deploy Module' + pool: + vmImage: 'ubuntu 16.04' + steps: + - task: DownloadBuildArtifacts@0 + displayName: 'Download Build Artifact' + inputs: + buildType: 'current' + downloadType: 'single' + artifactName: 'output' + downloadPath: '$(Build.SourcesDirectory)' + + - task: PowerShell@2 + name: publishRelease + displayName: 'Publish Release' + inputs: + filePath: './build.ps1' + arguments: '-tasks publish' + pwsh: true + env: + GitHubToken: $(GitHubToken) + GalleryApiToken: $(GalleryApiToken) + + - task: PowerShell@2 + name: sendChangelogPR + displayName: 'Send Changelog PR' + inputs: + filePath: './build.ps1' + arguments: '-tasks Create_ChangeLog_GitHub_PR' + pwsh: true + env: + GitHubToken: $(GitHubToken) diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000..bbe1a8e --- /dev/null +++ b/build.ps1 @@ -0,0 +1,379 @@ +<# +.DESCRIPTION + Bootstrap and build script for PowerShell module pipeline +#> +[CmdletBinding()] +param +( + [Parameter(Position = 0)] + [string[]]$Tasks = '.', + + [Parameter()] + [String] + $CodeCoverageThreshold = '', + + [Parameter()] + [validateScript( + { Test-Path -Path $_ } + )] + $BuildConfig, + + [Parameter()] + # A Specific folder to build the artefact into. + $OutputDirectory = 'output', + + [Parameter()] + # Subdirectory name to build the module (under $OutputDirectory) + $BuiltModuleSubdirectory = '', + + # Can be a path (relative to $PSScriptRoot or absolute) to tell Resolve-Dependency & PSDepend where to save the required modules, + # or use CurrentUser, AllUsers to target where to install missing dependencies + # You can override the value for PSDepend in the Build.psd1 build manifest + # This defaults to $OutputDirectory/modules (by default: ./output/modules) + [Parameter()] + $RequiredModulesDirectory = $(Join-Path 'output' 'RequiredModules'), + + [Parameter()] + [object[]] + $PesterScript, + + # Filter which tags to run when invoking Pester tests + # This is used in the Invoke-Pester.pester.build.ps1 tasks + [Parameter()] + [string[]] + $PesterTag, + + # Filter which tags to exclude when invoking Pester tests + # This is used in the Invoke-Pester.pester.build.ps1 tasks + [Parameter()] + [string[]] + $PesterExcludeTag, + + # Filter which tags to run when invoking DSC Resource tests + # This is used in the DscResource.Test.build.ps1 tasks + [Parameter()] + [string[]] + $DscTestTag, + + # Filter which tags to exclude when invoking DSC Resource tests + # This is used in the DscResource.Test.build.ps1 tasks + [Parameter()] + [string[]] + $DscTestExcludeTag, + + [Parameter()] + [Alias('bootstrap')] + [switch]$ResolveDependency, + + [Parameter(DontShow)] + [AllowNull()] + $BuildInfo, + + [Parameter()] + [switch] + $AutoRestore +) + +# The BEGIN block (at the end of this file) handles the Bootstrap of the Environment before Invoke-Build can run the tasks +# if the -ResolveDependency (aka Bootstrap) is specified, the modules are already available, and can be auto loaded + +process +{ + + if ($MyInvocation.ScriptName -notLike '*Invoke-Build.ps1') + { + # Only run the process block through InvokeBuild (Look at the Begin block at the bottom of this script) + return + } + + # Execute the Build Process from the .build.ps1 path. + Push-Location -Path $PSScriptRoot -StackName BeforeBuild + + try + { + Write-Host -ForeGroundColor magenta "[build] Parsing defined tasks" + + # Load Default BuildInfo if not provided as parameter + if (!$PSBoundParameters.ContainsKey('BuildInfo')) + { + try + { + if (Test-Path $BuildConfig) + { + $ConfigFile = (Get-Item -Path $BuildConfig) + Write-Host "[build] Loading Configuration from $ConfigFile" + $BuildInfo = switch -Regex ($ConfigFile.Extension) + { + # Native Support for PSD1 + '\.psd1' + { + Import-PowerShellDataFile -Path $BuildConfig + } + # Support for yaml when module PowerShell-Yaml is available + '\.[yaml|yml]' + { + Import-Module -ErrorAction Stop -Name 'powershell-yaml' + ConvertFrom-Yaml -Yaml (Get-Content -Raw $ConfigFile) + } + # Native Support for JSON and JSONC (by Removing comments) + '\.[json|jsonc]' + { + $JSONC = (Get-Content -Raw -Path $ConfigFile) + $JSON = $JSONC -replace '(?m)\s*//.*?$' -replace '(?ms)/\*.*?\*/' + # This should probably be converted to hashtable for splatting + $JSON | ConvertFrom-Json + } + default + { + Write-Error "Extension '$_' not supported. using @{}" + @{ } + } + } + } + else + { + Write-Host -Object "Configuration file $BuildConfig not found" -ForegroundColor Red + $BuildInfo = @{ } + } + } + catch + { + Write-Host -Object "Error loading Config $ConfigFile.`r`n Are you missing dependencies?" -ForegroundColor Yellow + Write-Host -Object "Make sure you run './build.ps1 -ResolveDependency -tasks noop' to restore the Required modules the first time" -ForegroundColor Yellow + $BuildInfo = @{ } + Write-Error $_.Exception.Message + } + } + + # If the Invoke-Build Task Header is specified in the Build Info, set it + if ($BuildInfo.TaskHeader) + { + Set-BuildHeader ([scriptblock]::Create($BuildInfo.TaskHeader)) + } + + # Import Tasks from modules via their exported aliases when defined in BUild Manifest + # https://github.com/nightroman/Invoke-Build/tree/master/Tasks/Import#example-2-import-from-a-module-with-tasks + if ($BuildInfo.containsKey('ModuleBuildTasks')) + { + foreach ($Module in $BuildInfo['ModuleBuildTasks'].Keys) + { + try + { + Write-Host -ForegroundColor DarkGray -Verbose "Importing tasks from module $Module" + $LoadedModule = Import-Module $Module -PassThru -ErrorAction Stop + foreach ($TaskToExport in $BuildInfo['ModuleBuildTasks'].($Module)) + { + $LoadedModule.ExportedAliases.GetEnumerator().Where{ + # using -like to support wildcard + Write-Host -ForegroundColor DarkGray "`t Loading $($_.Key)..." + $_.Key -like $TaskToExport + }.ForEach{ + # Dot sourcing the Tasks via their exported aliases + . (Get-Alias $_.Key) + } + } + } + catch + { + Write-Host -ForegroundColor Red -Object "Could not load tasks for module $Module." + Write-Error $_ + } + } + } + + # Loading Build Tasks defined in the .build/ folder (will override the ones imported above if same task name) + Get-ChildItem -Path ".build/" -Recurse -Include *.ps1 -ErrorAction Ignore | ForEach-Object { + "Importing file $($_.BaseName)" | Write-Verbose + . $_.FullName + } + + # Synopsis: Empty task, useful to test the bootstrap process + task noop { } + + # Define default task sequence ("."), can be overridden in the $BuildInfo + task . { + Write-Build Yellow "No sequence currently defined for the default task" + } + + # Load Invoke-Build task sequences/workflows from $BuildInfo + Write-Host -ForegroundColor DarkGray "Adding Workflow from configuration:" + foreach ($Workflow in $BuildInfo.BuildWorkflow.keys) + { + Write-Verbose "Creating Build Workflow '$Workflow' with tasks $($BuildInfo.BuildWorkflow.($Workflow) -join ', ')" + $WorkflowItem = $BuildInfo.BuildWorkflow.($Workflow) + if ($WorkflowItem.Trim() -match '^\{(?[\w\W]*)\}$') + { + $WorkflowItem = [ScriptBlock]::Create($Matches['sb']) + } + Write-Host -ForegroundColor DarkGray " +-> $Workflow" + task $Workflow $WorkflowItem + } + + Write-Host -ForeGroundColor magenta "[build] Executing requested workflow: $($Tasks -join ', ')" + + } + finally + { + Pop-Location -StackName BeforeBuild + } +} + +Begin +{ + # Find build config if not specified + if (-not $BuildConfig) { + $config = Get-ChildItem -Path "$PSScriptRoot\*" -Include 'build.y*ml', 'build.psd1', 'build.json*' -ErrorAction:Ignore + if (-not $config -or ($config -is [array] -and $config.Length -le 0)) { + throw "No build configuration found. Specify path via -BuildConfig" + } + elseif ($config -is [array]) { + if ($config.Length -gt 1) { + throw "More than one build configuration found. Specify which one to use via -BuildConfig" + } + $BuildConfig = $config[0] + } + else { + $BuildConfig = $config + } + } + # Bootstrapping the environment before using Invoke-Build as task runner + + if ($MyInvocation.ScriptName -notLike '*Invoke-Build.ps1') + { + Write-Host -foregroundColor Green "[pre-build] Starting Build Init" + Push-Location $PSScriptRoot -StackName BuildModule + } + + if ($RequiredModulesDirectory -in @('CurrentUser', 'AllUsers')) + { + # Installing modules instead of saving them + Write-Host -foregroundColor Green "[pre-build] Required Modules will be installed for $RequiredModulesDirectory, not saved." + # Tell Resolve-Dependency to use provided scope as the -PSDependTarget if not overridden in Build.psd1 + $PSDependTarget = $RequiredModulesDirectory + } + else + { + if (-Not (Split-Path -IsAbsolute -Path $OutputDirectory)) + { + $OutputDirectory = Join-Path -Path $PSScriptRoot -ChildPath $OutputDirectory + } + + # Resolving the absolute path to save the required modules to + if (-Not (Split-Path -IsAbsolute -Path $RequiredModulesDirectory)) + { + $RequiredModulesDirectory = Join-Path -Path $PSScriptRoot -ChildPath $RequiredModulesDirectory + } + + # Create the output/modules folder if not exists, or resolve the Absolute path otherwise + if (Resolve-Path $RequiredModulesDirectory -ErrorAction SilentlyContinue) + { + Write-Debug "[pre-build] Required Modules path already exist at $RequiredModulesDirectory" + $RequiredModulesPath = Convert-Path $RequiredModulesDirectory + } + else + { + Write-Host -foregroundColor Green "[pre-build] Creating required modules directory $RequiredModulesDirectory." + $RequiredModulesPath = (New-Item -ItemType Directory -Force -Path $RequiredModulesDirectory).FullName + } + + # Prepending $RequiredModulesPath folder to PSModulePath to resolve from this folder FIRST + if ($RequiredModulesDirectory -notIn @('CurrentUser', 'AllUsers') -and + (($Env:PSModulePath -split [io.path]::PathSeparator) -notContains $RequiredModulesDirectory)) + { + Write-Host -foregroundColor Green "[pre-build] Prepending '$RequiredModulesDirectory' folder to PSModulePath" + $Env:PSModulePath = $RequiredModulesDirectory + [io.path]::PathSeparator + $Env:PSModulePath + } + + # Checking if the user should -ResolveDependency + if ((!(Get-Module -ListAvailable powershell-yaml) -or !(Get-Module -ListAvailable InvokeBuild) -or !(Get-Module -ListAvailable PSDepend)) -and !$ResolveDependency) + { + if ($AutoRestore -or !$PSBoundParameters.ContainsKey('Tasks') -or $Tasks -contains 'build') + { + Write-Host -ForegroundColor Yellow "[pre-build] Dependency missing, running './build.ps1 -ResolveDependency -Tasks noop' for you `r`n" + $ResolveDependency = $true + } + else + { + Write-Warning "Some required Modules are missing, make sure you first run with the '-ResolveDependency' parameter." + Write-Warning "Running 'build.ps1 -ResolveDependency -Tasks noop' will pull required modules without running the build task." + } + } + + if ($BuiltModuleSubdirectory) + { + if (-Not (Split-Path -IsAbsolute $BuiltModuleSubdirectory)) + { + $BuildModuleOutput = Join-Path $OutputDirectory $BuiltModuleSubdirectory + } + else + { + $BuildModuleOutput = $BuiltModuleSubdirectory + } + } + else + { + $BuildModuleOutput = $OutputDirectory + } + + # Prepending $BuildModuleOutput folder to PSModulePath to resolve built module from this folder + if (($Env:PSModulePath -split [io.path]::PathSeparator) -notContains $BuildModuleOutput) + { + Write-Host -foregroundColor Green "[pre-build] Prepending '$BuildModuleOutput' folder to PSModulePath" + $Env:PSModulePath = $BuildModuleOutput + [io.path]::PathSeparator + $Env:PSModulePath + } + + # Tell Resolve-Dependency to use $RequiredModulesPath as -PSDependTarget if not overridden in Build.psd1 + $PSDependTarget = $RequiredModulesPath + } + + if ($ResolveDependency) + { + Write-Host -Object "[pre-build] Resolving dependencies." -foregroundColor Green + $ResolveDependencyParams = @{ } + + # If BuildConfig is a Yaml file, bootstrap powershell-yaml via ResolveDependency + if ($BuildConfig -match '\.[yaml|yml]$') + { + $ResolveDependencyParams.add('WithYaml', $True) + } + + $ResolveDependencyAvailableParams = (Get-Command -Name '.\Resolve-Dependency.ps1').parameters.keys + foreach ($CmdParameter in $ResolveDependencyAvailableParams) + { + + # The parameter has been explicitly used for calling the .build.ps1 + if ($MyInvocation.BoundParameters.ContainsKey($CmdParameter)) + { + $ParamValue = $MyInvocation.BoundParameters.ContainsKey($CmdParameter) + Write-Debug " adding $CmdParameter :: $ParamValue [from user-provided parameters to Build.ps1]" + $ResolveDependencyParams.Add($CmdParameter, $ParamValue) + } + # Use defaults parameter value from Build.ps1, if any + else + { + if ($ParamValue = Get-Variable -Name $CmdParameter -ValueOnly -ErrorAction Ignore) + { + Write-Debug " adding $CmdParameter :: $ParamValue [from default Build.ps1 variable]" + $ResolveDependencyParams.add($CmdParameter, $ParamValue) + } + } + } + + Write-Host -foregroundColor Green "[pre-build] Starting bootstrap process." + .\Resolve-Dependency.ps1 @ResolveDependencyParams + } + + if ($MyInvocation.ScriptName -notLike '*Invoke-Build.ps1') + { + Write-Verbose "Bootstrap completed. Handing back to InvokeBuild." + if ($PSBoundParameters.ContainsKey('ResolveDependency')) + { + Write-Verbose "Dependency already resolved. Removing task" + $null = $PSBoundParameters.Remove('ResolveDependency') + } + Write-Host -foregroundColor Green "[build] Starting build with InvokeBuild." + Invoke-Build @PSBoundParameters -Task $Tasks -File $MyInvocation.MyCommand.Path + Pop-Location -StackName BuildModule + return + } +} diff --git a/build.yaml b/build.yaml new file mode 100644 index 0000000..a890f69 --- /dev/null +++ b/build.yaml @@ -0,0 +1,91 @@ +--- +#################################################### +# ModuleBuilder Configuration # +#################################################### +CopyDirectories: + - en-US + - DSCResources + - Modules +Encoding: UTF8 +VersionedOutputDirectory: true + +#################################################### +# Pipeline Configuration # +#################################################### +BuildWorkflow: + '.': + - build + - test + + build: + - Clean + - Build_Module_ModuleBuilder + - Build_NestedModules_ModuleBuilder + - Create_changelog_release_output + - Generate_Conceptual_Help + - Generate_Wiki_Content + + pack: + - build + - package_module_nupkg + + hqrmtest: + - DscResource_Tests_Stop_On_Fail + + test: + - Pester_Tests_Stop_On_Fail + - Pester_if_Code_Coverage_Under_Threshold + + publish: + - Publish_release_to_GitHub + - publish_module_to_gallery + + +#################################################### +# PESTER Configuration # +#################################################### + +Pester: + OutputFormat: NUnitXML + ExcludeFromCodeCoverage: + Script: + - tests/Unit + ExcludeTag: + Tag: + CodeCoverageThreshold: 65 + +DscTest: + OutputFormat: NUnitXML + ExcludeTag: + - 'Common Tests - New Error-Level Script Analyzer Rules' + ExcludeSourceFile: + - output + +Resolve-Dependency: + Gallery: 'PSGallery' + AllowPrerelease: false + Verbose: false + +ModuleBuildTasks: + Sampler: + - '*.build.Sampler.ib.tasks' + DscResource.DocGenerator: + - 'Task.*' + +TaskHeader: | + param($Path) + "" + "=" * 79 + Write-Build Cyan "`t`t`t$($Task.Name.replace("_"," ").ToUpper())" + Write-Build DarkGray "$(Get-BuildSynopsis $Task)" + "-" * 79 + Write-Build DarkGray " $Path" + Write-Build DarkGray " $($Task.InvocationInfo.ScriptName):$($Task.InvocationInfo.ScriptLineNumber)" + "" + +GitHubConfig: + GitHubFilesToAdd: + - 'CHANGELOG.md' + GitHubConfigUserName: dscbot + GitHubConfigUserEmail: dsccommunity@outlook.com + UpdateChangelogOnPrerelease: false diff --git a/source/Build.psd1 b/source/Build.psd1 new file mode 100644 index 0000000..c80d28e --- /dev/null +++ b/source/Build.psd1 @@ -0,0 +1,5 @@ +@{ + Path = 'DFSDsc.psd1' +} +# Waiting for ModuleBuilder to do away with this file +# when all parameters are provided to the function diff --git a/DFSDsc.psd1 b/source/DFSDsc.psd1 similarity index 60% rename from DFSDsc.psd1 rename to source/DFSDsc.psd1 index f341566..3be7a0c 100644 --- a/DFSDsc.psd1 +++ b/source/DFSDsc.psd1 @@ -1,48 +1,45 @@ @{ # Version number of this module. - moduleVersion = '4.4.0.0' + ModuleVersion = '0.0.1' # ID used to uniquely identify this module - GUID = '3bcb9c66-ea0b-4675-bd46-c390a382c388' + GUID = '3bcb9c66-ea0b-4675-bd46-c390a382c388' # Author of this module - Author = 'Microsoft Corporation' + Author = 'DSC Community' # Company or vendor of this module - CompanyName = 'Microsoft Corporation' + CompanyName = 'DSC Community' # Copyright statement for this module - Copyright = '(c) 2018 Microsoft Corporation. All rights reserved.' + Copyright = 'Copyright the DSC Community contributors. All rights reserved.' # Description of the functionality provided by this module - Description = 'DSC resources for configuring Distributed File System Replication and Namespaces.' + Description = 'DSC resources for configuring Distributed File System Replication and Namespaces.' # Minimum version of the Windows PowerShell engine required by this module - PowerShellVersion = '5.0' + PowerShellVersion = '5.0' # Minimum version of the common language runtime (CLR) required by this module - CLRVersion = '4.0' + CLRVersion = '4.0' # Processor architecture (None, X86, Amd64) required by this module ProcessorArchitecture = 'None' - # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess - # NestedModules = @() - # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. - FunctionsToExport = @() + FunctionsToExport = @() # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. - CmdletsToExport = @() + CmdletsToExport = @() # Variables to export from this module - VariablesToExport = @() + VariablesToExport = @() # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. - AliasesToExport = @() + AliasesToExport = @() # DSC resources to export from this module - DscResourcesToExport = @( + DscResourcesToExport = @( 'DFSNamespaceFolder', 'DFSNamespaceRoot', 'DFSNamespaceServerConfiguration', @@ -50,33 +47,28 @@ 'DFSReplicationGroupConnection', 'DFSReplicationGroupFolder', 'DFSReplicationGroupMembership' - ) + ) # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. - PrivateData = @{ + PrivateData = @{ PSData = @{ + # Set to a prerelease string value if the release should be a prerelease. + Prerelease = '' + # Tags applied to this module. These help with module discovery in online galleries. - Tags = @( 'DSC', 'DesiredStateConfiguration', 'DSCResourceKit', 'DSCResource', 'DFS', 'DistributedFileSystem' ) + Tags = @( 'DSC', 'DesiredStateConfiguration', 'DSCResource', 'DFS', 'DistributedFileSystem', 'Replication', 'Namespace' ) # A URL to the license for this module. - LicenseUri = 'https://github.com/PowerShell/DFSDsc/blob/master/LICENSE' + LicenseUri = 'https://github.com/dsccommunity/DFSDsc/blob/master/LICENSE' # A URL to the main website for this project. - ProjectUri = 'https://github.com/PowerShell/DFSDsc' + ProjectUri = 'https://github.com/dsccommunity/DFSDsc' - # ReleaseNotes of this module - ReleaseNotes = '- Fix example publish to PowerShell Gallery by adding `gallery_api` - environment variable to `AppVeyor.yml` - fixes [Issue 91](https://github.com/PowerShell/DfsDsc/issues/91). -- Fix minor style issues in statement case. + # A URL to an icon representing this module. + IconUri = 'https://dsccommunity.org/images/DSC_Logo_300p.png' -' + # ReleaseNotes of this module + ReleaseNotes = '' } # End of PSData hashtable } # End of PrivateData hashtable } - - - - - - - diff --git a/DSCResources/MSFT_DFSNamespaceFolder/MSFT_DFSNamespaceFolder.psm1 b/source/DSCResources/DSC_DFSNamespaceFolder/DSC_DFSNamespaceFolder.psm1 similarity index 90% rename from DSCResources/MSFT_DFSNamespaceFolder/MSFT_DFSNamespaceFolder.psm1 rename to source/DSCResources/DSC_DFSNamespaceFolder/DSC_DFSNamespaceFolder.psm1 index 160d0b3..368106b 100644 --- a/DSCResources/MSFT_DFSNamespaceFolder/MSFT_DFSNamespaceFolder.psm1 +++ b/source/DSCResources/DSC_DFSNamespaceFolder/DSC_DFSNamespaceFolder.psm1 @@ -1,14 +1,12 @@ $modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules' -# Import the Certificate Resource Helper Module +# Import the DFSDsc.Common Module Import-Module -Name (Join-Path -Path $modulePath ` - -ChildPath (Join-Path -Path 'DFSDsc.ResourceHelper' ` - -ChildPath 'DFSDsc.ResourceHelper.psm1')) + -ChildPath (Join-Path -Path 'DFSDsc.Common' ` + -ChildPath 'DFSDsc.Common.psm1')) # Import Localization Strings -$localizedData = Get-LocalizedData ` - -ResourceName 'MSFT_DFSNamespaceFolder' ` - -ResourcePath (Split-Path -Parent $Script:MyInvocation.MyCommand.Path) +$script:localizedData = Get-LocalizedData -ResourceName 'DSC_DFSNamespaceFolder' <# .SYNOPSIS @@ -45,7 +43,7 @@ function Get-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.GettingNamespaceFolderMessage) ` + $($script:localizedData.GettingNamespaceFolderMessage) ` -f $Path,$TargetPath ) -join '' ) @@ -65,7 +63,7 @@ function Get-TargetResource # The namespace folder exists Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceFolderExistsMessage) ` + $($script:localizedData.NamespaceFolderExistsMessage) ` -f $Path ) -join '' ) } @@ -74,7 +72,7 @@ function Get-TargetResource # The namespace folder does not exist Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceFolderDoesNotExistMessage) ` + $($script:localizedData.NamespaceFolderDoesNotExistMessage) ` -f $Path ) -join '' ) return $returnValue @@ -104,7 +102,7 @@ function Get-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceFolderTargetExistsMessage) ` + $($script:localizedData.NamespaceFolderTargetExistsMessage) ` -f $Path,$TargetPath ) -join '' ) } @@ -113,7 +111,7 @@ function Get-TargetResource # The target does not exist in this namespace Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceFolderTargetDoesNotExistMessage) ` + $($script:localizedData.NamespaceFolderTargetDoesNotExistMessage) ` -f $Path,$TargetPath ) -join '' ) } # if @@ -198,7 +196,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.SettingNamespaceFolderMessage) ` + $($script:localizedData.SettingNamespaceFolderMessage) ` -f $Path,$TargetPath ) -join '' ) @@ -266,7 +264,7 @@ function Set-TargetResource $folderProperties.GetEnumerator() | ForEach-Object -Process { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceFolderUpdateParameterMessage) ` + $($script:localizedData.NamespaceFolderUpdateParameterMessage) ` -f $Path,$_.name, $_.value ) -join '' ) } @@ -330,7 +328,7 @@ function Set-TargetResource $targetProperties.GetEnumerator() | ForEach-Object -Process { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceFolderTargetUpdateParameterMessage) ` + $($script:localizedData.NamespaceFolderTargetUpdateParameterMessage) ` -f $Path,$TargetPath,$_.name, $_.value ) -join '' ) } @@ -357,7 +355,7 @@ function Set-TargetResource $PSBoundParameters.GetEnumerator() | ForEach-Object -Process { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceFolderUpdateParameterMessage) ` + $($script:localizedData.NamespaceFolderUpdateParameterMessage) ` -f $Path,$TargetPath,$_.name, $_.value ) -join '' ) } @@ -383,7 +381,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceFolderTargetRemovedMessage) ` + $($script:localizedData.NamespaceFolderTargetRemovedMessage) ` -f $Path,$TargetPath ) -join '' ) } @@ -468,7 +466,7 @@ function Test-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.TestingNamespaceFolderMessage) ` + $($script:localizedData.TestingNamespaceFolderMessage) ` -f $Path,$TargetPath ) -join '' ) @@ -492,7 +490,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceFolderParameterNeedsUpdateMessage) ` + $($script:localizedData.NamespaceFolderParameterNeedsUpdateMessage) ` -f $Path,'Description' ) -join '' ) $desiredConfigurationMatch = $false @@ -503,7 +501,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceFolderParameterNeedsUpdateMessage) ` + $($script:localizedData.NamespaceFolderParameterNeedsUpdateMessage) ` -f $Path,'TimeToLiveSec' ) -join '' ) $desiredConfigurationMatch = $false @@ -514,7 +512,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceFolderParameterNeedsUpdateMessage) ` + $($script:localizedData.NamespaceFolderParameterNeedsUpdateMessage) ` -f $Path,'EnableInsiteReferrals' ) -join '' ) $desiredConfigurationMatch = $false @@ -525,7 +523,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceFolderParameterNeedsUpdateMessage) ` + $($script:localizedData.NamespaceFolderParameterNeedsUpdateMessage) ` -f $Path,'EnableTargetFailback' ) -join '' ) $desiredConfigurationMatch = $false @@ -542,7 +540,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceFolderTargetParameterNeedsUpdateMessage) ` + $($script:localizedData.NamespaceFolderTargetParameterNeedsUpdateMessage) ` -f $Path,$TargetPath,'ReferralPriorityClass' ) -join '' ) $desiredConfigurationMatch = $false @@ -553,7 +551,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceFolderTargetParameterNeedsUpdateMessage) ` + $($script:localizedData.NamespaceFolderTargetParameterNeedsUpdateMessage) ` -f $Path,$TargetPath,'ReferralPriorityRank' ) -join '' ) $desiredConfigurationMatch = $false @@ -564,7 +562,7 @@ function Test-TargetResource # The Folder target does not exist but should - change required Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceFolderTargetDoesNotExistButShouldMessage) ` + $($script:localizedData.NamespaceFolderTargetDoesNotExistButShouldMessage) ` -f $Path,$TargetPath ) -join '' ) $desiredConfigurationMatch = $false @@ -575,7 +573,7 @@ function Test-TargetResource # Ths Namespace Folder doesn't exist but should - change required Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceFolderDoesNotExistButShouldMessage) ` + $($script:localizedData.NamespaceFolderDoesNotExistButShouldMessage) ` -f $Path ) -join '' ) $desiredConfigurationMatch = $false @@ -595,7 +593,7 @@ function Test-TargetResource # The Folder target exists but should not - change required Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceFolderTargetExistsButShouldNotMessage) ` + $($script:localizedData.NamespaceFolderTargetExistsButShouldNotMessage) ` -f $Path,$TargetPath ) -join '' ) $desiredConfigurationMatch = $false @@ -605,7 +603,7 @@ function Test-TargetResource # The Namespace exists but the target doesn't - change not required Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceFolderTargetDoesNotExistAndShouldNotMessage) ` + $($script:localizedData.NamespaceFolderTargetDoesNotExistAndShouldNotMessage) ` -f $Path,$TargetPath ) -join '' ) } @@ -615,7 +613,7 @@ function Test-TargetResource # The Namespace does not exist (so neither does the target) - change not required Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceFolderDoesNotExistAndShouldNotMessage) ` + $($script:localizedData.NamespaceFolderDoesNotExistAndShouldNotMessage) ` -f $Path ) -join '' ) } diff --git a/DSCResources/MSFT_DFSNamespaceFolder/MSFT_DFSNamespaceFolder.schema.mof b/source/DSCResources/DSC_DFSNamespaceFolder/DSC_DFSNamespaceFolder.schema.mof similarity index 96% rename from DSCResources/MSFT_DFSNamespaceFolder/MSFT_DFSNamespaceFolder.schema.mof rename to source/DSCResources/DSC_DFSNamespaceFolder/DSC_DFSNamespaceFolder.schema.mof index 32a5677..9587be9 100644 --- a/DSCResources/MSFT_DFSNamespaceFolder/MSFT_DFSNamespaceFolder.schema.mof +++ b/source/DSCResources/DSC_DFSNamespaceFolder/DSC_DFSNamespaceFolder.schema.mof @@ -1,5 +1,5 @@ [ClassVersion("1.0.0.0"), FriendlyName("DFSNamespaceFolder")] -class MSFT_DFSNamespaceFolder : OMI_BaseResource +class DSC_DFSNamespaceFolder : OMI_BaseResource { [Key, Description("Specifies a path for the root of a DFS namespace.")] String Path; [Key, Description("Specifies a path for a root target of the DFS namespace.")] String TargetPath; diff --git a/DSCResources/MSFT_DFSNamespaceFolder/README.md b/source/DSCResources/DSC_DFSNamespaceFolder/README.md similarity index 100% rename from DSCResources/MSFT_DFSNamespaceFolder/README.md rename to source/DSCResources/DSC_DFSNamespaceFolder/README.md diff --git a/DSCResources/MSFT_DFSNamespaceFolder/en-us/MSFT_DFSNamespaceFolder.strings.psd1 b/source/DSCResources/DSC_DFSNamespaceFolder/en-US/DSC_DFSNamespaceFolder.strings.psd1 similarity index 100% rename from DSCResources/MSFT_DFSNamespaceFolder/en-us/MSFT_DFSNamespaceFolder.strings.psd1 rename to source/DSCResources/DSC_DFSNamespaceFolder/en-US/DSC_DFSNamespaceFolder.strings.psd1 diff --git a/DSCResources/MSFT_DFSNamespaceRoot/MSFT_DFSNamespaceRoot.psm1 b/source/DSCResources/DSC_DFSNamespaceRoot/DSC_DFSNamespaceRoot.psm1 similarity index 90% rename from DSCResources/MSFT_DFSNamespaceRoot/MSFT_DFSNamespaceRoot.psm1 rename to source/DSCResources/DSC_DFSNamespaceRoot/DSC_DFSNamespaceRoot.psm1 index af93916..f3b435d 100644 --- a/DSCResources/MSFT_DFSNamespaceRoot/MSFT_DFSNamespaceRoot.psm1 +++ b/source/DSCResources/DSC_DFSNamespaceRoot/DSC_DFSNamespaceRoot.psm1 @@ -1,14 +1,12 @@ $modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules' -# Import the Certificate Resource Helper Module +# Import the DFSDsc.Common Module Import-Module -Name (Join-Path -Path $modulePath ` - -ChildPath (Join-Path -Path 'DFSDsc.ResourceHelper' ` - -ChildPath 'DFSDsc.ResourceHelper.psm1')) + -ChildPath (Join-Path -Path 'DFSDsc.Common' ` + -ChildPath 'DFSDsc.Common.psm1')) # Import Localization Strings -$localizedData = Get-LocalizedData ` - -ResourceName 'MSFT_DFSNamespaceRoot' ` - -ResourcePath (Split-Path -Parent $Script:MyInvocation.MyCommand.Path) +$script:localizedData = Get-LocalizedData -ResourceName 'DSC_DFSNamespaceRoot' <# .SYNOPSIS @@ -53,7 +51,7 @@ function Get-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.GettingNamespaceRootMessage) ` + $($script:localizedData.GettingNamespaceRootMessage) ` -f $Type,$Path,$TargetPath ) -join '' ) @@ -74,7 +72,7 @@ function Get-TargetResource # The namespace exists Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceRootExistsMessage) ` + $($script:localizedData.NamespaceRootExistsMessage) ` -f $Type,$Path ) -join '' ) } @@ -83,7 +81,7 @@ function Get-TargetResource # The namespace does not exist Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceRootDoesNotExistMessage) ` + $($script:localizedData.NamespaceRootDoesNotExistMessage) ` -f $Type,$Path ) -join '' ) return $returnValue @@ -116,7 +114,7 @@ function Get-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceRootTargetExistsMessage) ` + $($script:localizedData.NamespaceRootTargetExistsMessage) ` -f $Type,$Path,$TargetPath ) -join '' ) } @@ -125,7 +123,7 @@ function Get-TargetResource # The target does not exist in this namespace Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceRootTargetDoesNotExistMessage) ` + $($script:localizedData.NamespaceRootTargetDoesNotExistMessage) ` -f $Type,$Path,$TargetPath ) -join '' ) } # if @@ -239,7 +237,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.SettingNamespaceRootMessage) ` + $($script:localizedData.SettingNamespaceRootMessage) ` -f $Type,$Path,$TargetPath ) -join '' ) @@ -334,7 +332,7 @@ function Set-TargetResource $rootProperties.GetEnumerator() | ForEach-Object -Process { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceRootUpdateParameterMessage) ` + $($script:localizedData.NamespaceRootUpdateParameterMessage) ` -f $Type,$Path,$_.name, $_.value ) -join '' ) } @@ -398,7 +396,7 @@ function Set-TargetResource $targetProperties.GetEnumerator() | ForEach-Object -Process { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceRootTargetUpdateParameterMessage) ` + $($script:localizedData.NamespaceRootTargetUpdateParameterMessage) ` -f $Type,$Path,$TargetPath,$_.name, $_.value ) -join '' ) } @@ -425,7 +423,7 @@ function Set-TargetResource $PSBoundParameters.GetEnumerator() | ForEach-Object -Process { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceRootUpdateParameterMessage) ` + $($script:localizedData.NamespaceRootUpdateParameterMessage) ` -f $Type,$Path,$_.name, $_.value ) -join '' ) } @@ -452,7 +450,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceRootTargetRemovedMessage) ` + $($script:localizedData.NamespaceRootTargetRemovedMessage) ` -f $Type,$Path,$TargetPath ) -join '' ) } # if @@ -566,7 +564,7 @@ function Test-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.TestingNamespaceRootMessage) ` + $($script:localizedData.TestingNamespaceRootMessage) ` -f $Type,$Path,$TargetPath ) -join '' ) @@ -590,7 +588,7 @@ function Test-TargetResource if (($root.Type -replace ' ','') -ne $Type) { New-InvalidOperationException ` - -Message ($($LocalizedData.NamespaceRootTypeConversionError) ` + -Message ($($script:localizedData.NamespaceRootTypeConversionError) ` -f $Type,($root.Type -replace ' ','')) } # if @@ -600,7 +598,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceRootParameterNeedsUpdateMessage) ` + $($script:localizedData.NamespaceRootParameterNeedsUpdateMessage) ` -f $Type,$Path,'Description' ) -join '' ) @@ -612,7 +610,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceRootParameterNeedsUpdateMessage) ` + $($script:localizedData.NamespaceRootParameterNeedsUpdateMessage) ` -f $Type,$Path,'TimeToLiveSec' ) -join '' ) @@ -624,7 +622,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceRootParameterNeedsUpdateMessage) ` + $($script:localizedData.NamespaceRootParameterNeedsUpdateMessage) ` -f $Type,$Path,'EnableSiteCosting' ) -join '' ) @@ -636,7 +634,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceRootParameterNeedsUpdateMessage) ` + $($script:localizedData.NamespaceRootParameterNeedsUpdateMessage) ` -f $Type,$Path,'EnableInsiteReferrals' ) -join '' ) @@ -648,7 +646,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceRootParameterNeedsUpdateMessage) ` + $($script:localizedData.NamespaceRootParameterNeedsUpdateMessage) ` -f $Type,$Path,'EnableAccessBasedEnumeration' ) -join '' ) @@ -660,7 +658,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceRootParameterNeedsUpdateMessage) ` + $($script:localizedData.NamespaceRootParameterNeedsUpdateMessage) ` -f $Type,$Path,'EnableRootScalability' ) -join '' ) @@ -672,7 +670,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceRootParameterNeedsUpdateMessage) ` + $($script:localizedData.NamespaceRootParameterNeedsUpdateMessage) ` -f $Type,$Path,'EnableTargetFailback' ) -join '' ) @@ -690,7 +688,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceRootTargetParameterNeedsUpdateMessage) ` + $($script:localizedData.NamespaceRootTargetParameterNeedsUpdateMessage) ` -f $Type,$Path,$TargetPath,'ReferralPriorityClass' ) -join '' ) $desiredConfigurationMatch = $false @@ -701,7 +699,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceRootTargetParameterNeedsUpdateMessage) ` + $($script:localizedData.NamespaceRootTargetParameterNeedsUpdateMessage) ` -f $Type,$Path,$TargetPath,'ReferralPriorityRank' ) -join '' ) $desiredConfigurationMatch = $false @@ -712,7 +710,7 @@ function Test-TargetResource # The Root target does not exist but should - change required Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceRootTargetDoesNotExistButShouldMessage) ` + $($script:localizedData.NamespaceRootTargetDoesNotExistButShouldMessage) ` -f $Type,$Path,$TargetPath ) -join '' ) $desiredConfigurationMatch = $false @@ -723,7 +721,7 @@ function Test-TargetResource # Ths Namespace root doesn't exist but should - change required Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceRootDoesNotExistButShouldMessage) ` + $($script:localizedData.NamespaceRootDoesNotExistButShouldMessage) ` -f $Type,$Path ) -join '' ) $desiredConfigurationMatch = $false @@ -743,7 +741,7 @@ function Test-TargetResource # The Root target exists but should not - change required Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceRootTargetExistsButShouldNotMessage) ` + $($script:localizedData.NamespaceRootTargetExistsButShouldNotMessage) ` -f $Type,$Path,$TargetPath ) -join '' ) $desiredConfigurationMatch = $false @@ -753,7 +751,7 @@ function Test-TargetResource # The Namespace exists but the target doesn't - change not required Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceRootTargetDoesNotExistAndShouldNotMessage) ` + $($script:localizedData.NamespaceRootTargetDoesNotExistAndShouldNotMessage) ` -f $Type,$Path,$TargetPath ) -join '' ) } # if @@ -763,7 +761,7 @@ function Test-TargetResource # The Namespace does not exist (so neither does the target) - change not required Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceRootDoesNotExistAndShouldNotMessage) ` + $($script:localizedData.NamespaceRootDoesNotExistAndShouldNotMessage) ` -f $Type,$Path ) -join '' ) } # if diff --git a/DSCResources/MSFT_DFSNamespaceRoot/MSFT_DFSNamespaceRoot.schema.mof b/source/DSCResources/DSC_DFSNamespaceRoot/DSC_DFSNamespaceRoot.schema.mof similarity index 97% rename from DSCResources/MSFT_DFSNamespaceRoot/MSFT_DFSNamespaceRoot.schema.mof rename to source/DSCResources/DSC_DFSNamespaceRoot/DSC_DFSNamespaceRoot.schema.mof index ba099fc..2f754a4 100644 --- a/DSCResources/MSFT_DFSNamespaceRoot/MSFT_DFSNamespaceRoot.schema.mof +++ b/source/DSCResources/DSC_DFSNamespaceRoot/DSC_DFSNamespaceRoot.schema.mof @@ -1,5 +1,5 @@ [ClassVersion("1.0.0.0"), FriendlyName("DFSNamespaceRoot")] -class MSFT_DFSNamespaceRoot : OMI_BaseResource +class DSC_DFSNamespaceRoot : OMI_BaseResource { [Key, Description("Specifies a path for the root of a DFS namespace.")] String Path; [Key, Description("Specifies a path for a root target of the DFS namespace.")] String TargetPath; diff --git a/DSCResources/MSFT_DFSNamespaceRoot/README.md b/source/DSCResources/DSC_DFSNamespaceRoot/README.md similarity index 100% rename from DSCResources/MSFT_DFSNamespaceRoot/README.md rename to source/DSCResources/DSC_DFSNamespaceRoot/README.md diff --git a/DSCResources/MSFT_DFSNamespaceRoot/en-us/MSFT_DFSNamespaceRoot.strings.psd1 b/source/DSCResources/DSC_DFSNamespaceRoot/en-US/DSC_DFSNamespaceRoot.strings.psd1 similarity index 100% rename from DSCResources/MSFT_DFSNamespaceRoot/en-us/MSFT_DFSNamespaceRoot.strings.psd1 rename to source/DSCResources/DSC_DFSNamespaceRoot/en-US/DSC_DFSNamespaceRoot.strings.psd1 diff --git a/DSCResources/MSFT_DFSNamespaceServerConfiguration/MSFT_DFSNamespaceServerConfiguration.psm1 b/source/DSCResources/DSC_DFSNamespaceServerConfiguration/DSC_DFSNamespaceServerConfiguration.psm1 similarity index 87% rename from DSCResources/MSFT_DFSNamespaceServerConfiguration/MSFT_DFSNamespaceServerConfiguration.psm1 rename to source/DSCResources/DSC_DFSNamespaceServerConfiguration/DSC_DFSNamespaceServerConfiguration.psm1 index 22649cb..5342803 100644 --- a/DSCResources/MSFT_DFSNamespaceServerConfiguration/MSFT_DFSNamespaceServerConfiguration.psm1 +++ b/source/DSCResources/DSC_DFSNamespaceServerConfiguration/DSC_DFSNamespaceServerConfiguration.psm1 @@ -1,14 +1,12 @@ $modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules' -# Import the Certificate Resource Helper Module +# Import the DFSDsc.Common Module Import-Module -Name (Join-Path -Path $modulePath ` - -ChildPath (Join-Path -Path 'DFSDsc.ResourceHelper' ` - -ChildPath 'DFSDsc.ResourceHelper.psm1')) + -ChildPath (Join-Path -Path 'DFSDsc.Common' ` + -ChildPath 'DFSDsc.Common.psm1')) # Import Localization Strings -$localizedData = Get-LocalizedData ` - -ResourceName 'MSFT_DFSNamespaceServerConfiguration' ` - -ResourcePath (Split-Path -Parent $Script:MyInvocation.MyCommand.Path) +$script:localizedData = Get-LocalizedData -ResourceName 'DSC_DFSNamespaceServerConfiguration' <# This is an array of all the parameters used by this resource. @@ -55,7 +53,7 @@ function Get-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.GettingNamespaceServerConfigurationMessage) + $($script:localizedData.GettingNamespaceServerConfigurationMessage) ) -join '' ) # Get the current DFSN Server Configuration @@ -122,7 +120,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.SettingNamespaceServerConfigurationMessage) + $($script:localizedData.SettingNamespaceServerConfigurationMessage) ) -join '' ) # Get the current DFSN Server Configuration @@ -147,7 +145,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceServerConfigurationUpdateParameterMessage) ` + $($script:localizedData.NamespaceServerConfigurationUpdateParameterMessage) ` -f $parameter.Name,$parameterNew ) -join '' ) @@ -168,7 +166,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceServerConfigurationUpdatedMessage) + $($script:localizedData.NamespaceServerConfigurationUpdatedMessage) ) -join '' ) if ($restart) @@ -181,7 +179,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceServerConfigurationServiceRestartedMessage) + $($script:localizedData.NamespaceServerConfigurationServiceRestartedMessage) ) -join '' ) } } # if @@ -232,7 +230,7 @@ function Test-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.TestingNamespaceServerConfigurationMessage) + $($script:localizedData.TestingNamespaceServerConfigurationMessage) ) -join '' ) # Flag to signal whether settings are correct @@ -254,7 +252,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.NamespaceServerConfigurationParameterNeedsUpdateMessage) ` + $($script:localizedData.NamespaceServerConfigurationParameterNeedsUpdateMessage) ` -f $parameter.Name,$parameterSource,$parameterNew ) -join '' ) diff --git a/DSCResources/MSFT_DFSNamespaceServerConfiguration/MSFT_DFSNamespaceServerConfiguration.schema.mof b/source/DSCResources/DSC_DFSNamespaceServerConfiguration/DSC_DFSNamespaceServerConfiguration.schema.mof similarity index 92% rename from DSCResources/MSFT_DFSNamespaceServerConfiguration/MSFT_DFSNamespaceServerConfiguration.schema.mof rename to source/DSCResources/DSC_DFSNamespaceServerConfiguration/DSC_DFSNamespaceServerConfiguration.schema.mof index bcb6e88..4d5eb73 100644 --- a/DSCResources/MSFT_DFSNamespaceServerConfiguration/MSFT_DFSNamespaceServerConfiguration.schema.mof +++ b/source/DSCResources/DSC_DFSNamespaceServerConfiguration/DSC_DFSNamespaceServerConfiguration.schema.mof @@ -1,5 +1,5 @@ [ClassVersion("1.0.0.0"), FriendlyName("DFSNamespaceServerConfiguration")] -class MSFT_DFSNamespaceServerConfiguration : OMI_BaseResource +class DSC_DFSNamespaceServerConfiguration : OMI_BaseResource { [Key, Description("Specifies the resource is a single instance, the value must be 'Yes'."), ValueMap{"Yes"}, Values{"Yes"}] String IsSingleInstance; [Write, Description("Specifies a time-out value, in seconds, for Lightweight Directory Access Protocol (LDAP) requests for the DFS namespace server.")] Uint32 LdapTimeoutSec; diff --git a/DSCResources/MSFT_DFSNamespaceServerConfiguration/README.md b/source/DSCResources/DSC_DFSNamespaceServerConfiguration/README.md similarity index 100% rename from DSCResources/MSFT_DFSNamespaceServerConfiguration/README.md rename to source/DSCResources/DSC_DFSNamespaceServerConfiguration/README.md diff --git a/DSCResources/MSFT_DFSNamespaceServerConfiguration/en-us/MSFT_DFSNamespaceServerConfiguration.strings.psd1 b/source/DSCResources/DSC_DFSNamespaceServerConfiguration/en-US/DSC_DFSNamespaceServerConfiguration.strings.psd1 similarity index 100% rename from DSCResources/MSFT_DFSNamespaceServerConfiguration/en-us/MSFT_DFSNamespaceServerConfiguration.strings.psd1 rename to source/DSCResources/DSC_DFSNamespaceServerConfiguration/en-US/DSC_DFSNamespaceServerConfiguration.strings.psd1 diff --git a/DSCResources/MSFT_DFSReplicationGroup/MSFT_DFSReplicationGroup.psm1 b/source/DSCResources/DSC_DFSReplicationGroup/DSC_DFSReplicationGroup.psm1 similarity index 90% rename from DSCResources/MSFT_DFSReplicationGroup/MSFT_DFSReplicationGroup.psm1 rename to source/DSCResources/DSC_DFSReplicationGroup/DSC_DFSReplicationGroup.psm1 index 23e91c9..df5b92e 100644 --- a/DSCResources/MSFT_DFSReplicationGroup/MSFT_DFSReplicationGroup.psm1 +++ b/source/DSCResources/DSC_DFSReplicationGroup/DSC_DFSReplicationGroup.psm1 @@ -1,14 +1,12 @@ $modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules' -# Import the Certificate Resource Helper Module +# Import the DFSDsc.Common Module Import-Module -Name (Join-Path -Path $modulePath ` - -ChildPath (Join-Path -Path 'DFSDsc.ResourceHelper' ` - -ChildPath 'DFSDsc.ResourceHelper.psm1')) + -ChildPath (Join-Path -Path 'DFSDsc.Common' ` + -ChildPath 'DFSDsc.Common.psm1')) # Import Localization Strings -$localizedData = Get-LocalizedData ` - -ResourceName 'MSFT_DFSReplicationGroup' ` - -ResourcePath (Split-Path -Parent $Script:MyInvocation.MyCommand.Path) +$script:localizedData = Get-LocalizedData -ResourceName 'DSC_DFSReplicationGroup' <# .SYNOPSIS @@ -44,7 +42,7 @@ function Get-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.GettingReplicationGroupMessage) ` + $($script:localizedData.GettingReplicationGroupMessage) ` -f $GroupName ) -join '' ) @@ -69,7 +67,7 @@ function Get-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupExistsMessage) ` + $($script:localizedData.ReplicationGroupExistsMessage) ` -f $GroupName ) -join '' ) @@ -93,7 +91,7 @@ function Get-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupDoesNotExistMessage) ` + $($script:localizedData.ReplicationGroupDoesNotExistMessage) ` -f $GroupName ) -join '' ) @@ -184,7 +182,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.SettingRegGroupMessage) ` + $($script:localizedData.SettingRegGroupMessage) ` -f $GroupName ) -join '' ) @@ -208,7 +206,7 @@ function Set-TargetResource # The rep group should exist Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.EnsureReplicationGroupExistsMessage) ` + $($script:localizedData.EnsureReplicationGroupExistsMessage) ` -f $GroupName ) -join '' ) @@ -224,7 +222,7 @@ function Set-TargetResource # The RG exists already - Check the existing RG and members Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupExistsMessage) ` + $($script:localizedData.ReplicationGroupExistsMessage) ` -f $GroupName ) -join '' ) @@ -235,7 +233,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupDescriptionUpdatedMessage) ` + $($script:localizedData.ReplicationGroupDescriptionUpdatedMessage) ` -f $GroupName ) -join '' ) } # if @@ -245,7 +243,7 @@ function Set-TargetResource # Ths Rep Groups doesn't exist - Create it Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupDoesNotExistMessage) ` + $($script:localizedData.ReplicationGroupDoesNotExistMessage) ` -f $GroupName ) -join '' ) @@ -253,7 +251,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupCreatedMessage) ` + $($script:localizedData.ReplicationGroupCreatedMessage) ` -f $GroupName ) -join '' ) } # else @@ -291,7 +289,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupMemberAddedMessage) ` + $($script:localizedData.ReplicationGroupMemberAddedMessage) ` -f $GroupName,$member ) -join '' ) } # if @@ -310,7 +308,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupMemberRemovedMessage) ` + $($script:localizedData.ReplicationGroupMemberRemovedMessage) ` -f $GroupName,$existingMember ) -join '' ) } # if @@ -331,7 +329,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupFolderAddedMessage) ` + $($script:localizedData.ReplicationGroupFolderAddedMessage) ` -f $GroupName,$folder ) -join '' ) } # if @@ -350,7 +348,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupFolderRemovedMessage) ` + $($script:localizedData.ReplicationGroupFolderRemovedMessage) ` -f $GroupName,$existingFolder ) -join '' ) } # if @@ -394,7 +392,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupContentPathUpdatedMessage) ` + $($script:localizedData.ReplicationGroupContentPathUpdatedMessage) ` -f $GroupName,$membership.ComputerName ) -join '' ) } # foreach @@ -438,7 +436,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupFullMeshConnectionUpdatedMessage) ` + $($script:localizedData.ReplicationGroupFullMeshConnectionUpdatedMessage) ` -f $GroupName,$source,$destination ) -join '' ) } # if @@ -450,7 +448,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupFullMeshConnectionAddedMessage) ` + $($script:localizedData.ReplicationGroupFullMeshConnectionAddedMessage) ` -f $GroupName,$source,$destination ) -join '' ) } # if @@ -464,7 +462,7 @@ function Set-TargetResource # The Rep Group should not exist Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.EnsureReplicationGroupDoesNotExistMessage) ` + $($script:localizedData.EnsureReplicationGroupDoesNotExistMessage) ` -f $GroupName ) -join '' ) @@ -478,7 +476,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupExistsRemovedMessage) ` + $($script:localizedData.ReplicationGroupExistsRemovedMessage) ` -f $GroupName ) -join '' ) } # if @@ -568,7 +566,7 @@ function Test-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.TestingRegGroupMessage) ` + $($script:localizedData.TestingRegGroupMessage) ` -f $GroupName ) -join '' ) @@ -595,7 +593,7 @@ function Test-TargetResource # The RG exists already Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupExistsMessage) ` + $($script:localizedData.ReplicationGroupExistsMessage) ` -f $GroupName ) -join '' ) @@ -604,7 +602,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupDescriptionNeedsUpdateMessage) ` + $($script:localizedData.ReplicationGroupDescriptionNeedsUpdateMessage) ` -f $GroupName ) -join '' ) @@ -640,7 +638,7 @@ function Test-TargetResource # There is a member difference of some kind. Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupMembersNeedUpdateMessage) ` + $($script:localizedData.ReplicationGroupMembersNeedUpdateMessage) ` -f $GroupName ) -join '' ) @@ -656,7 +654,7 @@ function Test-TargetResource # There is a member difference of some kind. Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupMembersNeedUpdateMessage) ` + $($script:localizedData.ReplicationGroupMembersNeedUpdateMessage) ` -f $GroupName ) -join '' ) @@ -680,7 +678,7 @@ function Test-TargetResource # There is a folder difference of some kind. Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupFoldersNeedUpdateMessage) ` + $($script:localizedData.ReplicationGroupFoldersNeedUpdateMessage) ` -f $GroupName ) -join '' ) @@ -696,7 +694,7 @@ function Test-TargetResource # There is a folder difference of some kind. Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupFoldersNeedUpdateMessage) ` + $($script:localizedData.ReplicationGroupFoldersNeedUpdateMessage) ` -f $GroupName ) -join '' ) @@ -731,7 +729,7 @@ function Test-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupContentPathNeedUpdateMessage) ` + $($script:localizedData.ReplicationGroupContentPathNeedUpdateMessage) ` -f $GroupName,$membership.ComputerName ) -join '' ) @@ -773,7 +771,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupFullMeshDisabledConnectionMessage) ` + $($script:localizedData.ReplicationGroupFullMeshDisabledConnectionMessage) ` -f $GroupName,$source,$destination ) -join '' ) @@ -784,7 +782,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupFullMeshMissingConnectionMessage) ` + $($script:localizedData.ReplicationGroupFullMeshMissingConnectionMessage) ` -f $GroupName,$source,$destination ) -join '' ) @@ -800,7 +798,7 @@ function Test-TargetResource # Ths RG doesn't exist but should Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupDoesNotExistButShouldMessage) ` + $($script:localizedData.ReplicationGroupDoesNotExistButShouldMessage) ` -f $GroupName ) -join '' ) @@ -815,7 +813,7 @@ function Test-TargetResource # The RG exists but should not Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupExistsButShouldNotMessage) ` + $($script:localizedData.ReplicationGroupExistsButShouldNotMessage) ` -f $GroupName ) -join '' ) @@ -826,7 +824,7 @@ function Test-TargetResource # The RG does not exist and should not Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupDoesNotExistAndShouldNotMessage) ` + $($script:localizedData.ReplicationGroupDoesNotExistAndShouldNotMessage) ` -f $GroupName ) -join '' ) } # else @@ -889,7 +887,7 @@ function Get-FQDNMemberName else { New-InvalidOperationException ` - -Message ($($LocalizedData.ReplicationGroupDomainMismatchError ` + -Message ($($script:localizedData.ReplicationGroupDomainMismatchError ` -f $GroupName,$ComputerName,$DomainName)) } # if } diff --git a/DSCResources/MSFT_DFSReplicationGroup/MSFT_DFSReplicationGroup.schema.mof b/source/DSCResources/DSC_DFSReplicationGroup/DSC_DFSReplicationGroup.schema.mof similarity index 96% rename from DSCResources/MSFT_DFSReplicationGroup/MSFT_DFSReplicationGroup.schema.mof rename to source/DSCResources/DSC_DFSReplicationGroup/DSC_DFSReplicationGroup.schema.mof index 5d8ab63..36a3312 100644 --- a/DSCResources/MSFT_DFSReplicationGroup/MSFT_DFSReplicationGroup.schema.mof +++ b/source/DSCResources/DSC_DFSReplicationGroup/DSC_DFSReplicationGroup.schema.mof @@ -1,5 +1,5 @@ [ClassVersion("1.0.0.0"), FriendlyName("DFSReplicationGroup")] -class MSFT_DFSReplicationGroup : OMI_BaseResource +class DSC_DFSReplicationGroup : OMI_BaseResource { [Key, Description("The name of the DFS Replication Group.")] String GroupName; [Required, Description("Specifies whether the DSF Replication Group should exist."), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure; diff --git a/DSCResources/MSFT_DFSReplicationGroup/README.md b/source/DSCResources/DSC_DFSReplicationGroup/README.md similarity index 100% rename from DSCResources/MSFT_DFSReplicationGroup/README.md rename to source/DSCResources/DSC_DFSReplicationGroup/README.md diff --git a/DSCResources/MSFT_DFSReplicationGroup/en-us/MSFT_DFSReplicationGroup.strings.psd1 b/source/DSCResources/DSC_DFSReplicationGroup/en-US/DSC_DFSReplicationGroup.strings.psd1 similarity index 100% rename from DSCResources/MSFT_DFSReplicationGroup/en-us/MSFT_DFSReplicationGroup.strings.psd1 rename to source/DSCResources/DSC_DFSReplicationGroup/en-US/DSC_DFSReplicationGroup.strings.psd1 diff --git a/DSCResources/MSFT_DFSReplicationGroupConnection/MSFT_DFSReplicationGroupConnection.psm1 b/source/DSCResources/DSC_DFSReplicationGroupConnection/DSC_DFSReplicationGroupConnection.psm1 similarity index 88% rename from DSCResources/MSFT_DFSReplicationGroupConnection/MSFT_DFSReplicationGroupConnection.psm1 rename to source/DSCResources/DSC_DFSReplicationGroupConnection/DSC_DFSReplicationGroupConnection.psm1 index 93346d8..3d5cb57 100644 --- a/DSCResources/MSFT_DFSReplicationGroupConnection/MSFT_DFSReplicationGroupConnection.psm1 +++ b/source/DSCResources/DSC_DFSReplicationGroupConnection/DSC_DFSReplicationGroupConnection.psm1 @@ -1,14 +1,12 @@ $modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules' -# Import the Certificate Resource Helper Module +# Import the DFSDsc.Common Module Import-Module -Name (Join-Path -Path $modulePath ` - -ChildPath (Join-Path -Path 'DFSDsc.ResourceHelper' ` - -ChildPath 'DFSDsc.ResourceHelper.psm1')) + -ChildPath (Join-Path -Path 'DFSDsc.Common' ` + -ChildPath 'DFSDsc.Common.psm1')) # Import Localization Strings -$localizedData = Get-LocalizedData ` - -ResourceName 'MSFT_DFSReplicationGroupConnection' ` - -ResourcePath (Split-Path -Parent $Script:MyInvocation.MyCommand.Path) +$script:localizedData = Get-LocalizedData -ResourceName 'DSC_DFSReplicationGroupConnection' <# .SYNOPSIS @@ -64,7 +62,7 @@ function Get-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.GettingReplicationGroupConnectionMessage) ` + $($script:localizedData.GettingReplicationGroupConnectionMessage) ` -f $GroupName,$SourceComputerName,$DestinationComputerName ) -join '' ) @@ -91,7 +89,7 @@ function Get-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupConnectionExistsMessage) ` + $($script:localizedData.ReplicationGroupConnectionExistsMessage) ` -f $GroupName,$SourceComputerName,$DestinationComputerName ) -join '' ) @@ -128,7 +126,7 @@ function Get-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupConnectionDoesNotExistMessage) ` + $($script:localizedData.ReplicationGroupConnectionDoesNotExistMessage) ` -f $GroupName,$SourceComputerName,$DestinationComputerName ) -join '' ) @@ -216,7 +214,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.SettingReplicationGroupConnectionMessage) ` + $($script:localizedData.SettingReplicationGroupConnectionMessage) ` -f $GroupName,$SourceComputerName,$DestinationComputerName ) -join '' ) @@ -246,7 +244,7 @@ function Set-TargetResource # The rep group connection should exist Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.EnsureReplicationGroupConnectionExistsMessage) ` + $($script:localizedData.EnsureReplicationGroupConnectionExistsMessage) ` -f $GroupName,$SourceComputerName,$DestinationComputerName ) -join '' ) @@ -258,7 +256,7 @@ function Set-TargetResource # The RG connection exists already - update it Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupConnectionExistsMessage) ` + $($script:localizedData.ReplicationGroupConnectionExistsMessage) ` -f $GroupName,$SourceComputerName,$DestinationComputerName ) -join '' ) @@ -267,7 +265,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupConnectionUpdatedMessage) ` + $($script:localizedData.ReplicationGroupConnectionUpdatedMessage) ` -f $GroupName,$SourceComputerName,$DestinationComputerName ) -join '' ) } @@ -276,7 +274,7 @@ function Set-TargetResource # Ths Rep Groups doesn't exist - Create it Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupConnectionDoesNotExistMessage) ` + $($script:localizedData.ReplicationGroupConnectionDoesNotExistMessage) ` -f $GroupName,$SourceComputerName,$DestinationComputerName ) -join '' ) @@ -285,7 +283,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupConnectionCreatedMessage) ` + $($script:localizedData.ReplicationGroupConnectionCreatedMessage) ` -f $GroupName,$SourceComputerName,$DestinationComputerName ) -join '' ) } # if @@ -295,7 +293,7 @@ function Set-TargetResource # The Rep Group should not exist Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.EnsureReplicationGroupConnectionDoesNotExistMessage) ` + $($script:localizedData.EnsureReplicationGroupConnectionDoesNotExistMessage) ` -f $GroupName,$SourceComputerName,$DestinationComputerName ) -join '' ) @@ -306,7 +304,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupConnectionExistsRemovedMessage) ` + $($script:localizedData.ReplicationGroupConnectionExistsRemovedMessage) ` -f $GroupName,$SourceComputerName,$DestinationComputerName ) -join '' ) } @@ -393,7 +391,7 @@ function Test-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.TestingReplicationGroupConnectionMessage) ` + $($script:localizedData.TestingReplicationGroupConnectionMessage) ` -f $GroupName,$SourceComputerName,$DestinationComputerName ) -join '' ) @@ -425,7 +423,7 @@ function Test-TargetResource # The RG exists already Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupConnectionExistsMessage) ` + $($script:localizedData.ReplicationGroupConnectionExistsMessage) ` -f $GroupName,$SourceComputerName,$DestinationComputerName ) -join '' ) @@ -435,7 +433,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupConnectionNeedsUpdateMessage) ` + $($script:localizedData.ReplicationGroupConnectionNeedsUpdateMessage) ` -f $GroupName,$SourceComputerName,$DestinationComputerName,'Description' ) -join '' ) @@ -449,7 +447,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupConnectionNeedsUpdateMessage) ` + $($script:localizedData.ReplicationGroupConnectionNeedsUpdateMessage) ` -f $GroupName,$SourceComputerName,$DestinationComputerName,'Enabled' ) -join '' ) @@ -463,7 +461,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupConnectionNeedsUpdateMessage) ` + $($script:localizedData.ReplicationGroupConnectionNeedsUpdateMessage) ` -f $GroupName,$SourceComputerName,$DestinationComputerName,'RDC Enabled' ) -join '' ) @@ -475,7 +473,7 @@ function Test-TargetResource # Ths RG doesn't exist but should Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupConnectionDoesNotExistButShouldMessage) ` + $($script:localizedData.ReplicationGroupConnectionDoesNotExistButShouldMessage) ` -f $GroupName,$SourceComputerName,$DestinationComputerName ) -join '' ) @@ -490,7 +488,7 @@ function Test-TargetResource # The RG exists but should not Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupConnectionExistsButShouldNotMessage) ` + $($script:localizedData.ReplicationGroupConnectionExistsButShouldNotMessage) ` -f $GroupName,$SourceComputerName,$DestinationComputerName ) -join '' ) @@ -501,7 +499,7 @@ function Test-TargetResource # The RG does not exist and should not Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupConnectionDoesNotExistAndShouldNotMessage) ` + $($script:localizedData.ReplicationGroupConnectionDoesNotExistAndShouldNotMessage) ` -f $GroupName,$SourceComputerName,$DestinationComputerName ) -join '' ) } # if diff --git a/DSCResources/MSFT_DFSReplicationGroupConnection/MSFT_DFSReplicationGroupConnection.schema.mof b/source/DSCResources/DSC_DFSReplicationGroupConnection/DSC_DFSReplicationGroupConnection.schema.mof similarity index 96% rename from DSCResources/MSFT_DFSReplicationGroupConnection/MSFT_DFSReplicationGroupConnection.schema.mof rename to source/DSCResources/DSC_DFSReplicationGroupConnection/DSC_DFSReplicationGroupConnection.schema.mof index 3c4e361..d9b5783 100644 --- a/DSCResources/MSFT_DFSReplicationGroupConnection/MSFT_DFSReplicationGroupConnection.schema.mof +++ b/source/DSCResources/DSC_DFSReplicationGroupConnection/DSC_DFSReplicationGroupConnection.schema.mof @@ -1,5 +1,5 @@ [ClassVersion("1.0.0.0"), FriendlyName("DFSReplicationGroupConnection")] -class MSFT_DFSReplicationGroupConnection : OMI_BaseResource +class DSC_DFSReplicationGroupConnection : OMI_BaseResource { [Key, Description("The name of the DFS Replication Group.")] String GroupName; [Key, Description("The name of the Replication Group source computer for the connection. This can be specified using either the ComputerName or FQDN name for the member. If an FQDN name is used and the DomainName parameter is set, the FQDN domain name must match.")] String SourceComputerName; diff --git a/DSCResources/MSFT_DFSReplicationGroupConnection/README.md b/source/DSCResources/DSC_DFSReplicationGroupConnection/README.md similarity index 100% rename from DSCResources/MSFT_DFSReplicationGroupConnection/README.md rename to source/DSCResources/DSC_DFSReplicationGroupConnection/README.md diff --git a/DSCResources/MSFT_DFSReplicationGroupConnection/en-us/MSFT_DFSReplicationGroupConnection.strings.psd1 b/source/DSCResources/DSC_DFSReplicationGroupConnection/en-US/DSC_DFSReplicationGroupConnection.strings.psd1 similarity index 100% rename from DSCResources/MSFT_DFSReplicationGroupConnection/en-us/MSFT_DFSReplicationGroupConnection.strings.psd1 rename to source/DSCResources/DSC_DFSReplicationGroupConnection/en-US/DSC_DFSReplicationGroupConnection.strings.psd1 diff --git a/DSCResources/MSFT_DFSReplicationGroupFolder/MSFT_DFSReplicationGroupFolder.psm1 b/source/DSCResources/DSC_DFSReplicationGroupFolder/DSC_DFSReplicationGroupFolder.psm1 similarity index 87% rename from DSCResources/MSFT_DFSReplicationGroupFolder/MSFT_DFSReplicationGroupFolder.psm1 rename to source/DSCResources/DSC_DFSReplicationGroupFolder/DSC_DFSReplicationGroupFolder.psm1 index c50eff9..9da1984 100644 --- a/DSCResources/MSFT_DFSReplicationGroupFolder/MSFT_DFSReplicationGroupFolder.psm1 +++ b/source/DSCResources/DSC_DFSReplicationGroupFolder/DSC_DFSReplicationGroupFolder.psm1 @@ -1,14 +1,12 @@ $modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules' -# Import the Certificate Resource Helper Module +# Import the DFSDsc.Common Module Import-Module -Name (Join-Path -Path $modulePath ` - -ChildPath (Join-Path -Path 'DFSDsc.ResourceHelper' ` - -ChildPath 'DFSDsc.ResourceHelper.psm1')) + -ChildPath (Join-Path -Path 'DFSDsc.Common' ` + -ChildPath 'DFSDsc.Common.psm1')) # Import Localization Strings -$localizedData = Get-LocalizedData ` - -ResourceName 'MSFT_DFSReplicationGroupFolder' ` - -ResourcePath (Split-Path -Parent $Script:MyInvocation.MyCommand.Path) +$script:localizedData = Get-LocalizedData -ResourceName 'DSC_DFSReplicationGroupFolder' <# .SYNOPSIS @@ -43,7 +41,7 @@ function Get-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.GettingReplicationGroupFolderMessage) ` + $($script:localizedData.GettingReplicationGroupFolderMessage) ` -f $GroupName,$FolderName ) -join '' ) @@ -69,7 +67,7 @@ function Get-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupFolderExistsMessage) ` + $($script:localizedData.ReplicationGroupFolderExistsMessage) ` -f $GroupName,$FolderName ) -join '' ) @@ -91,7 +89,7 @@ function Get-TargetResource { # The Rep Group folder doesn't exist New-InvalidOperationException ` - -Message ($($LocalizedData.ReplicationGroupFolderMissingError) ` + -Message ($($script:localizedData.ReplicationGroupFolderMissingError) ` -f $GroupName,$FolderName) } @@ -160,7 +158,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.SettingReplicationGroupFolderMessage) ` + $($script:localizedData.SettingReplicationGroupFolderMessage) ` -f $GroupName,$FolderName ) -join '' ) @@ -170,7 +168,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupFolderUpdatedMessage) ` + $($script:localizedData.ReplicationGroupFolderUpdatedMessage) ` -f $GroupName,$FolderName ) -join '' ) } # Set-TargetResource @@ -241,7 +239,7 @@ function Test-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.TestingReplicationGroupFolderMessage) ` + $($script:localizedData.TestingReplicationGroupFolderMessage) ` -f $GroupName,$FolderName ) -join '' ) @@ -266,7 +264,7 @@ function Test-TargetResource # The rep group folder is found Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupFolderExistsMessage) ` + $($script:localizedData.ReplicationGroupFolderExistsMessage) ` -f $GroupName,$FolderName ) -join '' ) @@ -276,7 +274,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupFolderDescriptionMismatchMessage) ` + $($script:localizedData.ReplicationGroupFolderDescriptionMismatchMessage) ` -f $GroupName,$FolderName ) -join '' ) @@ -291,7 +289,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupFolderFileNameToExcludeMismatchMessage) ` + $($script:localizedData.ReplicationGroupFolderFileNameToExcludeMismatchMessage) ` -f $GroupName,$FolderName ) -join '' ) @@ -306,7 +304,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupFolderDirectoryNameToExcludeMismatchMessage) ` + $($script:localizedData.ReplicationGroupFolderDirectoryNameToExcludeMismatchMessage) ` -f $GroupName,$FolderName ) -join '' ) @@ -318,7 +316,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupFolderDfsnPathMismatchMessage) ` + $($script:localizedData.ReplicationGroupFolderDfsnPathMismatchMessage) ` -f $GroupName,$FolderName ) -join '' ) @@ -329,7 +327,7 @@ function Test-TargetResource { # The Rep Group folder doesn't exist New-InvalidOperationException ` - -Message ($($LocalizedData.ReplicationGroupFolderMissingError) ` + -Message ($($script:localizedData.ReplicationGroupFolderMissingError) ` -f $GroupName,$FolderName) } # if diff --git a/DSCResources/MSFT_DFSReplicationGroupFolder/MSFT_DFSReplicationGroupFolder.schema.mof b/source/DSCResources/DSC_DFSReplicationGroupFolder/DSC_DFSReplicationGroupFolder.schema.mof similarity index 94% rename from DSCResources/MSFT_DFSReplicationGroupFolder/MSFT_DFSReplicationGroupFolder.schema.mof rename to source/DSCResources/DSC_DFSReplicationGroupFolder/DSC_DFSReplicationGroupFolder.schema.mof index bed99d3..33fdae8 100644 --- a/DSCResources/MSFT_DFSReplicationGroupFolder/MSFT_DFSReplicationGroupFolder.schema.mof +++ b/source/DSCResources/DSC_DFSReplicationGroupFolder/DSC_DFSReplicationGroupFolder.schema.mof @@ -1,5 +1,5 @@ [ClassVersion("1.0.0.0"), FriendlyName("DFSReplicationGroupFolder")] -class MSFT_DFSReplicationGroupFolder : OMI_BaseResource +class DSC_DFSReplicationGroupFolder : OMI_BaseResource { [Key, Description("The name of the DFS Replication Group.")] String GroupName; [Key, Description("The name of the DFS Replication Group Folder.")] String FolderName; diff --git a/DSCResources/MSFT_DFSReplicationGroupFolder/README.md b/source/DSCResources/DSC_DFSReplicationGroupFolder/README.md similarity index 100% rename from DSCResources/MSFT_DFSReplicationGroupFolder/README.md rename to source/DSCResources/DSC_DFSReplicationGroupFolder/README.md diff --git a/DSCResources/MSFT_DFSReplicationGroupFolder/en-us/MSFT_DFSReplicationGroupFolder.strings.psd1 b/source/DSCResources/DSC_DFSReplicationGroupFolder/en-US/DSC_DFSReplicationGroupFolder.strings.psd1 similarity index 100% rename from DSCResources/MSFT_DFSReplicationGroupFolder/en-us/MSFT_DFSReplicationGroupFolder.strings.psd1 rename to source/DSCResources/DSC_DFSReplicationGroupFolder/en-US/DSC_DFSReplicationGroupFolder.strings.psd1 diff --git a/DSCResources/MSFT_DFSReplicationGroupMembership/MSFT_DFSReplicationGroupMembership.psm1 b/source/DSCResources/DSC_DFSReplicationGroupMembership/DSC_DFSReplicationGroupMembership.psm1 similarity index 88% rename from DSCResources/MSFT_DFSReplicationGroupMembership/MSFT_DFSReplicationGroupMembership.psm1 rename to source/DSCResources/DSC_DFSReplicationGroupMembership/DSC_DFSReplicationGroupMembership.psm1 index 0926211..352b1c8 100644 --- a/DSCResources/MSFT_DFSReplicationGroupMembership/MSFT_DFSReplicationGroupMembership.psm1 +++ b/source/DSCResources/DSC_DFSReplicationGroupMembership/DSC_DFSReplicationGroupMembership.psm1 @@ -1,14 +1,12 @@ $modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules' -# Import the Certificate Resource Helper Module +# Import the DFSDsc.Common Module Import-Module -Name (Join-Path -Path $modulePath ` - -ChildPath (Join-Path -Path 'DFSDsc.ResourceHelper' ` - -ChildPath 'DFSDsc.ResourceHelper.psm1')) + -ChildPath (Join-Path -Path 'DFSDsc.Common' ` + -ChildPath 'DFSDsc.Common.psm1')) # Import Localization Strings -$localizedData = Get-LocalizedData ` - -ResourceName 'MSFT_DFSReplicationGroupMembership' ` - -ResourcePath (Split-Path -Parent $Script:MyInvocation.MyCommand.Path) +$script:localizedData = Get-LocalizedData -ResourceName 'DSC_DFSReplicationGroupMembership' <# .SYNOPSIS @@ -54,7 +52,7 @@ function Get-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.GettingReplicationGroupMembershipMessage) ` + $($script:localizedData.GettingReplicationGroupMembershipMessage) ` -f $GroupName,$FolderName,$ComputerName ) -join '' ) @@ -85,7 +83,7 @@ function Get-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupMembershipExistsMessage) ` + $($script:localizedData.ReplicationGroupMembershipExistsMessage) ` -f $GroupName,$FolderName,$ComputerName ) -join '' ) @@ -105,7 +103,7 @@ function Get-TargetResource { # The Rep Group membership doesn't exist New-InvalidOperationException ` - -Message ($($LocalizedData.ReplicationGroupMembershipMissingError) ` + -Message ($($script:localizedData.ReplicationGroupMembershipMissingError) ` -f $GroupName,$FolderName,$ComputerName) } @@ -192,7 +190,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.SettingRegGroupMembershipMessage) ` + $($script:localizedData.SettingRegGroupMembershipMessage) ` -f $GroupName,$FolderName,$ComputerName ) -join '' ) @@ -202,7 +200,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupMembershipUpdatedMessage) ` + $($script:localizedData.ReplicationGroupMembershipUpdatedMessage) ` -f $GroupName,$FolderName,$ComputerName ) -join '' ) } # Set-TargetResource @@ -291,7 +289,7 @@ function Test-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.TestingRegGroupMembershipMessage) ` + $($script:localizedData.TestingRegGroupMembershipMessage) ` -f $GroupName,$FolderName,$ComputerName ) -join '' ) @@ -317,7 +315,7 @@ function Test-TargetResource # The rep group folder is found Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupMembershipExistsMessage) ` + $($script:localizedData.ReplicationGroupMembershipExistsMessage) ` -f $GroupName,$FolderName,$ComputerName ) -join '' ) @@ -327,7 +325,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupMembershipContentPathMismatchMessage) ` + $($script:localizedData.ReplicationGroupMembershipContentPathMismatchMessage) ` -f $GroupName,$FolderName,$ComputerName ) -join '' ) @@ -340,7 +338,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupMembershipStagingPathMismatchMessage) ` + $($script:localizedData.ReplicationGroupMembershipStagingPathMismatchMessage) ` -f $GroupName,$FolderName,$ComputerName ) -join '' ) @@ -353,7 +351,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupMembershipStagingPathQuotaMismatchMessage) ` + $($script:localizedData.ReplicationGroupMembershipStagingPathQuotaMismatchMessage) ` -f $GroupName,$FolderName,$ComputerName ) -join '' ) @@ -366,7 +364,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupMembershipReadOnlyMismatchMessage) ` + $($script:localizedData.ReplicationGroupMembershipReadOnlyMismatchMessage) ` -f $GroupName,$FolderName,$ComputerName ) -join '' ) @@ -379,7 +377,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ReplicationGroupMembershipPrimaryMemberMismatchMessage) ` + $($script:localizedData.ReplicationGroupMembershipPrimaryMemberMismatchMessage) ` -f $GroupName,$FolderName,$ComputerName ) -join '' ) @@ -390,7 +388,7 @@ function Test-TargetResource { # The Rep Group membership doesn't exist New-InvalidOperationException ` - -Message ($($LocalizedData.ReplicationGroupMembershipMissingError) ` + -Message ($($script:localizedData.ReplicationGroupMembershipMissingError) ` -f $GroupName,$FolderName,$ComputerName) } # if diff --git a/DSCResources/MSFT_DFSReplicationGroupMembership/MSFT_DFSReplicationGroupMembership.schema.mof b/source/DSCResources/DSC_DFSReplicationGroupMembership/DSC_DFSReplicationGroupMembership.schema.mof similarity index 95% rename from DSCResources/MSFT_DFSReplicationGroupMembership/MSFT_DFSReplicationGroupMembership.schema.mof rename to source/DSCResources/DSC_DFSReplicationGroupMembership/DSC_DFSReplicationGroupMembership.schema.mof index af76bf0..d3d4e31 100644 --- a/DSCResources/MSFT_DFSReplicationGroupMembership/MSFT_DFSReplicationGroupMembership.schema.mof +++ b/source/DSCResources/DSC_DFSReplicationGroupMembership/DSC_DFSReplicationGroupMembership.schema.mof @@ -1,5 +1,5 @@ [ClassVersion("1.0.0.0"), FriendlyName("DFSReplicationGroupMembership")] -class MSFT_DFSReplicationGroupMembership : OMI_BaseResource +class DSC_DFSReplicationGroupMembership : OMI_BaseResource { [Key, Description("The name of the DFS Replication Group.")] String GroupName; [Key, Description("The name of the DFS Replication Group Folder.")] String FolderName; diff --git a/DSCResources/MSFT_DFSReplicationGroupMembership/README.md b/source/DSCResources/DSC_DFSReplicationGroupMembership/README.md similarity index 100% rename from DSCResources/MSFT_DFSReplicationGroupMembership/README.md rename to source/DSCResources/DSC_DFSReplicationGroupMembership/README.md diff --git a/DSCResources/MSFT_DFSReplicationGroupMembership/en-us/MSFT_DFSReplicationGroupMembership.strings.psd1 b/source/DSCResources/DSC_DFSReplicationGroupMembership/en-US/DSC_DFSReplicationGroupMembership.strings.psd1 similarity index 100% rename from DSCResources/MSFT_DFSReplicationGroupMembership/en-us/MSFT_DFSReplicationGroupMembership.strings.psd1 rename to source/DSCResources/DSC_DFSReplicationGroupMembership/en-US/DSC_DFSReplicationGroupMembership.strings.psd1 diff --git a/Examples/Resources/DFSNamespaceFolder/1-DFSNamespaceFolder_Domain_MultipleTarget_Config.ps1 b/source/Examples/Resources/DFSNamespaceFolder/1-DFSNamespaceFolder_Domain_MultipleTarget_Config.ps1 similarity index 94% rename from Examples/Resources/DFSNamespaceFolder/1-DFSNamespaceFolder_Domain_MultipleTarget_Config.ps1 rename to source/Examples/Resources/DFSNamespaceFolder/1-DFSNamespaceFolder_Domain_MultipleTarget_Config.ps1 index df31c64..b91b5f5 100644 --- a/Examples/Resources/DFSNamespaceFolder/1-DFSNamespaceFolder_Domain_MultipleTarget_Config.ps1 +++ b/source/Examples/Resources/DFSNamespaceFolder/1-DFSNamespaceFolder_Domain_MultipleTarget_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID c99703be-abb1-424a-a856-b69af295ccfe -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/DfsDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/DfsDsc +.LICENSEURI https://github.com/dsccommunity/DfsDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/DfsDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/DFSNamespaceFolder/2-DFSNamespaceFolder_Domain_SingleTarget_Config.ps1 b/source/Examples/Resources/DFSNamespaceFolder/2-DFSNamespaceFolder_Domain_SingleTarget_Config.ps1 similarity index 91% rename from Examples/Resources/DFSNamespaceFolder/2-DFSNamespaceFolder_Domain_SingleTarget_Config.ps1 rename to source/Examples/Resources/DFSNamespaceFolder/2-DFSNamespaceFolder_Domain_SingleTarget_Config.ps1 index 812e8e7..acf380b 100644 --- a/Examples/Resources/DFSNamespaceFolder/2-DFSNamespaceFolder_Domain_SingleTarget_Config.ps1 +++ b/source/Examples/Resources/DFSNamespaceFolder/2-DFSNamespaceFolder_Domain_SingleTarget_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 9f8adea6-6aed-42e8-a87a-10ba1d93e732 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/DfsDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/DfsDsc +.LICENSEURI https://github.com/dsccommunity/DfsDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/DfsDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/DFSNamespaceFolder/3-DFSNamespaceFolder_Standalone_FQDN_Config.ps1 b/source/Examples/Resources/DFSNamespaceFolder/3-DFSNamespaceFolder_Standalone_FQDN_Config.ps1 similarity index 91% rename from Examples/Resources/DFSNamespaceFolder/3-DFSNamespaceFolder_Standalone_FQDN_Config.ps1 rename to source/Examples/Resources/DFSNamespaceFolder/3-DFSNamespaceFolder_Standalone_FQDN_Config.ps1 index a96c46e..973c637 100644 --- a/Examples/Resources/DFSNamespaceFolder/3-DFSNamespaceFolder_Standalone_FQDN_Config.ps1 +++ b/source/Examples/Resources/DFSNamespaceFolder/3-DFSNamespaceFolder_Standalone_FQDN_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 3a26d1aa-17d0-40e7-8900-e9bf21662b46 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/DfsDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/DfsDsc +.LICENSEURI https://github.com/dsccommunity/DfsDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/DfsDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/DFSNamespaceFolder/4-DFSNamespaceFolder_Standalone_Config.ps1 b/source/Examples/Resources/DFSNamespaceFolder/4-DFSNamespaceFolder_Standalone_Config.ps1 similarity index 89% rename from Examples/Resources/DFSNamespaceFolder/4-DFSNamespaceFolder_Standalone_Config.ps1 rename to source/Examples/Resources/DFSNamespaceFolder/4-DFSNamespaceFolder_Standalone_Config.ps1 index f668360..1988cc5 100644 --- a/Examples/Resources/DFSNamespaceFolder/4-DFSNamespaceFolder_Standalone_Config.ps1 +++ b/source/Examples/Resources/DFSNamespaceFolder/4-DFSNamespaceFolder_Standalone_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 7bacca7a-9602-4af1-98d5-ba35d4af1290 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/DfsDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/DfsDsc +.LICENSEURI https://github.com/dsccommunity/DfsDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/DfsDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/DFSNamespaceRoot/1-DFSNamespaceRoot_Domain_MultipleTarget_Config.ps1 b/source/Examples/Resources/DFSNamespaceRoot/1-DFSNamespaceRoot_Domain_MultipleTarget_Config.ps1 similarity index 94% rename from Examples/Resources/DFSNamespaceRoot/1-DFSNamespaceRoot_Domain_MultipleTarget_Config.ps1 rename to source/Examples/Resources/DFSNamespaceRoot/1-DFSNamespaceRoot_Domain_MultipleTarget_Config.ps1 index 95089b0..30cdd64 100644 --- a/Examples/Resources/DFSNamespaceRoot/1-DFSNamespaceRoot_Domain_MultipleTarget_Config.ps1 +++ b/source/Examples/Resources/DFSNamespaceRoot/1-DFSNamespaceRoot_Domain_MultipleTarget_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID f79dac3a-89dd-4a46-95cf-02be7f029cd5 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/DfsDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/DfsDsc +.LICENSEURI https://github.com/dsccommunity/DfsDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/DfsDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/DFSNamespaceRoot/2-DFSNamespaceRoot_Domain_SingleTarget_Config.ps1 b/source/Examples/Resources/DFSNamespaceRoot/2-DFSNamespaceRoot_Domain_SingleTarget_Config.ps1 similarity index 91% rename from Examples/Resources/DFSNamespaceRoot/2-DFSNamespaceRoot_Domain_SingleTarget_Config.ps1 rename to source/Examples/Resources/DFSNamespaceRoot/2-DFSNamespaceRoot_Domain_SingleTarget_Config.ps1 index 0be2c8c..0dad6c2 100644 --- a/Examples/Resources/DFSNamespaceRoot/2-DFSNamespaceRoot_Domain_SingleTarget_Config.ps1 +++ b/source/Examples/Resources/DFSNamespaceRoot/2-DFSNamespaceRoot_Domain_SingleTarget_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID ef7ea9b0-f02f-4352-bddd-16f9d40c3d66 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/DfsDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/DfsDsc +.LICENSEURI https://github.com/dsccommunity/DfsDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/DfsDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/DFSNamespaceRoot/3-DFSNamespaceRoot_Standalone_FQDN_Config.ps1 b/source/Examples/Resources/DFSNamespaceRoot/3-DFSNamespaceRoot_Standalone_FQDN_Config.ps1 similarity index 91% rename from Examples/Resources/DFSNamespaceRoot/3-DFSNamespaceRoot_Standalone_FQDN_Config.ps1 rename to source/Examples/Resources/DFSNamespaceRoot/3-DFSNamespaceRoot_Standalone_FQDN_Config.ps1 index 0057735..34d0f11 100644 --- a/Examples/Resources/DFSNamespaceRoot/3-DFSNamespaceRoot_Standalone_FQDN_Config.ps1 +++ b/source/Examples/Resources/DFSNamespaceRoot/3-DFSNamespaceRoot_Standalone_FQDN_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 2f8a475b-5dc9-4f0e-b8e0-fe51d3552698 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/DfsDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/DfsDsc +.LICENSEURI https://github.com/dsccommunity/DfsDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/DfsDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/DFSNamespaceRoot/4-DFSNamespaceRoot_Standalone_Config.ps1 b/source/Examples/Resources/DFSNamespaceRoot/4-DFSNamespaceRoot_Standalone_Config.ps1 similarity index 89% rename from Examples/Resources/DFSNamespaceRoot/4-DFSNamespaceRoot_Standalone_Config.ps1 rename to source/Examples/Resources/DFSNamespaceRoot/4-DFSNamespaceRoot_Standalone_Config.ps1 index 4f7a545..dfbaf76 100644 --- a/Examples/Resources/DFSNamespaceRoot/4-DFSNamespaceRoot_Standalone_Config.ps1 +++ b/source/Examples/Resources/DFSNamespaceRoot/4-DFSNamespaceRoot_Standalone_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID daadea0f-b395-4702-bc3d-0a0613e2ef9f -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/DfsDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/DfsDsc +.LICENSEURI https://github.com/dsccommunity/DfsDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/DfsDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/DFSNamespaceServerConfiguration/1-DFSNamespaceServerConfiguration_Standalone_FQDN_Config.ps1 b/source/Examples/Resources/DFSNamespaceServerConfiguration/1-DFSNamespaceServerConfiguration_Standalone_FQDN_Config.ps1 similarity index 91% rename from Examples/Resources/DFSNamespaceServerConfiguration/1-DFSNamespaceServerConfiguration_Standalone_FQDN_Config.ps1 rename to source/Examples/Resources/DFSNamespaceServerConfiguration/1-DFSNamespaceServerConfiguration_Standalone_FQDN_Config.ps1 index 0aaa005..b946b0d 100644 --- a/Examples/Resources/DFSNamespaceServerConfiguration/1-DFSNamespaceServerConfiguration_Standalone_FQDN_Config.ps1 +++ b/source/Examples/Resources/DFSNamespaceServerConfiguration/1-DFSNamespaceServerConfiguration_Standalone_FQDN_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID ea6fb120-43ba-4a71-b77d-0e8b793c8ea3 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/DfsDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/DfsDsc +.LICENSEURI https://github.com/dsccommunity/DfsDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/DfsDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/DFSReplicationGroup/1-DFSReplicationGroup_FullMesh_Config.ps1 b/source/Examples/Resources/DFSReplicationGroup/1-DFSReplicationGroup_FullMesh_Config.ps1 similarity index 92% rename from Examples/Resources/DFSReplicationGroup/1-DFSReplicationGroup_FullMesh_Config.ps1 rename to source/Examples/Resources/DFSReplicationGroup/1-DFSReplicationGroup_FullMesh_Config.ps1 index 1395edc..f6bdc4e 100644 --- a/Examples/Resources/DFSReplicationGroup/1-DFSReplicationGroup_FullMesh_Config.ps1 +++ b/source/Examples/Resources/DFSReplicationGroup/1-DFSReplicationGroup_FullMesh_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID b8e7619e-4b6d-4b56-9f26-266de1d02ca4 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/DfsDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/DfsDsc +.LICENSEURI https://github.com/dsccommunity/DfsDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/DfsDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/DFSReplicationGroup/2-DFSReplicationGroup_Simple_Config.ps1 b/source/Examples/Resources/DFSReplicationGroup/2-DFSReplicationGroup_Simple_Config.ps1 similarity index 87% rename from Examples/Resources/DFSReplicationGroup/2-DFSReplicationGroup_Simple_Config.ps1 rename to source/Examples/Resources/DFSReplicationGroup/2-DFSReplicationGroup_Simple_Config.ps1 index 44999e0..3beff74 100644 --- a/Examples/Resources/DFSReplicationGroup/2-DFSReplicationGroup_Simple_Config.ps1 +++ b/source/Examples/Resources/DFSReplicationGroup/2-DFSReplicationGroup_Simple_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID d5b27b97-bebc-4edf-adb8-0846f9be4807 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/DfsDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/DfsDsc +.LICENSEURI https://github.com/dsccommunity/DfsDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/DfsDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/DFSReplicationGroup/3-DFSReplicationGroup_Complete_Config.ps1 b/source/Examples/Resources/DFSReplicationGroup/3-DFSReplicationGroup_Complete_Config.ps1 similarity index 93% rename from Examples/Resources/DFSReplicationGroup/3-DFSReplicationGroup_Complete_Config.ps1 rename to source/Examples/Resources/DFSReplicationGroup/3-DFSReplicationGroup_Complete_Config.ps1 index 4deea94..26dd57e 100644 --- a/Examples/Resources/DFSReplicationGroup/3-DFSReplicationGroup_Complete_Config.ps1 +++ b/source/Examples/Resources/DFSReplicationGroup/3-DFSReplicationGroup_Complete_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 30820711-2bce-4acf-a891-d3d1a3f49832 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/DfsDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/DfsDsc +.LICENSEURI https://github.com/dsccommunity/DfsDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/DfsDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/DFSReplicationGroup/4-DFSReplicationGroup_HubAndSpoke_Config.ps1 b/source/Examples/Resources/DFSReplicationGroup/4-DFSReplicationGroup_HubAndSpoke_Config.ps1 similarity index 94% rename from Examples/Resources/DFSReplicationGroup/4-DFSReplicationGroup_HubAndSpoke_Config.ps1 rename to source/Examples/Resources/DFSReplicationGroup/4-DFSReplicationGroup_HubAndSpoke_Config.ps1 index a332872..3950bdb 100644 --- a/Examples/Resources/DFSReplicationGroup/4-DFSReplicationGroup_HubAndSpoke_Config.ps1 +++ b/source/Examples/Resources/DFSReplicationGroup/4-DFSReplicationGroup_HubAndSpoke_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID cb1ced6c-35ea-4e02-aa0c-0aa1cd3c5182 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/DfsDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/DfsDsc +.LICENSEURI https://github.com/dsccommunity/DfsDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/DfsDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/DFSReplicationGroupConnection/1-DFSReplicationGroupConnection_Complete_Config.ps1 b/source/Examples/Resources/DFSReplicationGroupConnection/1-DFSReplicationGroupConnection_Complete_Config.ps1 similarity index 93% rename from Examples/Resources/DFSReplicationGroupConnection/1-DFSReplicationGroupConnection_Complete_Config.ps1 rename to source/Examples/Resources/DFSReplicationGroupConnection/1-DFSReplicationGroupConnection_Complete_Config.ps1 index efdb675..07aacb4 100644 --- a/Examples/Resources/DFSReplicationGroupConnection/1-DFSReplicationGroupConnection_Complete_Config.ps1 +++ b/source/Examples/Resources/DFSReplicationGroupConnection/1-DFSReplicationGroupConnection_Complete_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 24104af9-3ba9-4926-9d0a-644be607e3a2 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/DfsDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/DfsDsc +.LICENSEURI https://github.com/dsccommunity/DfsDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/DfsDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/DFSReplicationGroupConnection/2-DFSReplicationGroupConnection_HubAndSpoke_Config.ps1 b/source/Examples/Resources/DFSReplicationGroupConnection/2-DFSReplicationGroupConnection_HubAndSpoke_Config.ps1 similarity index 94% rename from Examples/Resources/DFSReplicationGroupConnection/2-DFSReplicationGroupConnection_HubAndSpoke_Config.ps1 rename to source/Examples/Resources/DFSReplicationGroupConnection/2-DFSReplicationGroupConnection_HubAndSpoke_Config.ps1 index d518145..9b72dc8 100644 --- a/Examples/Resources/DFSReplicationGroupConnection/2-DFSReplicationGroupConnection_HubAndSpoke_Config.ps1 +++ b/source/Examples/Resources/DFSReplicationGroupConnection/2-DFSReplicationGroupConnection_HubAndSpoke_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID abf31b13-4bb7-449b-b077-028b0caecb77 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/DfsDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/DfsDsc +.LICENSEURI https://github.com/dsccommunity/DfsDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/DfsDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/DFSReplicationGroupFolder/1-DFSReplicationGroupFolder_FullMesh_Config.ps1 b/source/Examples/Resources/DFSReplicationGroupFolder/1-DFSReplicationGroupFolder_FullMesh_Config.ps1 similarity index 92% rename from Examples/Resources/DFSReplicationGroupFolder/1-DFSReplicationGroupFolder_FullMesh_Config.ps1 rename to source/Examples/Resources/DFSReplicationGroupFolder/1-DFSReplicationGroupFolder_FullMesh_Config.ps1 index 5461012..e99ce9a 100644 --- a/Examples/Resources/DFSReplicationGroupFolder/1-DFSReplicationGroupFolder_FullMesh_Config.ps1 +++ b/source/Examples/Resources/DFSReplicationGroupFolder/1-DFSReplicationGroupFolder_FullMesh_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID c5ede1bd-b182-4b1c-be59-0db5320fca42 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/DfsDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/DfsDsc +.LICENSEURI https://github.com/dsccommunity/DfsDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/DfsDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/DFSReplicationGroupFolder/2-DFSReplicationGroupFolder_Complete_Config.ps1 b/source/Examples/Resources/DFSReplicationGroupFolder/2-DFSReplicationGroupFolder_Complete_Config.ps1 similarity index 93% rename from Examples/Resources/DFSReplicationGroupFolder/2-DFSReplicationGroupFolder_Complete_Config.ps1 rename to source/Examples/Resources/DFSReplicationGroupFolder/2-DFSReplicationGroupFolder_Complete_Config.ps1 index f452476..48c522d 100644 --- a/Examples/Resources/DFSReplicationGroupFolder/2-DFSReplicationGroupFolder_Complete_Config.ps1 +++ b/source/Examples/Resources/DFSReplicationGroupFolder/2-DFSReplicationGroupFolder_Complete_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 6fb9b69c-b611-47db-b33c-7cf4acacb409 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/DfsDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/DfsDsc +.LICENSEURI https://github.com/dsccommunity/DfsDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/DfsDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/DFSReplicationGroupFolder/3-DFSReplicationGroupFolder_HubAndSpoke_Config.ps1 b/source/Examples/Resources/DFSReplicationGroupFolder/3-DFSReplicationGroupFolder_HubAndSpoke_Config.ps1 similarity index 94% rename from Examples/Resources/DFSReplicationGroupFolder/3-DFSReplicationGroupFolder_HubAndSpoke_Config.ps1 rename to source/Examples/Resources/DFSReplicationGroupFolder/3-DFSReplicationGroupFolder_HubAndSpoke_Config.ps1 index dba4d19..26567fa 100644 --- a/Examples/Resources/DFSReplicationGroupFolder/3-DFSReplicationGroupFolder_HubAndSpoke_Config.ps1 +++ b/source/Examples/Resources/DFSReplicationGroupFolder/3-DFSReplicationGroupFolder_HubAndSpoke_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID e049f14d-28ab-49d6-979c-c7d1a16fe298 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/DfsDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/DfsDsc +.LICENSEURI https://github.com/dsccommunity/DfsDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/DfsDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/DFSReplicationGroupMembership/1-DFSReplicationGroupMembership_FullMesh_Config.ps1 b/source/Examples/Resources/DFSReplicationGroupMembership/1-DFSReplicationGroupMembership_FullMesh_Config.ps1 similarity index 92% rename from Examples/Resources/DFSReplicationGroupMembership/1-DFSReplicationGroupMembership_FullMesh_Config.ps1 rename to source/Examples/Resources/DFSReplicationGroupMembership/1-DFSReplicationGroupMembership_FullMesh_Config.ps1 index fe43047..794cfae 100644 --- a/Examples/Resources/DFSReplicationGroupMembership/1-DFSReplicationGroupMembership_FullMesh_Config.ps1 +++ b/source/Examples/Resources/DFSReplicationGroupMembership/1-DFSReplicationGroupMembership_FullMesh_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID f4a025e1-1134-4ebb-a11c-2e3ff331e175 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/DfsDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/DfsDsc +.LICENSEURI https://github.com/dsccommunity/DfsDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/DfsDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/DFSReplicationGroupMembership/2-DFSReplicationGroupMembership_Complete_Config.ps1 b/source/Examples/Resources/DFSReplicationGroupMembership/2-DFSReplicationGroupMembership_Complete_Config.ps1 similarity index 93% rename from Examples/Resources/DFSReplicationGroupMembership/2-DFSReplicationGroupMembership_Complete_Config.ps1 rename to source/Examples/Resources/DFSReplicationGroupMembership/2-DFSReplicationGroupMembership_Complete_Config.ps1 index 5995066..672cdb4 100644 --- a/Examples/Resources/DFSReplicationGroupMembership/2-DFSReplicationGroupMembership_Complete_Config.ps1 +++ b/source/Examples/Resources/DFSReplicationGroupMembership/2-DFSReplicationGroupMembership_Complete_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 61fe9c32-c109-4cef-8613-0e0a2d66758a -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/DfsDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/DfsDsc +.LICENSEURI https://github.com/dsccommunity/DfsDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/DfsDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/DFSReplicationGroupMembership/3-DFSReplicationGroupMembership_HubAndSpoke_Config.ps1 b/source/Examples/Resources/DFSReplicationGroupMembership/3-DFSReplicationGroupMembership_HubAndSpoke_Config.ps1 similarity index 94% rename from Examples/Resources/DFSReplicationGroupMembership/3-DFSReplicationGroupMembership_HubAndSpoke_Config.ps1 rename to source/Examples/Resources/DFSReplicationGroupMembership/3-DFSReplicationGroupMembership_HubAndSpoke_Config.ps1 index 343bd6b..1a393ef 100644 --- a/Examples/Resources/DFSReplicationGroupMembership/3-DFSReplicationGroupMembership_HubAndSpoke_Config.ps1 +++ b/source/Examples/Resources/DFSReplicationGroupMembership/3-DFSReplicationGroupMembership_HubAndSpoke_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 52fb2644-0ad3-47f8-9ffa-aa7179d2a44a -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/DfsDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/DfsDsc +.LICENSEURI https://github.com/dsccommunity/DfsDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/DfsDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/source/Modules/DFSDsc.Common/DFSDsc.Common.psm1 b/source/Modules/DFSDsc.Common/DFSDsc.Common.psm1 new file mode 100644 index 0000000..2a645a3 --- /dev/null +++ b/source/Modules/DFSDsc.Common/DFSDsc.Common.psm1 @@ -0,0 +1,364 @@ +<# + .SYNOPSIS + This function tests if a cmdlet exists. + + .PARAMETER Name + The name of the cmdlet to check for. + + .PARAMETER Module + The module containing the command. +#> +function Test-Command +{ + [CmdletBinding()] + [OutputType([System.Boolean])] + param + ( + [Parameter(Mandatory = $true)] + [System.String] + $Name, + + [Parameter(Mandatory = $true)] + [System.String] + $Module + ) + + return ($null -ne (Get-Command @PSBoundParameters -ErrorAction SilentlyContinue)) +} # function Test-Command + +<# + .SYNOPSIS + Tests if the current machine is a Nano server. +#> +function Test-IsNanoServer +{ + if (Test-Command -Name 'Get-ComputerInfo' -Module 'Microsoft.PowerShell.Management') + { + $computerInfo = Get-ComputerInfo + + if ('Server' -eq $computerInfo.OsProductType ` + -and 'NanoServer' -eq $computerInfo.OsServerLevel) + { + return $true + } + } + + return $false +} + +<# + .SYNOPSIS + Retrieves the localized string data based on the machine's culture. + Falls back to en-US strings if the machine's culture is not supported. + + .PARAMETER ResourceName + The name of the resource as it appears before '.strings.psd1' of the localized string file. + For example: + For WindowsOptionalFeature: MSFT_WindowsOptionalFeature + For Service: MSFT_ServiceResource + For Registry: MSFT_RegistryResource + For Helper: SqlServerDscHelper + + .PARAMETER ScriptRoot + Optional. The root path where to expect to find the culture folder. This is only needed + for localization in helper modules. This should not normally be used for resources. + + .NOTES + To be able to use localization in the helper function, this function must + be first in the file, before Get-LocalizedData is used by itself to load + localized data for this helper module (see directly after this function). +#> +function Get-LocalizedData +{ + [CmdletBinding()] + param + ( + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [System.String] + $ResourceName, + + [Parameter()] + [ValidateNotNullOrEmpty()] + [System.String] + $ScriptRoot + ) + + if (-not $ScriptRoot) + { + $dscResourcesFolder = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'DSCResources' + $resourceDirectory = Join-Path -Path $dscResourcesFolder -ChildPath $ResourceName + } + else + { + $resourceDirectory = $ScriptRoot + } + + $localizedStringFileLocation = Join-Path -Path $resourceDirectory -ChildPath $PSUICulture + + if (-not (Test-Path -Path $localizedStringFileLocation)) + { + # Fallback to en-US + $localizedStringFileLocation = Join-Path -Path $resourceDirectory -ChildPath 'en-US' + } + + Import-LocalizedData ` + -BindingVariable 'localizedData' ` + -FileName "$ResourceName.strings.psd1" ` + -BaseDirectory $localizedStringFileLocation + + return $localizedData +} + +<# + .SYNOPSIS + Creates and throws an invalid argument exception. + + .PARAMETER Message + The message explaining why this error is being thrown. + + .PARAMETER ArgumentName + The name of the invalid argument that is causing this error to be thrown. +#> +function New-InvalidArgumentException +{ + [CmdletBinding()] + param + ( + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [System.String] + $Message, + + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [System.String] + $ArgumentName + ) + + $argumentException = New-Object -TypeName 'ArgumentException' ` + -ArgumentList @($Message, $ArgumentName) + + $newObjectParameters = @{ + TypeName = 'System.Management.Automation.ErrorRecord' + ArgumentList = @($argumentException, $ArgumentName, 'InvalidArgument', $null) + } + + $errorRecord = New-Object @newObjectParameters + + throw $errorRecord +} + +<# + .SYNOPSIS + Creates and throws an invalid operation exception. + + .PARAMETER Message + The message explaining why this error is being thrown. + + .PARAMETER ErrorRecord + The error record containing the exception that is causing this terminating error. +#> +function New-InvalidOperationException +{ + [CmdletBinding()] + param + ( + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [System.String] + $Message, + + [Parameter()] + [ValidateNotNull()] + [System.Management.Automation.ErrorRecord] + $ErrorRecord + ) + + if ($null -eq $ErrorRecord) + { + $invalidOperationException = New-Object -TypeName 'InvalidOperationException' ` + -ArgumentList @($Message) + } + else + { + $invalidOperationException = New-Object -TypeName 'InvalidOperationException' ` + -ArgumentList @($Message, $ErrorRecord.Exception) + } + + $newObjectParameters = @{ + TypeName = 'System.Management.Automation.ErrorRecord' + ArgumentList = @( + $invalidOperationException.ToString(), + 'MachineStateIncorrect', + 'InvalidOperation', + $null + ) + } + + $errorRecordToThrow = New-Object @newObjectParameters + + throw $errorRecordToThrow +} + +<# + .SYNOPSIS + Creates and throws an object not found exception. + + .PARAMETER Message + The message explaining why this error is being thrown. + + .PARAMETER ErrorRecord + The error record containing the exception that is causing this terminating error. +#> +function New-ObjectNotFoundException +{ + [CmdletBinding()] + param + ( + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [System.String] + $Message, + + [Parameter()] + [ValidateNotNull()] + [System.Management.Automation.ErrorRecord] + $ErrorRecord + ) + + if ($null -eq $ErrorRecord) + { + $exception = New-Object -TypeName 'System.Exception' ` + -ArgumentList @($Message) + } + else + { + $exception = New-Object -TypeName 'System.Exception' ` + -ArgumentList @($Message, $ErrorRecord.Exception) + } + + $newObjectParameters = @{ + TypeName = 'System.Management.Automation.ErrorRecord' + ArgumentList = @( + $exception.ToString(), + 'MachineStateIncorrect', + 'ObjectNotFound', + $null + ) + } + + $errorRecordToThrow = New-Object @newObjectParameters + + throw $errorRecordToThrow +} + +<# + .SYNOPSIS + Creates and throws an invalid result exception. + + .PARAMETER Message + The message explaining why this error is being thrown. + + .PARAMETER ErrorRecord + The error record containing the exception that is causing this terminating error. +#> +function New-InvalidResultException +{ + [CmdletBinding()] + param + ( + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [System.String] + $Message, + + [Parameter()] + [ValidateNotNull()] + [System.Management.Automation.ErrorRecord] + $ErrorRecord + ) + + if ($null -eq $ErrorRecord) + { + $exception = New-Object -TypeName 'System.Exception' ` + -ArgumentList @($Message) + } + else + { + $exception = New-Object -TypeName 'System.Exception' ` + -ArgumentList @($Message, $ErrorRecord.Exception) + } + + $newObjectParameters = @{ + TypeName = 'System.Management.Automation.ErrorRecord' + ArgumentList = @( + $exception.ToString(), + 'MachineStateIncorrect', + 'InvalidResult', + $null + ) + } + + $errorRecordToThrow = New-Object @newObjectParameters + + throw $errorRecordToThrow +} + +function New-NotImplementedException +{ + [CmdletBinding()] + param + ( + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [System.String] + $Message, + + [Parameter()] + [ValidateNotNull()] + [System.Management.Automation.ErrorRecord] + $ErrorRecord + ) + + if ($null -eq $ErrorRecord) + { + $invalidOperationException = New-Object -TypeName 'NotImplementedException' ` + -ArgumentList @($Message) + } + else + { + $invalidOperationException = New-Object -TypeName 'NotImplementedException' ` + -ArgumentList @($Message, $ErrorRecord.Exception) + } + + $newObjectParameters = @{ + TypeName = 'System.Management.Automation.ErrorRecord' + ArgumentList = @( + $invalidOperationException.ToString(), + 'MachineStateIncorrect', + 'NotImplemented', + $null + ) + } + + $errorRecordToThrow = New-Object @newObjectParameters + + throw $errorRecordToThrow +} + +# Import Localization Strings +$script:localizedData = Get-LocalizedData ` + -ResourceName 'DFSDsc.Common' ` + -ScriptRoot $PSScriptRoot + +Export-ModuleMember -Function @( + 'Test-Command', + 'Test-IsNanoServer', + 'Get-LocalizedData', + 'New-InvalidArgumentException', + 'New-InvalidOperationException', + 'New-ObjectNotFoundException', + 'New-InvalidResultException', + 'New-NotImplementedException' + ) diff --git a/source/Modules/DFSDsc.Common/en-US/DFSDsc.Common.strings.psd1 b/source/Modules/DFSDsc.Common/en-US/DFSDsc.Common.strings.psd1 new file mode 100644 index 0000000..3b35d66 --- /dev/null +++ b/source/Modules/DFSDsc.Common/en-US/DFSDsc.Common.strings.psd1 @@ -0,0 +1,2 @@ +ConvertFrom-StringData @' +'@ diff --git a/source/en-US/about_DFSDsc.help.txt b/source/en-US/about_DFSDsc.help.txt new file mode 100644 index 0000000..0403c71 --- /dev/null +++ b/source/en-US/about_DFSDsc.help.txt @@ -0,0 +1,26 @@ +TOPIC + about_DFSDsc + +SHORT DESCRIPTION + DSC resources for configuring Distributed File System Replication and Namespaces. + +LONG DESCRIPTION + This module contains DSC resources for configuring Distributed File System + Replication and Namespaces. + +EXAMPLES + PS C:\> Get-DscResource -Module DFSDsc + +NOTE: + Thank you to the DSC Community contributors who contributed to this module by + writing code, sharing opinions, and provided feedback. + +TROUBLESHOOTING NOTE: + Go to the Github repository for read about issues, submit a new issue, and read + about new releases. https://github.com/dsccommunity/DFSDsc + +SEE ALSO + - https://github.com/dsccommunity/DFSDsc + +KEYWORDS + DSC, DscResource, DFS, DistributedFileSystem, Replication, Namespace diff --git a/tests/Integration/DSC_DFSNamespaceFolder.Integration.Tests.ps1 b/tests/Integration/DSC_DFSNamespaceFolder.Integration.Tests.ps1 new file mode 100644 index 0000000..cbc9cab --- /dev/null +++ b/tests/Integration/DSC_DFSNamespaceFolder.Integration.Tests.ps1 @@ -0,0 +1,202 @@ +[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "")] +param () + +$script:dscModuleName = 'DFSDsc' +$script:dscResourceName = 'DSC_DFSnamespaceFolder' + +try +{ + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' +} +catch [System.IO.FileNotFoundException] +{ + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' +} + +$script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Integration' + +Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') + +try +{ + # Ensure that the tests can be performed on this computer + $productType = (Get-CimInstance Win32_OperatingSystem).ProductType + + Describe 'Environment' { + Context 'Operating System' { + It 'Should be a Server OS' { + $productType | Should -Be 3 + } + } + } + + if ($productType -ne 3) + { + break + } + + $featureInstalled = (Get-WindowsFeature -Name FS-DFS-Namespace).Installed + + Describe 'Environment' { + Context 'Windows Features' { + It 'Should have the DFS Namespace Feature Installed' { + $featureInstalled | Should -Be $true + } + } + } + + if ($featureInstalled -eq $false) + { + break + } + + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1" + . $configFile + + Describe "$($script:dscResourceName)_Integration" { + Context 'When creating a new folder in DFS Namespace' { + BeforeAll { + $script:namespaceRootName = 'IntegrationTestNamespace' + $script:namespaceFolderName = 'TestFolder' + $script:namespaceRoot = @{ + Path = "\\$($env:COMPUTERNAME)\$script:namespaceRootName" + TargetPath = "\\$($env:COMPUTERNAME)\$script:namespaceRootName" + } + $script:namespaceFolder = @{ + Path = "$($script:namespaceRoot.Path)\$script:namespaceFolderName" + TargetPath = "\\$($env:COMPUTERNAME)\$script:namespaceFolderName" + Ensure = 'Present' + Description = 'Integration test namespace folder' + EnableInsiteReferrals = $true + EnableTargetFailback = $true + ReferralPriorityClass = 'Global-Low' + ReferralPriorityRank = 10 + } + + # Create a SMB share for the Namespace + $randomFileName = [System.IO.Path]::GetrandomFileName() + $script:shareFolderRoot = Join-Path -Path $env:Temp -ChildPath "$($script:DSCResourceName)_$randomFileName" + + New-Item ` + -Path $script:shareFolderRoot ` + -Type Directory + + New-SMBShare ` + -Name $script:namespaceRootName ` + -Path $script:shareFolderRoot ` + -FullAccess 'Everyone' + + $randomFileName = [System.IO.Path]::GetrandomFileName() + $script:shareFolderName = Join-Path -Path $env:Temp -ChildPath "$($script:DSCResourceName)_$randomFileName" + + New-Item ` + -Path $script:shareFolderName ` + -Type Directory + + New-SMBShare ` + -Name $script:namespaceFolderName ` + -Path $script:shareFolderName ` + -FullAccess 'Everyone' + + New-DFSNRoot ` + -Path $script:namespaceRoot.Path ` + -TargetPath $script:namespaceRoot.TargetPath ` + -Type Standalone + } + + It 'Should compile and apply the MOF without throwing' { + { + $configData = @{ + AllNodes = @( + @{ + NodeName = 'localhost' + Path = $script:namespaceFolder.Path + TargetPath = $script:namespaceFolder.TargetPath + Ensure = $script:namespaceFolder.Ensure + Description = $script:namespaceFolder.Description + EnableInsiteReferrals = $script:namespaceFolder.EnableInsiteReferrals + EnableTargetFailback = $script:namespaceFolder.EnableTargetFailback + ReferralPriorityClass = $script:namespaceFolder.ReferralPriorityClass + ReferralPriorityRank = $script:namespaceFolder.ReferralPriorityRank + } + ) + } + + & "$($script:DSCResourceName)_Config" ` + -OutputPath $TestDrive ` + -ConfigurationData $configData + + Start-DscConfiguration ` + -Path $TestDrive ` + -ComputerName localhost ` + -Wait ` + -Verbose ` + -Force ` + -ErrorAction Stop + } | Should -Not -Throw + } + + It 'Should be able to call Get-DscConfiguration without throwing' { + { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw + } + + It 'Should have set the resource and all the folder parameters should match' { + $namespaceFolderNew = Get-DfsnFolder -Path $script:namespaceFolder.Path + $namespaceFolderNew.Path | Should -Be $script:namespaceFolder.Path + $namespaceFolderNew.TimeToLiveSec | Should -Be 300 + $namespaceFolderNew.State | Should -Be 'Online' + $namespaceFolderNew.Description | Should -Be $script:namespaceFolder.Description + $namespaceFolderNew.NamespacePath | Should -Be $script:namespaceFolder.Path + $namespaceFolderNew.Flags | Should -Be @('Target Failback','Insite Referrals') + } + + It 'Should have set the resource and all the folder target parameters should match' { + $namespaceFolderTargetNew = Get-DfsnFolderTarget -Path $script:namespaceFolder.Path -TargetPath $script:namespaceFolder.TargetPath + $namespaceFolderTargetNew.Path | Should -Be $script:namespaceFolder.Path + $namespaceFolderTargetNew.NamespacePath | Should -Be $script:namespaceFolder.Path + $namespaceFolderTargetNew.TargetPath | Should -Be $script:namespaceFolder.TargetPath + $namespaceFolderTargetNew.ReferralPriorityClass | Should -Be $script:namespaceFolder.ReferralPriorityClass + $namespaceFolderTargetNew.ReferralPriorityRank | Should -Be $script:namespaceFolder.ReferralPriorityRank + } + + AfterAll { + # Clean up + Remove-DFSNFolder ` + -Path $script:namespaceFolder.Path ` + -Force ` + -Confirm:$false + + Remove-DFSNRoot ` + -Path $script:namespaceRoot.Path ` + -Force ` + -Confirm:$false + + Remove-SMBShare ` + -Name $script:namespaceFolderName ` + -Confirm:$false + + Remove-Item ` + -Path $script:shareFolderName ` + -Recurse ` + -Force + + Remove-SMBShare ` + -Name $script:namespaceRootName ` + -Confirm:$false + + Remove-Item ` + -Path $script:shareFolderRoot ` + -Recurse ` + -Force + } + } + } +} +finally +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} diff --git a/tests/Integration/DSC_DFSNamespaceFolder.config.ps1 b/tests/Integration/DSC_DFSNamespaceFolder.config.ps1 new file mode 100644 index 0000000..e52663f --- /dev/null +++ b/tests/Integration/DSC_DFSNamespaceFolder.config.ps1 @@ -0,0 +1,16 @@ +Configuration DSC_DFSNamespaceFolder_Config { + Import-DscResource -ModuleName DFSDsc + + Node localhost { + DFSNamespaceFolder Integration_Test { + Path = $Node.Path + TargetPath = $Node.TargetPath + Ensure = $Node.Ensure + Description = $Node.Description + EnableInsiteReferrals = $Node.EnableInsiteReferrals + EnableTargetFailback = $Node.EnableTargetFailback + ReferralPriorityClass = $Node.ReferralPriorityClass + ReferralPriorityRank = $Node.ReferralPriorityRank + } + } +} diff --git a/tests/Integration/DSC_DFSNamespaceRoot.Integration.Tests.ps1 b/tests/Integration/DSC_DFSNamespaceRoot.Integration.Tests.ps1 new file mode 100644 index 0000000..5bca1c0 --- /dev/null +++ b/tests/Integration/DSC_DFSNamespaceRoot.Integration.Tests.ps1 @@ -0,0 +1,180 @@ +[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "")] +param () + +$script:dscModuleName = 'DFSDsc' +$script:dscResourceName = 'DSC_DFSNamespaceRoot' + +try +{ + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' +} +catch [System.IO.FileNotFoundException] +{ + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' +} + +$script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Integration' + +Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') + +try +{ + # Ensure that the tests can be performed on this computer + $productType = (Get-CimInstance Win32_OperatingSystem).ProductType + + Describe 'Environment' { + Context 'Operating System' { + It 'Should be a Server OS' { + $productType | Should -Be 3 + } + } + } + + if ($productType -ne 3) + { + break + } + + $featureInstalled = (Get-WindowsFeature -Name FS-DFS-Namespace).Installed + + Describe 'Environment' { + Context 'Windows Features' { + It 'Should have the DFS Namespace Feature Installed' { + $featureInstalled | Should -Be $true + } + } + } + + if ($featureInstalled -eq $false) + { + break + } + + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1" + . $configFile + + Describe "$($script:dscResourceName)_Integration" { + Context 'When creating a DFS Namespace Root' { + BeforeAll { + $script:namespaceRootName = 'IntegrationTestNamespace' + $script:namespaceRoot = @{ + Path = "\\$($env:COMPUTERNAME)\$script:namespaceRootName" + TargetPath = "\\$($env:COMPUTERNAME)\$script:namespaceRootName" + Ensure = 'Present' + Type = 'Standalone' + Description = 'Integration test namespace' + TimeToLiveSec = 500 + EnableSiteCosting = $true + EnableInsiteReferrals = $true + EnableAccessBasedEnumeration = $true + EnableRootScalability = $true + EnableTargetFailback = $true + ReferralPriorityClass = 'Global-Low' + ReferralPriorityRank = 10 + } + + # Create a SMB share for the Namespace + $randomFileName = [System.IO.Path]::GetRandomFileName() + $script:shareFolderRoot = Join-Path -Path $env:Temp -ChildPath "$($script:DSCResourceName)_$randomFileName" + + New-Item ` + -Path $script:shareFolderRoot ` + -Type Directory + + New-SMBShare ` + -Name $script:namespaceRootName ` + -Path $script:shareFolderRoot ` + -FullAccess 'Everyone' + } + + It 'Should compile and apply the MOF without throwing' { + { + $configData = @{ + AllNodes = @( + @{ + NodeName = 'localhost' + Path = $script:namespaceRoot.Path + TargetPath = $script:namespaceRoot.TargetPath + Ensure = $script:namespaceRoot.Ensure + Type = $script:namespaceRoot.Type + Description = $script:namespaceRoot.Description + TimeToLiveSec = $script:namespaceRoot.TimeToLiveSec + EnableSiteCosting = $script:namespaceRoot.EnableSiteCosting + EnableInsiteReferrals = $script:namespaceRoot.EnableInsiteReferrals + EnableAccessBasedEnumeration = $script:namespaceRoot.EnableAccessBasedEnumeration + EnableRootScalability = $script:namespaceRoot.EnableRootScalability + EnableTargetFailback = $script:namespaceRoot.EnableTargetFailback + ReferralPriorityClass = $script:namespaceRoot.ReferralPriorityClass + ReferralPriorityRank = $script:namespaceRoot.ReferralPriorityRank + } + ) + } + + & "$($script:DSCResourceName)_Config" ` + -OutputPath $TestDrive ` + -ConfigurationData $configData + + Start-DscConfiguration ` + -Path $TestDrive ` + -ComputerName localhost ` + -Wait ` + -Verbose ` + -Force ` + -ErrorAction Stop + } | Should -Not -Throw + } + + It 'Should be able to call Get-DscConfiguration without throwing' { + { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw + } + + It 'Should have set the resource and all the folder parameters should match' { + # Get the Rule details + $namespaceRootNew = Get-DfsnRoot -Path $script:namespaceRoot.Path + $namespaceRootNew.Path | Should -Be $script:namespaceRoot.Path + $namespaceRootNew.Type | Should -Be $script:namespaceRoot.Type + $namespaceRootNew.TimeToLiveSec | Should -Be $script:namespaceRoot.TimeToLiveSec + $namespaceRootNew.State | Should -Be 'Online' + $namespaceRootNew.Description | Should -Be $script:namespaceRoot.Description + $namespaceRootNew.NamespacePath | Should -Be $script:namespaceRoot.Path + $namespaceRootNew.Flags | Should -Be @('Target Failback','Site Costing','Insite Referrals','AccessBased Enumeration') + } + + It 'Should have set the resource and all the folder target parameters should match' { + $namespaceRootTargetNew = Get-DfsnRootTarget ` + -Path $script:namespaceRoot.Path ` + -TargetPath $script:namespaceRoot.TargetPath + $namespaceRootTargetNew.Path | Should -Be $script:namespaceRoot.Path + $namespaceRootTargetNew.NamespacePath | Should -Be $script:namespaceRoot.Path + $namespaceRootTargetNew.TargetPath | Should -Be $script:namespaceRoot.TargetPath + $namespaceRootTargetNew.ReferralPriorityClass | Should -Be $script:namespaceRoot.ReferralPriorityClass + $namespaceRootTargetNew.ReferralPriorityRank | Should -Be $script:namespaceRoot.ReferralPriorityRank + } + + AfterAll { + # Clean up + Remove-DFSNRoot ` + -Path $script:namespaceRoot.Path ` + -Force ` + -Confirm:$false + + Remove-SMBShare ` + -Name $script:namespaceRootName ` + -Confirm:$false + + Remove-Item ` + -Path $script:shareFolderRoot ` + -Recurse ` + -Force + } + } + } +} +finally +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} diff --git a/tests/Integration/DSC_DFSNamespaceRoot.config.ps1 b/tests/Integration/DSC_DFSNamespaceRoot.config.ps1 new file mode 100644 index 0000000..6e21c91 --- /dev/null +++ b/tests/Integration/DSC_DFSNamespaceRoot.config.ps1 @@ -0,0 +1,22 @@ +Configuration DSC_DFSNamespaceRoot_Config { + Import-DscResource -ModuleName DFSDsc + + Node localhost { + DFSNamespaceRoot Integration_Test { + Path = $Node.Path + TargetPath = $Node.TargetPath + Ensure = $Node.Ensure + Type = $Node.Type + Description = $Node.Description + TimeToLiveSec = $Node.TimeToLiveSec + EnableSiteCosting = $Node.EnableSiteCosting + EnableInsiteReferrals = $Node.EnableInsiteReferrals + EnableAccessBasedEnumeration = $Node.EnableAccessBasedEnumeration + # Not supported by Standalone Namespaces + # EnableRootScalability = $Node.EnableRootScalability + EnableTargetFailback = $Node.EnableTargetFailback + ReferralPriorityClass = $Node.ReferralPriorityClass + ReferralPriorityRank = $Node.ReferralPriorityRank + } + } +} diff --git a/tests/Integration/DSC_DFSNamespaceServerConfiguration.Integration.Tests.ps1 b/tests/Integration/DSC_DFSNamespaceServerConfiguration.Integration.Tests.ps1 new file mode 100644 index 0000000..f2c26c4 --- /dev/null +++ b/tests/Integration/DSC_DFSNamespaceServerConfiguration.Integration.Tests.ps1 @@ -0,0 +1,130 @@ +[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "")] +param () + +$script:dscModuleName = 'DFSDsc' +$script:dscResourceName = 'DSC_DFSNamespaceServerConfiguration' + +try +{ + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' +} +catch [System.IO.FileNotFoundException] +{ + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' +} + +$script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Integration' + +Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') + +try +{ + # Ensure that the tests can be performed on this computer + $productType = (Get-CimInstance Win32_OperatingSystem).ProductType + + Describe 'Environment' { + Context 'Operating System' { + It 'Should be a Server OS' { + $productType | Should -Be 3 + } + } + } + + if ($productType -ne 3) + { + break + } + + $featureInstalled = (Get-WindowsFeature -Name FS-DFS-Namespace).Installed + + Describe 'Environment' { + Context 'Windows Features' { + It 'Should have the DFS Namespace Feature Installed' { + $featureInstalled | Should -Be $true + } + } + } + + if ($featureInstalled -eq $false) + { + break + } + + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1" + . $configFile + + Describe "$($script:dscResourceName)_Integration" { + BeforeAll { + # Backup the existing settings + $script:serverConfigurationBackup = Get-DFSNServerConfiguration ` + -ComputerName $env:COMPUTERNAME + + $script:namespaceServerConfiguration = @{ + LdapTimeoutSec = 45 + SyncIntervalSec = 5000 + UseFQDN = $True + } + } + + It 'Should compile and apply the MOF without throwing' { + { + $configData = @{ + AllNodes = @( + @{ + NodeName = 'localhost' + LdapTimeoutSec = $script:namespaceServerConfiguration.LdapTimeoutSec + SyncIntervalSec = $script:namespaceServerConfiguration.SyncIntervalSec + UseFQDN = $script:namespaceServerConfiguration.UseFQDN + } + ) + } + + & "$($script:DSCResourceName)_Config" ` + -OutputPath $TestDrive ` + -ConfigurationData $configData + + Start-DscConfiguration ` + -Path $TestDrive ` + -ComputerName localhost ` + -Wait ` + -Verbose ` + -Force ` + -ErrorAction Stop + } | Should -Not -Throw + } + + It 'Should be able to call Get-DscConfiguration without throwing' { + { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw + } + + It 'Should have set the resource and all the parameters should match' { + # Get the Rule details + $namespaceServerConfigurationNew = Get-DfsnServerConfiguration -ComputerName $env:COMPUTERNAME + $namespaceServerConfigurationNew.LdapTimeoutSec = $script:namespaceServerConfiguration.LdapTimeoutSec + $namespaceServerConfigurationNew.SyncIntervalSec = $script:namespaceServerConfiguration.SyncIntervalSec + $namespaceServerConfigurationNew.UseFQDN = $script:namespaceServerConfiguration.UseFQDN + } + + AfterAll { + if (-not $script:serverConfigurationBackup.UseFQDN) + { + $script:serverConfigurationBackup.UseFQDN = $false + } + + # Clean up + Set-DFSNServerConfiguration ` + -ComputerName $env:COMPUTERNAME ` + -LdapTimeoutSec $script:serverConfigurationBackup.LdapTimeoutSec ` + -SyncIntervalSec $script:serverConfigurationBackup.SyncIntervalSec ` + -UseFQDN $script:serverConfigurationBackup.UseFQDN + } + } +} +finally +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} diff --git a/tests/Integration/DSC_DFSNamespaceServerConfiguration.config.ps1 b/tests/Integration/DSC_DFSNamespaceServerConfiguration.config.ps1 new file mode 100644 index 0000000..ee0c8b1 --- /dev/null +++ b/tests/Integration/DSC_DFSNamespaceServerConfiguration.config.ps1 @@ -0,0 +1,12 @@ +Configuration DSC_DFSNamespaceServerConfiguration_Config { + Import-DscResource -ModuleName DFSDsc + + Node localhost { + DFSNamespaceServerConfiguration Integration_Test { + IsSingleInstance = 'Yes' + LdapTimeoutSec = $Node.LdapTimeoutSec + SyncIntervalSec = $Node.SyncIntervalSec + UseFQDN = $Node.UseFQDN + } + } +} diff --git a/tests/Integration/DSC_DFSReplicationGroup.Integration.Tests.ps1 b/tests/Integration/DSC_DFSReplicationGroup.Integration.Tests.ps1 new file mode 100644 index 0000000..7490a3d --- /dev/null +++ b/tests/Integration/DSC_DFSReplicationGroup.Integration.Tests.ps1 @@ -0,0 +1,224 @@ +<# + These integration tests can only be run on a computer that: + 1. Is a member of an Active Directory domain. + 2. Has access to two Windows Server 2012 or greater servers with + the FS-DFS-Replication and RSAT-DFS-Mgmt-Con features installed. + 3. An AD User account that has the required permissions that are needed + to create a DFS Replication Group. + + If the above are available then to allow these tests to be run a + DSC_DFSReplicationGroup.config.json file must be created in the same folder as + this file. The content should be a customized version of the following: + { + "Username": "contoso.com\\Administrator", + "Folders": [ + "TestFolder1", + "TestFolder2" + ], + "Members": [ + "Server1", + "Server2" + ], + "ContentPaths": [ + "c:\\IntegrationTests\\TestFolder1", + "c:\\IntegrationTests\\TestFolder2" + ], + "Password": "MyPassword" + } + + If the above are available and configured these integration tests will run. +#> +[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "")] +param () + +$script:dscModuleName = 'DFSDsc' +$script:dscResourceName = 'DSC_DFSReplicationGroup' + +# Test to see if the JSON config file is available. +$script:configJson = [System.IO.Path]::ChangeExtension($MyInvocation.MyCommand.Path,'json') + +if (-not (Test-Path -Path $configJson)) +{ + return +} + +try +{ + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' +} +catch [System.IO.FileNotFoundException] +{ + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' +} + +$script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Integration' + +Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') + +try +{ + # Ensure that the tests can be performed on this computer + $productType = (Get-CimInstance Win32_OperatingSystem).ProductType + + Describe 'Environment' { + Context 'Operating System' { + It 'Should be a Server OS' { + $productType | Should -Be 3 + } + } + } + + if ($productType -ne 3) + { + break + } + + $featureInstalled = (Get-WindowsFeature -Name FS-DFS-Namespace).Installed + + Describe 'Environment' { + Context 'Windows Features' { + It 'Should have the DFS Namespace Feature Installed' { + $featureInstalled | Should -Be $true + } + } + } + + if ($featureInstalled -eq $false) + { + break + } + + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1" + . $configFile + + Describe "$($script:dscResourceName)_Integration" { + Context 'When the creating a DFS Replication Group' { + BeforeAll { + # If there is a .config.json file for these tests, read the test parameters from it. + if (Test-Path -Path $script:configJson) + { + $script:testConfig = Get-Content -Path $script:configJson | ConvertFrom-Json + } + else + { + # Example config parameters. + $script:testConfig = @{ + Username = 'contoso.com\Administrator' + Password = 'MyP@ssw0rd!1' + Members = @('Server1','Server1') + Folders = @('TestFolder1','TestFolder2') + ContentPaths = @("$(ENV:Temp)TestFolder1","$(ENV:Temp)TestFolder2") + } + } + + $script:testPassword = ConvertTo-SecureString -String $script:testConfig.Password -AsPlainText -Force + $script:PSDscRunAsCredential = New-Object ` + -TypeName System.Management.Automation.PSCredential ` + -ArgumentList ($script:testConfig.Username, $script:testPassword) + + $script:replicationGroup = @{ + GroupName = 'IntegrationTestReplicationGroup' + Description = 'Integration Test Replication Group' + Ensure = 'Present' + Members = $script:testConfig.Members + Folders = $script:testConfig.Folders + Topology = 'Fullmesh' + PSDSCRunAsCredential = $script:PSDscRunAsCredential + } + } + + It 'Should compile and apply the MOF without throwing' { + { + $configData = @{ + AllNodes = @( + @{ + NodeName = 'localhost' + GroupName = $script:replicationGroup.GroupName + Description = $script:replicationGroup.Description + Ensure = $script:replicationGroup.Ensure + Members = $script:replicationGroup.Members + Folders = $script:replicationGroup.Folders + ContentPaths = $script:replicationGroup.ContentPaths + Topology = $script:replicationGroup.Topology + PSDSCRunAsCredential = $script:replicationGroup.PSDSCRunAsCredential + PSDscAllowPlainTextPassword = $true + } + ) + } + + & "$($script:DSCResourceName)_Config" ` + -OutputPath $TestDrive ` + -ConfigurationData $configData + + Start-DscConfiguration ` + -Path $TestDrive ` + -ComputerName localhost ` + -Wait ` + -Verbose ` + -Force ` + -ErrorAction Stop + } | Should -Not -Throw + } + + It 'Should be able to call Get-DscConfiguration without throwing' { + { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw + } + + It 'Should have set the resource and all the parameters should match' { + $replicationGroupNew = Get-DfsReplicationGroup ` + -GroupName $script:replicationGroup.GroupName ` + -ErrorAction Stop + $replicationGroupNew.GroupName | Should -Be $script:replicationGroup.GroupName + $replicationGroupNew.Description | Should -Be $script:replicationGroup.Description + + # Check the members are in the Replication Group + foreach ($member in $script:replicationGroup.Members) + { + $replicationGroupMemberNew = Get-DfsrMember ` + -GroupName $script:replicationGroup.GroupName ` + -ComputerName $Member ` + -ErrorAction Stop + $replicationGroupMemberNew.GroupName | Should -Be $script:replicationGroup.GroupName + + # If Member name was an FQDN then match the DNSName property, otherwise the ComputerName property + if ($member.Contains('.')) + { + $replicationGroupMemberNew.DnsName | Should -Be $Member + } + else + { + $replicationGroupMemberNew.ComputerName | Should -Be $Member + } + } + + # Check the folders are in the Replication Group + foreach ($folder in $script:replicationGroup.Folders) + { + $replicationGroupFolderNew = Get-DfsReplicatedFolder ` + -GroupName $script:replicationGroup.GroupName ` + -FolderName $folder ` + -ErrorAction Stop + $replicationGroupFolderNew.GroupName | Should -Be $script:replicationGroup.GroupName + $replicationGroupFolderNew.FolderName | Should -Be $folder + } + } + } + + AfterAll { + # Clean up + Remove-DFSReplicationGroup ` + -GroupName $script:replicationGroup.GroupName ` + -RemoveReplicatedFolders ` + -Force ` + -Confirm:$false + } + } +} +finally +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} diff --git a/tests/Integration/DSC_DFSReplicationGroup.config.ps1 b/tests/Integration/DSC_DFSReplicationGroup.config.ps1 new file mode 100644 index 0000000..b4a091b --- /dev/null +++ b/tests/Integration/DSC_DFSReplicationGroup.config.ps1 @@ -0,0 +1,16 @@ +Configuration DSC_DFSReplicationGroup_Config { + Import-DscResource -ModuleName DFSDsc + + Node localhost { + DFSReplicationGroup Integration_Test { + GroupName = $Node.GroupName + Description = $Node.Description + Ensure = $Node.Ensure + Members = $Node.Members + Folders = $Node.Folders + ContentPaths = $Node.ContentPaths + Topology = $Node.Topology + PSDSCRunAsCredential = $Node.PSDSCRunAsCredential + } + } +} diff --git a/tests/Integration/DSC_DFSReplicationGroupConnection.Integration.Tests.ps1 b/tests/Integration/DSC_DFSReplicationGroupConnection.Integration.Tests.ps1 new file mode 100644 index 0000000..d856a71 --- /dev/null +++ b/tests/Integration/DSC_DFSReplicationGroupConnection.Integration.Tests.ps1 @@ -0,0 +1,209 @@ +<# + These integration tests can only be run on a computer that: + 1. Is a member of an Active Directory domain. + 2. Has access to two Windows Server 2012 or greater servers with + the FS-DFS-Replication and RSAT-DFS-Mgmt-Con features installed. + 3. An AD User account that has the required permissions that are needed + to create a DFS Replication Group. + + If the above are available then to allow these tests to be run a + DSC_DFSReplicationGroupFolder.config.json file must be created in the same folder as + this file. The content should be a customized version of the following: + { + "Username": "contoso.com\\Administrator", + "Folders": [ + "TestFolder1", + "TestFolder2" + ], + "Members": [ + "Server1", + "Server2" + ], + "ContentPaths": [ + "c:\\IntegrationTests\\TestFolder1", + "c:\\IntegrationTests\\TestFolder2" + ], + "Password": "MyPassword" + } + + If the above are available and configured these integration tests will run. +#> +[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "")] +param () + +$script:dscModuleName = 'DFSDsc' +$script:dscResourceName = 'DSC_DFSReplicationGroupConnection' + +# Test to see if the JSON config file is available. +$script:configJson = [System.IO.Path]::ChangeExtension($MyInvocation.MyCommand.Path,'json') + +if (-not (Test-Path -Path $configJson)) +{ + return +} + +try +{ + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' +} +catch [System.IO.FileNotFoundException] +{ + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' +} + +$script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Integration' + +Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') + +try +{ + # Ensure that the tests can be performed on this computer + $productType = (Get-CimInstance Win32_OperatingSystem).ProductType + Describe 'Environment' { + Context 'Operating System' { + It 'Should be a Server OS' { + $productType | Should -Be 3 + } + } + } + + if ($productType -ne 3) + { + break + } + + $featureInstalled = (Get-WindowsFeature -Name FS-DFS-Namespace).Installed + Describe 'Environment' { + Context 'Windows Features' { + It 'Should have the DFS Namespace Feature Installed' { + $featureInstalled | Should -Be $true + } + } + } + + if ($featureInstalled -eq $false) + { + break + } + + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1" + . $configFile + + Describe "$($script:dscResourceName)_Integration" { + Context 'When the creating a DFS Replication Group connection' { + BeforeAll { + # If there is a .config.json file for these tests, read the test parameters from it. + if (Test-Path -Path $script:configJson) + { + $script:testConfig = Get-Content -Path $script:configJson | ConvertFrom-Json + } + else + { + # Example config parameters. + $script:testConfig = @{ + Username = 'contoso.com\Administrator' + Password = 'MyP@ssw0rd!1' + Members = @('Server1','Server1') + Folders = @('TestFolder1','TestFolder2') + ContentPaths = @("$(ENV:Temp)TestFolder1","$(ENV:Temp)TestFolder2") + } + } + + $script:testPassword = ConvertTo-SecureString -String $script:testConfig.Password -AsPlainText -Force + $script:PSDscRunAsCredential = New-Object ` + -TypeName System.Management.Automation.PSCredential ` + -ArgumentList ($script:testConfig.Username, $script:testPassword) + + $script:replicationGroupConnection = @{ + GroupName = 'IntegrationTestReplicationGroup' + Folders = $script:testConfig.Folders + Members = $script:testConfig.Members + Ensure = 'Present' + SourceComputerName = $script:testConfig.Members[0] + DestinationComputerName = $script:testConfig.Members[1] + PSDSCRunAsCredential = $script:PSDscRunAsCredential + } + + # Create the Replication group to work with + New-DFSReplicationGroup ` + -GroupName $script:replicationGroupConnection.GroupName + + foreach ($member in $script:replicationGroupConnection.Members) + { + Add-DFSRMember ` + -GroupName $script:replicationGroupConnection.GroupName ` + -ComputerName $member + } + + foreach ($folder in $script:replicationGroupConnection.Folders) + { + New-DFSReplicatedFolder ` + -GroupName $script:replicationGroupConnection.GroupName ` + -FolderName $folder + } + } + + It 'Should compile and apply the MOF without throwing' { + { + $ConfigData = @{ + AllNodes = @( + @{ + NodeName = 'localhost' + GroupName = $script:replicationGroupConnection.GroupName + Ensure = $script:replicationGroupConnection.Ensure + SourceComputerName = $script:replicationGroupConnection.SourceComputerName + DestinationComputerName = $script:replicationGroupConnection.DestinationComputerName + PSDSCRunAsCredential = $script:replicationGroupConnection.PSDSCRunAsCredential + PSDscAllowPlainTextPassword = $true + } + ) + } + + & "$($script:DSCResourceName)_Config" ` + -OutputPath $TestDrive ` + -ConfigurationData $configData + + Start-DscConfiguration ` + -Path $TestDrive ` + -ComputerName localhost ` + -Wait ` + -Verbose ` + -Force ` + -ErrorAction Stop + } | Should -Not -Throw + } + + It 'Should be able to call Get-DscConfiguration without throwing' { + { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw + } + + It 'Should have set the resource and all the parameters should match' { + $replicationGroupConnectionNew = Get-DfsrConnection ` + -GroupName $script:replicationGroupConnection.GroupName ` + -SourceComputerName $script:replicationGroupConnection.SourceComputerName ` + -DestinationComputerName $script:replicationGroupConnection.DestinationComputerName ` + -ErrorAction Stop + $replicationGroupConnectionNew.GroupName | Should -Be $script:replicationGroupConnection.GroupName + $replicationGroupConnectionNew.SourceComputerName | Should -Be $script:replicationGroupConnection.SourceComputerName + $replicationGroupConnectionNew.DestinationComputerName | Should -Be $script:replicationGroupConnection.DestinationComputerName + } + + AfterAll { + # Clean up + Remove-DFSReplicationGroup ` + -GroupName $script:replicationGroupConnection.GroupName ` + -RemoveReplicatedFolders ` + -Force ` + -Confirm:$false + } + } + } +} +finally +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} diff --git a/tests/Integration/DSC_DFSReplicationGroupConnection.config.ps1 b/tests/Integration/DSC_DFSReplicationGroupConnection.config.ps1 new file mode 100644 index 0000000..ba082d7 --- /dev/null +++ b/tests/Integration/DSC_DFSReplicationGroupConnection.config.ps1 @@ -0,0 +1,13 @@ +Configuration DSC_DFSReplicationGroupConnection_Config { + Import-DscResource -ModuleName DFSDsc + + Node localhost { + DFSReplicationGroupConnection Integration_Test { + GroupName = $Node.GroupName + Ensure = $Node.Ensure + SourceComputerName = $Node.SourceComputerName + DestinationComputerName = $Node.DestinationComputerName + PSDSCRunAsCredential = $Node.PSDSCRunAsCredential + } + } +} diff --git a/tests/Integration/DSC_DFSReplicationGroupFolder.Integration.Tests.ps1 b/tests/Integration/DSC_DFSReplicationGroupFolder.Integration.Tests.ps1 new file mode 100644 index 0000000..a39a847 --- /dev/null +++ b/tests/Integration/DSC_DFSReplicationGroupFolder.Integration.Tests.ps1 @@ -0,0 +1,212 @@ +<# + These integration tests can only be run on a computer that: + 1. Is a member of an Active Directory domain. + 2. Has access to two Windows Server 2012 or greater servers with + the FS-DFS-Replication and RSAT-DFS-Mgmt-Con features installed. + 3. An AD User account that has the required permissions that are needed + to create a DFS Replication Group. + + If the above are available then to allow these tests to be run a + DSC_DFSReplicationGroupFolder.config.json file must be created in the same folder as + this file. The content should be a customized version of the following: + { + "Username": "contoso.com\\Administrator", + "Folders": [ + "TestFolder1", + "TestFolder2" + ], + "Members": [ + "Server1", + "Server2" + ], + "ContentPaths": [ + "c:\\IntegrationTests\\TestFolder1", + "c:\\IntegrationTests\\TestFolder2" + ], + "Password": "MyPassword" + } + + If the above are available and configured these integration tests will run. +#> +[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "")] +param () + +$script:dscModuleName = 'DFSDsc' +$script:dscResourceName = 'DSC_DFSReplicationGroupFolder' + +# Test to see if the JSON config file is available. +$script:configJson = [System.IO.Path]::ChangeExtension($MyInvocation.MyCommand.Path,'json') + +if (-not (Test-Path -Path $configJson)) +{ + return +} + +try +{ + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' +} +catch [System.IO.FileNotFoundException] +{ + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' +} + +$script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Integration' + +Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') + +try +{ + # Ensure that the tests can be performed on this computer + $productType = (Get-CimInstance Win32_OperatingSystem).ProductType + Describe 'Environment' { + Context 'Operating System' { + It 'Should be a Server OS' { + $productType | Should -Be 3 + } + } + } + + if ($productType -ne 3) + { + break + } + + $featureInstalled = (Get-WindowsFeature -Name FS-DFS-Namespace).Installed + Describe 'Environment' { + Context 'Windows Features' { + It 'Should have the DFS Namespace Feature Installed' { + $featureInstalled | Should -Be $true + } + } + } + + if ($featureInstalled -eq $false) + { + break + } + + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1" + . $configFile + + Describe "$($script:dscResourceName)_Integration" { + Context 'When the creating a DFS Replication Group Folder' { + BeforeAll { + # If there is a .config.json file for these tests, read the test parameters from it. + if (Test-Path -Path $script:configJson) + { + $script:testConfig = Get-Content -Path $script:configJson | ConvertFrom-Json + } + else + { + # Example config parameters. + $script:testConfig = @{ + Username = 'contoso.com\Administrator' + Password = 'MyP@ssw0rd!1' + Members = @('Server1','Server1') + Folders = @('TestFolder1','TestFolder2') + ContentPaths = @("$(ENV:Temp)TestFolder1","$(ENV:Temp)TestFolder2") + } + } + + $script:testPassword = ConvertTo-SecureString -String $script:testConfig.Password -AsPlainText -Force + $script:PSDscRunAsCredential = New-Object ` + -TypeName System.Management.Automation.PSCredential ` + -ArgumentList ($script:testConfig.Username, $script:testPassword) + + $script:replicationGroupFolder = @{ + GroupName = 'IntegrationTestReplicationGroup' + Folders = $script:testConfig.Folders + Members = $script:testConfig.Members + FolderName = $script:testConfig.Folders[0] + Description = "Integration Test Rep Group Folder $($script:testConfig.Folders[0])" + DirectoryNameToExclude = @('Temp') + FilenameToExclude = @('*.bak','*.tmp') + PSDSCRunAsCredential = $script:PSDscRunAsCredential + } + + # Create the Replication group to work with + New-DFSReplicationGroup ` + -GroupName $script:replicationGroupFolder.GroupName + + foreach ($Member in $script:replicationGroupFolder.Members) + { + Add-DFSRMember ` + -GroupName $script:replicationGroupFolder.GroupName ` + -ComputerName $Member + } + + foreach ($Folder in $script:replicationGroupFolder.Folders) + { + New-DFSReplicatedFolder ` + -GroupName $script:replicationGroupFolder.GroupName ` + -FolderName $Folder + } + } + + It 'Should compile and apply the MOF without throwing' { + { + $configData = @{ + AllNodes = @( + @{ + NodeName = 'localhost' + GroupName = $script:replicationGroupFolder.GroupName + FolderName = $script:replicationGroupFolder.FolderName + Description = $script:replicationGroupFolder.Description + DirectoryNameToExclude = $script:replicationGroupFolder.DirectoryNameToExclude + FilenameToExclude = $script:replicationGroupFolder.FilenameToExclude + PSDSCRunAsCredential = $script:replicationGroupFolder.PSDSCRunAsCredential + PSDscAllowPlainTextPassword = $true + } + ) + } + + & "$($script:DSCResourceName)_Config" ` + -OutputPath $TestDrive ` + -ConfigurationData $configData + + Start-DscConfiguration ` + -Path $TestDrive ` + -ComputerName localhost ` + -Wait ` + -Verbose ` + -Force ` + -ErrorAction Stop + } | Should -Not -Throw + } + + It 'Should be able to call Get-DscConfiguration without throwing' { + { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw + } + + It 'Should have set the resource and all the parameters should match' { + $replicationGroupFolderNew = Get-DfsReplicatedFolder ` + -GroupName $script:replicationGroupFolder.GroupName ` + -FolderName $script:replicationGroupFolder.FolderName ` + -ErrorAction Stop + $replicationGroupFolderNew.GroupName | Should -Be $script:replicationGroupFolder.GroupName + $replicationGroupFolderNew.FolderName | Should -Be $script:replicationGroupFolder.FolderName + $replicationGroupFolderNew.Description | Should -Be $script:replicationGroupFolder.Description + $replicationGroupFolderNew.DirectoryNameToExclude | Should -Be $script:replicationGroupFolder.DirectoryNameToExclude + $replicationGroupFolderNew.FilenameToExclude | Should -Be $script:replicationGroupFolder.FilenameToExclude + } + + AfterAll { + # Clean up + Remove-DFSReplicationGroup ` + -GroupName $script:replicationGroupFolder.GroupName ` + -RemoveReplicatedFolders ` + -Force ` + -Confirm:$false + } + } + } +} +finally +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} diff --git a/tests/Integration/DSC_DFSReplicationGroupFolder.config.ps1 b/tests/Integration/DSC_DFSReplicationGroupFolder.config.ps1 new file mode 100644 index 0000000..7afc0d6 --- /dev/null +++ b/tests/Integration/DSC_DFSReplicationGroupFolder.config.ps1 @@ -0,0 +1,14 @@ +Configuration DSC_DFSReplicationGroupFolder_Config { + Import-DscResource -ModuleName DFSDsc + + Node localhost { + DFSReplicationGroupFolder Integration_Test { + GroupName = $Node.GroupName + FolderName = $Node.FolderName + Description = $Node.Description + DirectoryNameToExclude = $Node.DirectoryNameToExclude + FilenameToExclude = $Node.FilenameToExclude + PSDSCRunAsCredential = $Node.PSDSCRunAsCredential + } + } +} diff --git a/tests/Integration/DSC_DFSReplicationGroupMembership.Integration.Tests.ps1 b/tests/Integration/DSC_DFSReplicationGroupMembership.Integration.Tests.ps1 new file mode 100644 index 0000000..7f5d259 --- /dev/null +++ b/tests/Integration/DSC_DFSReplicationGroupMembership.Integration.Tests.ps1 @@ -0,0 +1,216 @@ +<# + These integration tests can only be run on a computer that: + 1. Is a member of an Active Directory domain. + 2. Has access to two Windows Server 2012 or greater servers with + the FS-DFS-Replication and RSAT-DFS-Mgmt-Con features installed. + 3. An AD User account that has the required permissions that are needed + to create a DFS Replication Group. + + If the above are available then to allow these tests to be run a + DSC_DFSReplicationGroupMembership.config.json file must be created in the same folder as + this file. The content should be a customized version of the following: + { + "Username": "contoso.com\\Administrator", + "Folders": [ + "TestFolder1", + "TestFolder2" + ], + "Members": [ + "Server1", + "Server2" + ], + "ContentPaths": [ + "c:\\IntegrationTests\\TestFolder1", + "c:\\IntegrationTests\\TestFolder2" + ], + "Password": "MyPassword" + } + + If the above are available and configured these integration tests will run. +#> +[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "")] +param () + +$script:dscModuleName = 'DFSDsc' +$script:dscResourceName = 'DSC_DFSReplicationGroupMembership' + +# Test to see if the JSON config file is available. +$script:configJson = [System.IO.Path]::ChangeExtension($MyInvocation.MyCommand.Path,'json') + +if (-not (Test-Path -Path $configJson)) +{ + return +} + +try +{ + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' +} +catch [System.IO.FileNotFoundException] +{ + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' +} + +$script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Integration' + +Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') + +try +{ + # Ensure that the tests can be performed on this computer + $productType = (Get-CimInstance Win32_OperatingSystem).ProductType + Describe 'Environment' { + Context 'Operating System' { + It 'Should be a Server OS' { + $productType | Should -Be 3 + } + } + } + + if ($productType -ne 3) + { + break + } + + $featureInstalled = (Get-WindowsFeature -Name FS-DFS-Namespace).Installed + Describe 'Environment' { + Context 'Windows Features' { + It 'Should have the DFS Namespace Feature Installed' { + $featureInstalled | Should -Be $true + } + } + } + + if ($featureInstalled -eq $false) + { + break + } + + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1" + . $configFile + + Describe "$($script:dscResourceName)_Integration" { + Context 'When creating a DFS Replication Group Membership' { + BeforeAll { + # If there is a .config.json file for these tests, read the test parameters from it. + if (Test-Path -Path $script:configJson) + { + $script:testConfig = Get-Content -Path $script:configJson | ConvertFrom-Json + } + else + { + # Example config parameters. + $script:testConfig = @{ + Username = 'contoso.com\Administrator' + Password = 'MyP@ssw0rd!1' + Members = @('Server1','Server1') + Folders = @('TestFolder1','TestFolder2') + ContentPaths = @("$(ENV:Temp)TestFolder1","$(ENV:Temp)TestFolder2") + } + } + + $script:testPassword = ConvertTo-SecureString -String $script:testConfig.Password -AsPlainText -Force + $script:PSDscRunAsCredential = New-Object ` + -TypeName System.Management.Automation.PSCredential ` + -ArgumentList ($script:testConfig.Username, $script:testPassword) + + $script:replicationGroupMembership = @{ + GroupName = 'IntegrationTestReplicationGroup' + Folders = $script:testConfig.Folders + FolderName = $script:testConfig.Folders[0] + Members = $script:testConfig.Members + ComputerName = $script:testConfig.Members[0] + ContentPath = $script:testConfig.ContentPaths[0] + ReadOnly = $false + PrimaryMember = $true + PSDSCRunAsCredential = $script:PSDscRunAsCredential + } + + # Create the Replication group to work with + New-DFSReplicationGroup ` + -GroupName $script:replicationGroupMembership.GroupName + + foreach ($member in $script:replicationGroupMembership.Members) + { + Add-DFSRMember ` + -GroupName $script:replicationGroupMembership.GroupName ` + -ComputerName $member + } + + foreach ($folder in $script:replicationGroupMembership.Folders) + { + New-DFSReplicatedFolder ` + -GroupName $script:replicationGroupMembership.GroupName ` + -FolderName $folder + } + } + + It 'Should compile and apply the MOF without throwing' { + { + $configData = @{ + AllNodes = @( + @{ + NodeName = 'localhost' + GroupName = $script:replicationGroupMembership.GroupName + FolderName = $script:replicationGroupMembership.FolderName + ComputerName = $script:replicationGroupMembership.ComputerName + ContentPath = $script:replicationGroupMembership.ContentPath + ReadOnly = $script:replicationGroupMembership.ReadOnly + PrimaryMember = $script:replicationGroupMembership.PrimaryMember + PSDSCRunAsCredential = $script:replicationGroupMembership.PSDSCRunAsCredential + PSDscAllowPlainTextPassword = $true + } + ) + } + + & "$($script:DSCResourceName)_Config" ` + -OutputPath $TestDrive ` + -ConfigurationData $configData + + Start-DscConfiguration ` + -Path $TestDrive ` + -ComputerName localhost ` + -Wait ` + -Verbose ` + -Force ` + -ErrorAction Stop + } | Should -Not -Throw + } + + It 'Should be able to call Get-DscConfiguration without throwing' { + { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw + } + + It 'Should have set the resource and all the parameters should match' { + $replicationGroupMembershipNew = Get-DfsrMembership ` + -GroupName $script:replicationGroupMembership.GroupName ` + -ComputerName $script:replicationGroupMembership.Members[0] ` + -ErrorAction Stop | Where-Object -Property FolderName -eq $script:replicationGroupMembership.Folders[0] + $replicationGroupMembershipNew.GroupName | Should -Be $script:replicationGroupMembership.GroupName + $replicationGroupMembershipNew.ComputerName | Should -Be $script:replicationGroupMembership.Members[0] + $replicationGroupMembershipNew.FolderName | Should -Be $script:replicationGroupMembership.Folders[0] + $replicationGroupMembershipNew.ContentPath | Should -Be $script:replicationGroupMembership.ContentPath + $replicationGroupMembershipNew.StagingPathQuotaInMB | Should -Be $script:replicationGroupMembership.StagingPathQuotaInMB + $replicationGroupMembershipNew.ReadOnly | Should -Be $script:replicationGroupMembership.ReadOnly + $replicationGroupMembershipNew.PrimaryMember | Should -Be $script:replicationGroupMembership.PrimaryMember + } + } + + AfterAll { + # Clean up + Remove-DFSReplicationGroup ` + -GroupName $script:replicationGroupMembership.GroupName ` + -RemoveReplicatedFolders ` + -Force ` + -Confirm:$false + } + } +} +finally +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} diff --git a/tests/Integration/DSC_DFSReplicationGroupMembership.config.ps1 b/tests/Integration/DSC_DFSReplicationGroupMembership.config.ps1 new file mode 100644 index 0000000..f69ca25 --- /dev/null +++ b/tests/Integration/DSC_DFSReplicationGroupMembership.config.ps1 @@ -0,0 +1,15 @@ +Configuration DSC_DFSReplicationGroupMembership_Config { + Import-DscResource -ModuleName DFSDsc + + Node localhost { + DFSReplicationGroupMembership Integration_Test { + GroupName = $Node.GroupName + FolderName = $Node.FolderName + ComputerName = $Node.ComputerName + ContentPath = $Node.ContentPath + ReadOnly = $Node.ReadOnly + PrimaryMember = $Node.PrimaryMember + PSDSCRunAsCredential = $Node.PSDSCRunAsCredential + } + } +} diff --git a/Tests/TestHelpers/CommonTestHelper.psm1 b/tests/TestHelpers/CommonTestHelper.psm1 similarity index 100% rename from Tests/TestHelpers/CommonTestHelper.psm1 rename to tests/TestHelpers/CommonTestHelper.psm1 diff --git a/Tests/Unit/MSFT_DFSNamespaceFolder.Tests.ps1 b/tests/Unit/DSC_DFSNamespaceFolder.Tests.ps1 similarity index 95% rename from Tests/Unit/MSFT_DFSNamespaceFolder.Tests.ps1 rename to tests/Unit/DSC_DFSNamespaceFolder.Tests.ps1 index 84b5748..3b73c12 100644 --- a/Tests/Unit/MSFT_DFSNamespaceFolder.Tests.ps1 +++ b/tests/Unit/DSC_DFSNamespaceFolder.Tests.ps1 @@ -1,22 +1,35 @@ -$script:DSCModuleName = 'DFSDsc' -$script:DSCResourceName = 'MSFT_DFSNamespaceFolder' +[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "")] +param () -#region HEADER -# Unit Test Template Version: 1.1.0 -[System.String] $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) +$script:dscModuleName = 'DFSDsc' +$script:dscResourceName = 'DSC_DFSNamespaceFolder' -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) +function Invoke-TestSetup { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) + try + { + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } + + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' + + Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') +} + +function Invoke-TestCleanup +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Unit -#endregion HEADER +Invoke-TestSetup # Begin Testing try @@ -50,8 +63,7 @@ try break } - #region Pester Tests - InModuleScope $script:DSCResourceName { + InModuleScope $script:dscResourceName { # Create the Mock Objects that will be used for running tests $namespace = [PSObject]@{ Path = '\\contoso.com\UnitTestNamespace\Folder' @@ -90,7 +102,7 @@ try TargetPath = $namespace.TargetPath } - Describe 'MSFT_DFSNamespaceFolder\Get-TargetResource' { + Describe 'DSC_DFSNamespaceFolder\Get-TargetResource' { Context 'Namespace Folder does not exist' { Mock Get-DFSNFolder Mock Get-DFSNFolderTarget @@ -155,7 +167,7 @@ try } } - Describe 'MSFT_DFSNamespaceFolder\Set-TargetResource' { + Describe 'DSC_DFSNamespaceFolder\Set-TargetResource' { Mock New-DFSNFolder Mock Set-DFSNFolder Mock New-DFSNFolderTarget @@ -413,7 +425,7 @@ try } } - Describe 'MSFT_DFSNamespaceFolder\Test-TargetResource' { + Describe 'DSC_DFSNamespaceFolder\Test-TargetResource' { Context 'Namespace Folder does not exist but should' { Mock Get-DFSNFolder Mock Get-DFSNFolderTarget @@ -588,7 +600,7 @@ try } } - Describe 'MSFT_DFSNamespaceFolder\Get-Folder' { + Describe 'DSC_DFSNamespaceFolder\Get-Folder' { Context 'DFSN Folder does not exist' { $errorId = 'Cannot get DFS folder properites on "{0}"' -f $namespaceFolder.Path $errorCategory = 'NotSpecified' @@ -629,7 +641,7 @@ try } } - Describe 'MSFT_DFSNamespaceFolder\Get-FolderTarget' { + Describe 'DSC_DFSNamespaceFolder\Get-FolderTarget' { Context 'DFSN Folder Target does not exist' { $errorId = 'Cannot get DFS target properites on "{0}"' -f $namespaceTarget.TargetPath $errorCategory = 'NotSpecified' @@ -672,11 +684,8 @@ try } } } - #endregion } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Invoke-TestCleanup } diff --git a/Tests/Unit/MSFT_DFSNamespaceRoot.Tests.ps1 b/tests/Unit/DSC_DFSNamespaceRoot.Tests.ps1 similarity index 96% rename from Tests/Unit/MSFT_DFSNamespaceRoot.Tests.ps1 rename to tests/Unit/DSC_DFSNamespaceRoot.Tests.ps1 index 3668fee..10cd119 100644 --- a/Tests/Unit/MSFT_DFSNamespaceRoot.Tests.ps1 +++ b/tests/Unit/DSC_DFSNamespaceRoot.Tests.ps1 @@ -1,24 +1,35 @@ -$script:DSCModuleName = 'DFSDsc' -$script:DSCResourceName = 'MSFT_DFSNamespaceRoot' +[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "")] +param () -Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global +$script:dscModuleName = 'DFSDsc' +$script:dscResourceName = 'DSC_DFSNamespaceRoot' -#region HEADER -# Unit Test Template Version: 1.1.0 -[System.String] $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) +function Invoke-TestSetup +{ + try + { + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } + + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' + + Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') +} -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) +function Invoke-TestCleanup { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Unit -#endregion HEADER +Invoke-TestSetup # Begin Testing try @@ -52,8 +63,7 @@ try break } - #region Pester Tests - InModuleScope $script:DSCResourceName { + InModuleScope $script:dscResourceName { # Create the Mock Objects that will be used for running tests $namespace = [PSObject]@{ Path = '\\contoso.com\UnitTestNamespace' @@ -101,7 +111,7 @@ try TargetPath = $namespace.TargetPath } - Describe 'MSFT_DFSNamespaceRoot\Get-TargetResource' { + Describe 'DSC_DFSNamespaceRoot\Get-TargetResource' { Context 'Namespace Root does not exist' { Mock Get-DFSNRoot Mock Get-DFSNRootTarget @@ -175,7 +185,7 @@ try } } - Describe 'MSFT_DFSNamespaceRoot\Set-TargetResource' { + Describe 'DSC_DFSNamespaceRoot\Set-TargetResource' { Mock New-DFSNRoot Mock Set-DFSNRoot Mock New-DfsnRootTarget @@ -502,7 +512,7 @@ try } } - Describe 'MSFT_DFSNamespaceRoot\Test-TargetResource' { + Describe 'DSC_DFSNamespaceRoot\Test-TargetResource' { Context 'Namespace Root does not exist but should' { Mock Get-DFSNRoot Mock Get-DFSNRootTarget @@ -745,7 +755,7 @@ try } } - Describe 'MSFT_DFSNamespaceRoot\Get-Root' { + Describe 'DSC_DFSNamespaceRoot\Get-Root' { Context 'DFSN Root does not exist' { $errorId = 'Cannot get DFS root properites on "{0}"' -f $namespaceRoot.Path $errorCategory = 'NotSpecified' @@ -784,7 +794,7 @@ try } } - Describe 'MSFT_DFSNamespaceRoot\Get-RootTarget' { + Describe 'DSC_DFSNamespaceRoot\Get-RootTarget' { Context 'DFSN Root Target does not exist' { $errorId = 'Cannot get DFS target properites on "{0}"' -f $namespaceTarget.TargetPath $errorCategory = 'NotSpecified' @@ -825,11 +835,8 @@ try } } } - #endregion } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Invoke-TestCleanup } diff --git a/Tests/Unit/MSFT_DFSNamespaceServerConfiguration.Tests.ps1 b/tests/Unit/DSC_DFSNamespaceServerConfiguration.Tests.ps1 similarity index 84% rename from Tests/Unit/MSFT_DFSNamespaceServerConfiguration.Tests.ps1 rename to tests/Unit/DSC_DFSNamespaceServerConfiguration.Tests.ps1 index 962ab87..1ee95fb 100644 --- a/Tests/Unit/MSFT_DFSNamespaceServerConfiguration.Tests.ps1 +++ b/tests/Unit/DSC_DFSNamespaceServerConfiguration.Tests.ps1 @@ -1,22 +1,35 @@ -$script:DSCModuleName = 'DFSDsc' -$script:DSCResourceName = 'MSFT_DFSNamespaceServerConfiguration' +[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "")] +param () -#region HEADER -# Unit Test Template Version: 1.1.0 -[System.String] $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) +$script:dscModuleName = 'DFSDsc' +$script:dscResourceName = 'DSC_DFSNamespaceServerConfiguration' -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) +function Invoke-TestSetup { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) + try + { + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } + + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' + + Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') +} + +function Invoke-TestCleanup +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Unit -#endregion HEADER +Invoke-TestSetup # Begin Testing try @@ -50,8 +63,7 @@ try break } - #region Pester Tests - InModuleScope $script:DSCResourceName { + InModuleScope $script:dscResourceName { # Create the Mock Objects that will be used for running tests $namespaceServerConfiguration = [PSObject]@{ LdapTimeoutSec = 45 @@ -66,7 +78,7 @@ try UseFQDN = $namespaceServerConfiguration.UseFQDN } - Describe 'MSFT_DFSNamespaceServerConfiguration\Get-TargetResource' { + Describe 'DSC_DFSNamespaceServerConfiguration\Get-TargetResource' { Context 'Namespace Server Configuration Exists' { Mock Get-DFSNServerConfiguration -MockWith { $namespaceServerConfiguration } @@ -83,7 +95,7 @@ try } } - Describe 'MSFT_DFSNamespaceServerConfiguration\Set-TargetResource' { + Describe 'DSC_DFSNamespaceServerConfiguration\Set-TargetResource' { Mock Get-DFSNServerConfiguration -MockWith { $namespaceServerConfiguration } Mock Set-DFSNServerConfiguration @@ -147,7 +159,7 @@ try } } - Describe 'MSFT_DFSNamespaceServerConfiguration\Test-TargetResource' { + Describe 'DSC_DFSNamespaceServerConfiguration\Test-TargetResource' { Mock Get-DFSNServerConfiguration -MockWith { $namespaceServerConfiguration } Context 'Namespace Server Configuration all parameters are the same' { @@ -198,11 +210,8 @@ try } } } - #endregion } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Invoke-TestCleanup } diff --git a/Tests/Unit/MSFT_DFSReplicationGroup.Tests.ps1 b/tests/Unit/DSC_DFSReplicationGroup.Tests.ps1 similarity index 97% rename from Tests/Unit/MSFT_DFSReplicationGroup.Tests.ps1 rename to tests/Unit/DSC_DFSReplicationGroup.Tests.ps1 index 69dc199..f1f887a 100644 --- a/Tests/Unit/MSFT_DFSReplicationGroup.Tests.ps1 +++ b/tests/Unit/DSC_DFSReplicationGroup.Tests.ps1 @@ -1,22 +1,35 @@ -$script:DSCModuleName = 'DFSDsc' -$script:DSCResourceName = 'MSFT_DFSReplicationGroup' +[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "")] +param () -#region HEADER -# Unit Test Template Version: 1.1.0 -[System.String] $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) +$script:dscModuleName = 'DFSDsc' +$script:dscResourceName = 'DSC_DFSReplicationGroup' -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) +function Invoke-TestSetup { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) + try + { + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } + + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' + + Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') } -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Unit -#endregion HEADER +function Invoke-TestCleanup +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} + +Invoke-TestSetup # Begin Testing try @@ -36,24 +49,10 @@ try break } - $featureInstalled = (Get-WindowsFeature -Name FS-DFS-Replication).Installed - Describe 'Environment' { - Context 'Windows Features' { - It 'Should have the DFS Replication Feature Installed' { - $featureInstalled | Should -Be $true - } - } - } - - if ($featureInstalled -eq $false) - { - break - } - - $featureInstalled = (Get-WindowsFeature -Name RSAT-DFS-Mgmt-Con).Installed + $featureInstalled = (Get-WindowsFeature -Name FS-DFS-Namespace).Installed Describe 'Environment' { Context 'Windows Features' { - It 'Should have the DFS Management Tools Feature Installed' { + It 'Should have the DFS Namespace Feature Installed' { $featureInstalled | Should -Be $true } } @@ -64,8 +63,7 @@ try break } - #region Pester Tests - InModuleScope $script:DSCResourceName { + InModuleScope $script:dscResourceName { # Create the Mock Objects that will be used for running tests $replicationGroup = [PSObject]@{ GroupName = 'Test Group' @@ -232,7 +230,7 @@ try $replicationGroupContentPath = $replicationGroup.Clone() $replicationGroupContentPath += @{ ContentPaths = @($mockReplicationGroupMembership.ContentPath) } - Describe 'MSFT_DFSReplicationGroup\Get-TargetResource' { + Describe 'DSC_DFSReplicationGroup\Get-TargetResource' { Context 'No replication groups exist' { Mock Get-DfsReplicationGroup Mock Get-DfsrMember @@ -291,7 +289,7 @@ try } } - Describe 'MSFT_DFSReplicationGroup\Set-TargetResource' { + Describe 'DSC_DFSReplicationGroup\Set-TargetResource' { Context 'Replication Group does not exist but should' { Mock Get-DfsReplicationGroup Mock New-DfsReplicationGroup @@ -945,7 +943,7 @@ try } } - Describe 'MSFT_DFSReplicationGroup\Test-TargetResource' { + Describe 'DSC_DFSReplicationGroup\Test-TargetResource' { Context 'Replication Group does not exist but should' { Mock Get-DfsReplicationGroup Mock Get-DfsrMember @@ -1373,7 +1371,7 @@ try } } - Describe 'MSFT_DFSReplicationGroup\Get-FQDNMemberName' { + Describe 'DSC_DFSReplicationGroup\Get-FQDNMemberName' { Context 'ComputerName passed includes Domain Name that matches DomainName' { It 'Should return correct FQDN' { $splat = @{ @@ -1426,11 +1424,8 @@ try } } } - #endregion } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Invoke-TestCleanup } diff --git a/Tests/Unit/MSFT_DFSReplicationGroupConnection.Tests.ps1 b/tests/Unit/DSC_DFSReplicationGroupConnection.Tests.ps1 similarity index 91% rename from Tests/Unit/MSFT_DFSReplicationGroupConnection.Tests.ps1 rename to tests/Unit/DSC_DFSReplicationGroupConnection.Tests.ps1 index 047d338..b0759ae 100644 --- a/Tests/Unit/MSFT_DFSReplicationGroupConnection.Tests.ps1 +++ b/tests/Unit/DSC_DFSReplicationGroupConnection.Tests.ps1 @@ -1,22 +1,35 @@ -$script:DSCModuleName = 'DFSDsc' -$script:DSCResourceName = 'MSFT_DFSReplicationGroupConnection' +[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "")] +param () -#region HEADER -# Unit Test Template Version: 1.1.0 -[System.String] $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) +$script:dscModuleName = 'DFSDsc' +$script:dscResourceName = 'DSC_DFSReplicationGroupConnection' -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) +function Invoke-TestSetup { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) + try + { + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } + + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' + + Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') } -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Unit -#endregion HEADER +function Invoke-TestCleanup +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} + +Invoke-TestSetup # Begin Testing try @@ -36,24 +49,10 @@ try break } - $featureInstalled = (Get-WindowsFeature -Name FS-DFS-Replication).Installed - Describe 'Environment' { - Context 'Windows Features' { - It 'Should have the DFS Replication Feature Installed' { - $featureInstalled | Should -Be $true - } - } - } - - if ($featureInstalled -eq $false) - { - break - } - - $featureInstalled = (Get-WindowsFeature -Name RSAT-DFS-Mgmt-Con).Installed + $featureInstalled = (Get-WindowsFeature -Name FS-DFS-Namespace).Installed Describe 'Environment' { Context 'Windows Features' { - It 'Should have the DFS Management Tools Feature Installed' { + It 'Should have the DFS Namespace Feature Installed' { $featureInstalled | Should -Be $true } } @@ -64,8 +63,7 @@ try break } - #region Pester Tests - InModuleScope $script:DSCResourceName { + InModuleScope $script:dscResourceName { # Create the Mock Objects that will be used for running tests $replicationGroup = [PSObject]@{ GroupName = 'Test Group' @@ -113,7 +111,7 @@ try DomainName = $replicationGroupConnections[0].DomainName } - Describe 'MSFT_DFSReplicationGroupConnection\Get-TargetResource' { + Describe 'DSC_DFSReplicationGroupConnection\Get-TargetResource' { Context 'No replication group connections exist' { Mock Get-DfsrConnection @@ -182,7 +180,7 @@ try } } - Describe 'MSFT_DFSReplicationGroupConnection\Set-TargetResource' { + Describe 'DSC_DFSReplicationGroupConnection\Set-TargetResource' { Context 'Replication Group connection does not exist but should' { Mock Get-DfsrConnection Mock Set-DfsrConnection @@ -360,7 +358,7 @@ try } } - Describe 'MSFT_DFSReplicationGroupConnection\Test-TargetResource' { + Describe 'DSC_DFSReplicationGroupConnection\Test-TargetResource' { Context 'Replication Group Connection does not exist but should' { Mock Get-DfsrConnection @@ -472,11 +470,8 @@ try } } } - #endregion } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Invoke-TestCleanup } diff --git a/Tests/Unit/MSFT_DFSReplicationGroupFolder.Tests.ps1 b/tests/Unit/DSC_DFSReplicationGroupFolder.Tests.ps1 similarity index 85% rename from Tests/Unit/MSFT_DFSReplicationGroupFolder.Tests.ps1 rename to tests/Unit/DSC_DFSReplicationGroupFolder.Tests.ps1 index f55c0f8..6d5717c 100644 --- a/Tests/Unit/MSFT_DFSReplicationGroupFolder.Tests.ps1 +++ b/tests/Unit/DSC_DFSReplicationGroupFolder.Tests.ps1 @@ -1,22 +1,35 @@ -$script:DSCModuleName = 'DFSDsc' -$script:DSCResourceName = 'MSFT_DFSReplicationGroupFolder' +[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "")] +param () -#region HEADER -# Unit Test Template Version: 1.1.0 -[System.String] $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) +$script:dscModuleName = 'DFSDsc' +$script:dscResourceName = 'DSC_DFSReplicationGroupFolder' -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) +function Invoke-TestSetup { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) + try + { + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } + + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' + + Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') } -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Unit -#endregion HEADER +function Invoke-TestCleanup +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} + +Invoke-TestSetup # Begin Testing try @@ -36,24 +49,10 @@ try break } - $featureInstalled = (Get-WindowsFeature -Name FS-DFS-Replication).Installed - Describe 'Environment' { - Context 'Windows Features' { - It 'Should have the DFS Replication Feature Installed' { - $featureInstalled | Should -Be $true - } - } - } - - if ($featureInstalled -eq $false) - { - break - } - - $featureInstalled = (Get-WindowsFeature -Name RSAT-DFS-Mgmt-Con).Installed + $featureInstalled = (Get-WindowsFeature -Name FS-DFS-Namespace).Installed Describe 'Environment' { Context 'Windows Features' { - It 'Should have the DFS Management Tools Feature Installed' { + It 'Should have the DFS Namespace Feature Installed' { $featureInstalled | Should -Be $true } } @@ -64,8 +63,7 @@ try break } - #region Pester Tests - InModuleScope $script:DSCResourceName { + InModuleScope $script:dscResourceName { # Create the Mock Objects that will be used for running tests $replicationGroup = [PSObject]@{ GroupName = 'Test Group' @@ -97,7 +95,7 @@ try } ) - Describe 'MSFT_DFSReplicationGroupFolder\Get-TargetResource' { + Describe 'DSC_DFSReplicationGroupFolder\Get-TargetResource' { Context 'Replication group folder does not exist' { Mock Get-DfsReplicatedFolder @@ -144,7 +142,7 @@ try } } - Describe 'MSFT_DFSReplicationGroupFolder\Set-TargetResource' { + Describe 'DSC_DFSReplicationGroupFolder\Set-TargetResource' { Context 'Replication group folder exists but has different Description' { Mock Set-DfsReplicatedFolder @@ -202,7 +200,7 @@ try } } - Describe 'MSFT_DFSReplicationGroupFolder\Test-TargetResource' { + Describe 'DSC_DFSReplicationGroupFolder\Test-TargetResource' { Context 'Replication group folder does not exist' { Mock Get-DfsReplicatedFolder @@ -289,11 +287,8 @@ try } } } - #endregion } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Invoke-TestCleanup } diff --git a/Tests/Unit/MSFT_DFSReplicationGroupMembership.Tests.ps1 b/tests/Unit/DSC_DFSReplicationGroupMembership.Tests.ps1 similarity index 90% rename from Tests/Unit/MSFT_DFSReplicationGroupMembership.Tests.ps1 rename to tests/Unit/DSC_DFSReplicationGroupMembership.Tests.ps1 index e83703a..35f2de6 100644 --- a/Tests/Unit/MSFT_DFSReplicationGroupMembership.Tests.ps1 +++ b/tests/Unit/DSC_DFSReplicationGroupMembership.Tests.ps1 @@ -1,22 +1,35 @@ -$script:DSCModuleName = 'DFSDsc' -$script:DSCResourceName = 'MSFT_DFSReplicationGroupMembership' +[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "")] +param () -#region HEADER -# Unit Test Template Version: 1.1.0 -[System.String] $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) +$script:dscModuleName = 'DFSDsc' +$script:dscResourceName = 'DSC_DFSReplicationGroupMembership' -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) +function Invoke-TestSetup { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) + try + { + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } + + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' + + Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') } -Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Unit -#endregion HEADER +function Invoke-TestCleanup +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} + +Invoke-TestSetup # Begin Testing try @@ -36,24 +49,10 @@ try break } - $featureInstalled = (Get-WindowsFeature -Name FS-DFS-Replication).Installed - Describe 'Environment' { - Context 'Windows Features' { - It 'Should have the DFS Replication Feature Installed' { - $featureInstalled | Should -Be $true - } - } - } - - if ($featureInstalled -eq $false) - { - break - } - - $featureInstalled = (Get-WindowsFeature -Name RSAT-DFS-Mgmt-Con).Installed + $featureInstalled = (Get-WindowsFeature -Name FS-DFS-Namespace).Installed Describe 'Environment' { Context 'Windows Features' { - It 'Should have the DFS Management Tools Feature Installed' { + It 'Should have the DFS Namespace Feature Installed' { $featureInstalled | Should -Be $true } } @@ -64,8 +63,7 @@ try break } - #region Pester Tests - InModuleScope $script:DSCResourceName { + InModuleScope $script:dscResourceName { # Create the Mock Objects that will be used for running tests $replicationGroup = [PSObject]@{ GroupName = 'Test Group' @@ -89,7 +87,7 @@ try PrimaryMember = $True } - Describe 'MSFT_DFSReplicationGroupMembership\Get-TargetResource' { + Describe 'DSC_DFSReplicationGroupMembership\Get-TargetResource' { Context 'Replication group folder does not exist' { Mock Get-DfsrMembership @@ -164,7 +162,7 @@ try } } - Describe 'MSFT_DFSReplicationGroupMembership\Set-TargetResource' { + Describe 'DSC_DFSReplicationGroupMembership\Set-TargetResource' { Context 'Replication group membership exists and has no differences' { Mock Set-DfsrMembership @@ -270,7 +268,7 @@ try } } - Describe 'MSFT_DFSReplicationGroupMembership\Test-TargetResource' { + Describe 'DSC_DFSReplicationGroupMembership\Test-TargetResource' { Context 'Replication group membership does not exist' { Mock Get-DfsrMembership @@ -394,11 +392,8 @@ try } } } - #endregion } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Invoke-TestCleanup }