diff --git a/.MetaTestOptIn.json b/.MetaTestOptIn.json deleted file mode 100644 index a5f60a34..00000000 --- a/.MetaTestOptIn.json +++ /dev/null @@ -1,13 +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", - "Common Tests - Validate Example Files To Be Published", - "Common Tests - Validate Markdown Links", - "Common Tests - Relative Path Length" -] diff --git a/.codecov.yml b/.codecov.yml deleted file mode 100644 index 411198f0..00000000 --- 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 index 37726ef1..9dbbd55b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,3 +2,9 @@ # 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 b03606ad..67f54dcd 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,10 @@ -DSCResource.Tests +*.suo +*.user +*.coverage +.vs +.vscode +.psproj +.sln +markdownissues.txt +output/ + diff --git a/.vscode/analyzersettings.psd1 b/.vscode/analyzersettings.psd1 index be415e4d..78312d2c 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 43f01cf9..a0606276 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 c6421e4b..dd77c775 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,31 @@ -# Versions +# Change log for FSRMDsc -## 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). +## [Unreleased] + +### Changed + +- Transferred ownership to DSCCommunity.org - Fixes [Issue #33](https://github.com/dsccommunity/FSRMDsc/issues/33). - Added .gitattributes file to fix bug publishing examples - Fixes [Issue #23](https://github.com/PlagueHO/FSRMDsc/issues/23). +- Combined all `FSRMDsc.ResourceHelper` module functions into + `FSRMDsc.Common` module and renamed to `FSRMDsc.CommonHelper` + module. +- Opted into Common Tests 'Common Tests - Validate Localization' - + fixes [Issue #82](https://github.com/PowerShell/FSRMDsc/issues/27). +- Minor style fixes to ensure new PSSA rules pass. +- Fix minor style issues in statement case. +- Fix minor style issues in hashtable layout. +- Updated to use the common module _DscResource.Common_ - Fixes [Issue #36](https://github.com/dsccommunity/FSRMDsc/issues/36). +- BREAKING CHANGE: Changed resource prefix from MSFT to DSC. +- Updated to use continuous delivery pattern using Azure DevOps - Fixes + [Issue #35](https://github.com/dsccommunity/FSRMDsc/issues/35). +- Updated build badges in README.MD. -## 2.4.1.0 +## [2.4.1] - 2017-12-04 + +### Changed - Enabled PSSA rule violations to fail build - Fixes [Issue #12](https://github.com/PlagueHO/FSRMDsc/issues/12). - Added Open Code of Conduct. @@ -20,7 +41,9 @@ - Common Tests - Relative Path Length - Update to new format LICENSE. -## 2.4.0.0 +## [2.4.0] - 2017-12-04 + +### Changed - Converted tests to meet Pester V4 standards. - Added restart to AppVeyor install step so that FSRM components @@ -40,7 +63,9 @@ - Fix bug comparing ReportTypes array in Test-TargetResource. - Fix blank verbose message in Get-TargetResource. -## 2.3.0.0 +## [2.3.0] - 2017-09-20 + +### Changed - Unit and Integration test headers updated to v1.1.0 - Converted AppVeyor.yml to pull Pester from PSGallery instead of Chocolatey. @@ -57,17 +82,23 @@ - Updated all integration tests to use v1.1.1 template format. - Fix bug with FSRMSettings when parameter being assigned it 0 or blank. -## 2.0.1.0 +## [2.0.1] - 2015-12-10 + +### Changed - Integration tests included for all resources. - DSR_xFSRMFileScreenAction: Fix to Get-TargetResource. - DSR_xFSRMQuotaAction: Fix to Get-TargetResource. - DSR_xFSRMQuotaActionTemplate: Fix to Get-TargetResource. -## 2.0.0.0 +## [2.0.0] - 2015-06-01 + +### Changed - Combined all FSRM Resources into this module. -## 1.0.0.0 +## [1.0.0] - 2015-01-01 + +### Changed - Initial release diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 2b2b4428..d7589ddb 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,133 +1,3 @@ -# Open Source Code of Conduct +# Code of Conduct -This code of conduct outlines our expectations for participants within this -DSC Resource Module community, as well as steps to reporting unacceptable behavior. -We are committed to providing a welcoming and inspiring community for all and expect -our code of conduct to be honored. Anyone who violates this code of conduct may be -banned from the community. - -Our open source communities strive to: - -- **Be friendly and patient.** -- **Be welcoming:** We strive to be a community that welcomes and supports people - of all backgrounds and identities. This includes, but is not limited to members - of any race, ethnicity, culture, national origin, colour, immigration status, - social and economic class, educational level, sex, sexual orientation, gender - identity and expression, age, size, family status, political belief, religion, - and mental and physical ability. -- **Be considerate:** Your work will be used by other people, and you in turn - will depend on the work of others. Any decision you take will affect users and - colleagues, and you should take those consequences into account when making - decisions. Remember that we're a world-wide community, so you might not be - communicating in someone else's primary language. -- **Be respectful:** Not all of us will agree all the time, but disagreement is - no excuse for poor behavior and poor manners. We might all experience some - frustration now and then, but we cannot allow that frustration to turn into a - personal attack. It's important to remember that a community where people feel - uncomfortable or threatened is not a productive one. -- **Be careful in the words that we choose:** we are a community of professionals, - and we conduct ourselves professionally. Be kind to others. Do not insult or - put down other participants. Harassment and other exclusionary behavior aren't - acceptable. -- **Try to understand why we disagree:** Disagreements, both social and technical, - happen all the time. It is important that we resolve disagreements and differing - views constructively. Remember that we're different. The strength of our community - comes from its diversity, people from a wide range of backgrounds. Different people - have different perspectives on issues. Being unable to understand why someone holds - a viewpoint doesn't mean that they're wrong. Don't forget that it is human to err - and blaming each other doesn't get us anywhere. Instead, focus on helping to resolve - issues and learning from mistakes. - -## Definitions - -Harassment includes, but is not limited to: - -- Offensive comments related to gender, gender identity and expression, sexual - orientation, disability, mental illness, neuro(a)typicality, physical appearance, - body size, race, age, regional discrimination, political or religious affiliation -- Unwelcome comments regarding a person's lifestyle choices and practices, - including those related to food, health, parenting, drugs, and employment -- Deliberate misgendering. This includes deadnaming or persistently using a - pronoun that does not correctly reflect a person's gender identity. You must - address people by the name they give you when not addressing them by their username - or handle -- Physical contact and simulated physical contact (eg, textual descriptions like - "hug" or "backrub") without consent or after a request to stop -- Threats of violence, both physical and psychological -- Incitement of violence towards any individual, including encouraging a person - to commit suicide or to engage in self-harm -- Deliberate intimidation -- Stalking or following -- Harassing photography or recording, including logging online activity for - harassment purposes -- Sustained disruption of discussion -- Unwelcome sexual attention, including gratuitous or off-topic sexual images or - behaviour -- Pattern of inappropriate social contact, such as requesting/assuming inappropriate - levels of intimacy with others -- Continued one-on-one communication after requests to cease -- Deliberate "outing" of any aspect of a person's identity without their consent - except as necessary to protect others from intentional abuse -- Publication of non-harassing private communication - -Our open source community prioritizes marginalized people's safety over privileged -people's comfort. We will not act on complaints regarding: - -- 'Reverse' -isms, including 'reverse racism,' 'reverse sexism,' and 'cisphobia' -- Reasonable communication of boundaries, such as "leave me alone," "go away," or - "I'm not discussing this with you" -- Refusal to explain or debate social justice concepts -- Communicating in a 'tone' you don't find congenial -- Criticizing racist, sexist, cissexist, or otherwise oppressive behavior or assumptions - -## Diversity Statement - -We encourage everyone to participate and are committed to building a community -for all. Although we will fail at times, we seek to treat everyone both as fairly -and equally as possible. Whenever a participant has made a mistake, we expect them -to take responsibility for it. If someone has been harmed or offended, it is our -responsibility to listen carefully and respectfully, and do our best to right the -wrong. - -Although this list cannot be exhaustive, we explicitly honor diversity in age, -gender, gender identity or expression, culture, ethnicity, language, national -origin, political beliefs, profession, race, religion, sexual orientation, socioeconomic -status, and technical ability. We will not tolerate discrimination based on any -of the protected characteristics above, including participants with disabilities. - -## Reporting Code of Conduct Issues - -If you experience or witness unacceptable behavior—or have any other concerns, -please report it by contacting us via [dscottraynsford@outlook.com](mailto:dscottraynsford@outlook.com). -All reports will be handled with discretion. - -In your report please include: - -- Your contact information. -- Names (real, usernames or pseudonyms) of any individuals involved. If there - are additional witnesses, please include them as well. -- Your account of what occurred, and if you believe the incident is ongoing. -- If there is a publicly available record (e.g. a mailing list archive or a - public chat log), please include a link or attachment. -- Any additional information that may be helpful. - -After filing a report, a representative will contact you personally, review the -incident, follow up with any additional questions, and make a decision as to how -to respond. If the person who is harassing you is part of the response team, they -will recuse themselves from handling your incident. If the complaint originates -from a member of the response team, it will be handled by a different member of -the response team. We will respect confidentiality requests for the purpose of -protecting victims of abuse. - -## Attribution & Acknowledgements - -We all stand on the shoulders of giants across many open source communities. -We’d like to thank the communities and projects that established code of conducts -and diversity statements as our inspiration: - -- [Django](https://www.djangoproject.com/conduct/reporting/) -- [Python](https://www.python.org/community/diversity/) -- [Ubuntu](http://www.ubuntu.com/about/about-ubuntu/conduct) -- [Contributor Covenant](http://contributor-covenant.org/) -- [Geek Feminism](http://geekfeminism.org/about/code-of-conduct/) -- [Citizen Code of Conduct](http://citizencodeofconduct.org/) +This project has adopted the [DSC Community Code of Conduct](https://dsccommunity.org/code_of_conduct). diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..3544bccb --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,7 @@ +# 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/FSRMDsc.psd1 b/FSRMDsc.psd1 deleted file mode 100644 index c42c7821..00000000 --- a/FSRMDsc.psd1 +++ /dev/null @@ -1,131 +0,0 @@ -@{ - -# Script module or binary module file associated with this manifest. -# RootModule = '' - -# Version number of this module. -ModuleVersion = '2.4.1.0' - -# ID used to uniquely identify this module -GUID = '5cda5979-ede4-4b49-9f77-2daa6f80eef2' - -# Author of this module -Author = 'Daniel Scott-Raynsford' - -# Company or vendor of this module -CompanyName = '' - -# Copyright statement for this module -Copyright = '(c) 2017 Daniel Scott-Raynsford. All rights reserved.' - -# Description of the functionality provided by this module -Description = 'DSC Resources for File Server Resource Manager configuration' - -# Minimum version of the Windows PowerShell engine required by this module -PowerShellVersion = '4.0' - -# Name of the Windows PowerShell host required by this module -# PowerShellHostName = '' - -# Minimum version of the Windows PowerShell host required by this module -# PowerShellHostVersion = '' - -# Minimum version of Microsoft .NET Framework required by this module -# DotNetFrameworkVersion = '' - -# Minimum version of the common language runtime (CLR) required by this module -CLRVersion = '4.0' - -# Processor architecture (None, X86, Amd64) required by this module -ProcessorArchitecture = 'None' - -# Modules that must be imported into the global environment prior to importing this module -# RequiredModules = @() - -# Assemblies that must be loaded prior to importing this module -RequiredAssemblies = @() - -# Script files (.ps1) that are run in the caller's environment prior to importing this module. -ScriptsToProcess = @() - -# Type files (.ps1xml) to be loaded when importing this module -TypesToProcess = @() - -# Format files (.ps1xml) to be loaded when importing this module -FormatsToProcess = @() - -# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess -# NestedModules = @() - -# Functions to export from this module -FunctionsToExport = @() - -# Cmdlets to export from this module -CmdletsToExport = @() - -# Variables to export from this module -VariablesToExport = @() - -# Aliases to export from this module -AliasesToExport = @() - -# DSC resources to export from this module -DscResourcesToExport = @( - 'FSRMSettings' - 'FSRMClassification' - 'FSRMClassificationProperty' - 'FSRMClassificationPropertyValue' - 'FSRMClassificationRule' - 'FSRMFileScreen' - 'FSRMFileScreenAction' - 'FSRMFileScreenTemplate' - 'FSRMFileScreenTemplateAction' - 'FSRMFileScreenException' - 'FSRMFileGroup' - 'FSRMQuota' - 'FSRMQuotaAction' - 'FSRMQuotaTemplate' - 'FSRMQuotaTemplateAction' - 'FSRMAutoQuota' -) - -# List of all modules packaged with this module -# ModuleList = @() - -# List of all files packaged with this module -FileList = @() - -# 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 = @{ - - PSData = @{ - - # Tags applied to this module. These help with module discovery in online galleries. - Tags = @( 'DSC','DesiredStateConfiguration','FSRM','FileServerResourceManager' ) - - # A URL to the license for this module. - LicenseUri = 'https://github.com/PlagueHO/FSRMDsc/blob/master/LICENSE' - - # A URL to the main website for this project. - ProjectUri = 'https://github.com/PlagueHO/FSRMDsc' - - # A URL to an icon representing this module. - # IconUri = '' - - # ReleaseNotes of this module - ReleaseNotes = 'Initial release of FSRMDsc in the DSC Resource Kit' - - # External dependent modules of this module - # ExternalModuleDependencies = '' - - } # End of PSData hashtable - - } # End of PrivateData hashtable - -# HelpInfo URI of this module -# HelpInfoURI = '' - -# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. -# DefaultCommandPrefix = '' - -} diff --git a/GitVersion.yml b/GitVersion.yml new file mode 100644 index 00000000..b42cc6d0 --- /dev/null +++ b/GitVersion.yml @@ -0,0 +1,26 @@ +mode: ContinuousDelivery +next-version: 2.4.1 +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 d03e93a4..be601b58 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) Daniel Scott-Raynsford. 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 diff --git a/Modules/FSRMDsc.ResourceHelper/FSRMDsc.ResourceHelper.psm1 b/Modules/FSRMDsc.ResourceHelper/FSRMDsc.ResourceHelper.psm1 deleted file mode 100644 index 02166967..00000000 --- a/Modules/FSRMDsc.ResourceHelper/FSRMDsc.ResourceHelper.psm1 +++ /dev/null @@ -1,178 +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. -#> -function Test-Command -{ - param - ( - [Parameter()] - [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()] - [String] - $Message, - - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [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()] - [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: DSR_xWindowsOptionalFeature - For Service: DSR_xServiceResource - For Registry: DSR_xRegistryResource - - .PARAMETER ResourcePath - The path the resource file is located in. -#> -function Get-LocalizedData -{ - [CmdletBinding()] - param - ( - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [String] - $ResourceName, - - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [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/PSScriptAnalyzerSettings.psd1 b/PSScriptAnalyzerSettings.psd1 deleted file mode 100644 index ba07a45a..00000000 --- a/PSScriptAnalyzerSettings.psd1 +++ /dev/null @@ -1,10 +0,0 @@ -@{ - ExcludeRules=@('PSDSCDscExamplesPresent', - 'PSDSCDscTestsPresent', - 'PSUseBOMForUnicodeEncodedFile', - 'PSUseShouldProcessForStateChangingFunctions', - 'PSUseSingularNouns', - 'PSUseToExportFieldsInManifest', - 'PSUseUTF8EncodingForHelpFile', - 'PSUseDeclaredVarsMoreThanAssignments') -} diff --git a/README.md b/README.md index 9d0abfeb..db338bf9 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,32 @@ # FSRMDsc +[![Build Status](https://dev.azure.com/dsccommunity/FSRMDsc/_apis/build/status/dsccommunity.FSRMDsc?branchName=master)](https://dev.azure.com/dsccommunity/FSRMDsc/_build/latest?definitionId=40&branchName=master) +![Code Coverage](https://img.shields.io/azure-devops/coverage/dsccommunity/FSRMDsc/40/master) +[![Azure DevOps tests](https://img.shields.io/azure-devops/tests/dsccommunity/FSRMDsc/40/master)](https://dsccommunity.visualstudio.com/FSRMDsc/_test/analytics?definitionId=40&contextType=build) +[![PowerShell Gallery (with prereleases)](https://img.shields.io/powershellgallery/vpre/FSRMDsc?label=FSRMDsc%20Preview)](https://www.powershellgallery.com/packages/FSRMDsc/) +[![PowerShell Gallery](https://img.shields.io/powershellgallery/v/FSRMDsc?label=FSRMDsc)](https://www.powershellgallery.com/packages/FSRMDsc/) + +## 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 **FSRMDsc** module contains DSC resources for configuring Windows File Server Resource Manager. @@ -27,33 +54,7 @@ Resource Manager. This project has adopted this [Open Source Code of Conduct](CODE_OF_CONDUCT.md). -This module should meet the [PowerShell DSC Resource Kit High Quality Resource -Module Guidelines](https://github.com/PowerShell/DscResources/blob/master/HighQualityModuleGuidelines.md). - ## Documentation and Examples For a full list of resources in FSRMDsc and examples on their use, check out -the [FSRMDsc wiki](https://github.com/PlagueHO/FSRMDsc/wiki). - -## Branches - -### master - -[![Build status](https://ci.appveyor.com/api/projects/status/9rjyjap2wl48xels/branch/master?svg=true)](https://ci.appveyor.com/project/PlagueHO/FSRMDsc/branch/master) -[![codecov](https://codecov.io/gh/PlagueHO/FSRMDsc/branch/master/graph/badge.svg)](https://codecov.io/gh/PlagueHO/FSRMDsc/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/9rjyjap2wl48xels/branch/dev?svg=true)](https://ci.appveyor.com/project/PlagueHO/FSRMDsc/branch/dev) -[![codecov](https://codecov.io/gh/PlagueHO/FSRMDsc/branch/dev/graph/badge.svg)](https://codecov.io/gh/PlagueHO/FSRMDsc/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/). - -## Contributing - -Please check out common DSC Resources [contributing guidelines](https://github.com/PowerShell/DscResource.Kit/blob/master/CONTRIBUTING.md). +the [FSRMDsc wiki](https://github.com/dsccommunity/FSRMDsc/wiki). diff --git a/RequiredModules.psd1 b/RequiredModules.psd1 new file mode 100644 index 00000000..2d31193f --- /dev/null +++ b/RequiredModules.psd1 @@ -0,0 +1,24 @@ +@{ + PSDependOptions = @{ + AddToPath = $true + Target = 'output\RequiredModules' + Parameters = @{ + Repository = '' + } + } + + InvokeBuild = 'latest' + PSScriptAnalyzer = 'latest' + Pester = '4.10.1' + Plaster = 'latest' + ModuleBuilder = 'latest' + ChangelogManagement = 'latest' + Sampler = 'latest' + MarkdownLinkCheck = 'latest' + 'DscResource.Test' = 'latest' + 'DscResource.AnalyzerRules' = 'latest' + 'DscResource.DocGenerator' = 'latest' + 'DscResource.Common' = 'latest' + xDscResourceDesigner = 'latest' + LoopbackAdapter = 'latest' +} diff --git a/Resolve-Dependency.ps1 b/Resolve-Dependency.ps1 new file mode 100644 index 00000000..ec909b88 --- /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 00000000..2ae8c0da --- /dev/null +++ b/Resolve-Dependency.psd1 @@ -0,0 +1,5 @@ +@{ + Gallery = 'PSGallery' + AllowPrerelease = $false + WithYAML = $true +} diff --git a/Tests/Integration/DSR_FSRMAutoQuota.Integration.Tests.ps1 b/Tests/Integration/DSR_FSRMAutoQuota.Integration.Tests.ps1 deleted file mode 100644 index 37e1118b..00000000 --- a/Tests/Integration/DSR_FSRMAutoQuota.Integration.Tests.ps1 +++ /dev/null @@ -1,67 +0,0 @@ -$script:DSCModuleName = 'FSRMDsc' -$script:DSCResourceName = 'DSR_FSRMAutoQuota' - -#region HEADER -# Integration Test Template Version: 1.1.1 -[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' { - { - & "$($script:DSCResourceName)_Config" -OutputPath $TestDrive - 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 - } - #endregion - - It 'Should have set the resource and all the parameters should match' { - # Get the AutoQuota details - $autoquotaNew = Get-FSRMAutoQuota -Path $autoquota.Path - $autoquota.Path | Should -Be $autoquotaNew.Path - $autoquota.Disabled | Should -Be $autoquotaNew.Disabled - $autoquota.Template | Should -Be $autoquotaNew.Template - } - - # Clean up - Remove-FSRMAutoQuota -Path $autoquota.path -Confirm:$false - } - #endregion -} -finally -{ - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion -} diff --git a/Tests/Integration/DSR_FSRMAutoQuota.config.ps1 b/Tests/Integration/DSR_FSRMAutoQuota.config.ps1 deleted file mode 100644 index 92262af0..00000000 --- a/Tests/Integration/DSR_FSRMAutoQuota.config.ps1 +++ /dev/null @@ -1,18 +0,0 @@ -$autoquota = @{ - Path = $ENV:Temp - Ensure = 'Present' - Disabled = $false - Template = (Get-FSRMQuotaTemplate | Select-Object -First 1).Name -} - -Configuration DSR_FSRMAutoQuota_Config { - Import-DscResource -ModuleName FSRMDsc - node localhost { - FSRMAutoQuota Integration_Test { - Path = $autoquota.Path - Ensure = $autoquota.Ensure - Disabled = $autoquota.Disabled - Template = $autoquota.Template - } - } -} diff --git a/Tests/Integration/DSR_FSRMClassification.Integration.Tests.ps1 b/Tests/Integration/DSR_FSRMClassification.Integration.Tests.ps1 deleted file mode 100644 index 24a233c6..00000000 --- a/Tests/Integration/DSR_FSRMClassification.Integration.Tests.ps1 +++ /dev/null @@ -1,75 +0,0 @@ -$script:DSCModuleName = 'FSRMDsc' -$script:DSCResourceName = 'DSR_FSRMClassification' - -#region HEADER -# Integration Test Template Version: 1.1.1 -[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" { - # Backup existing Classification - $classificationOld = Get-FSRMClassification - - #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 ` - -ErrorAction Stop - } | 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 Classification details - $classificationNew = Get-FSRMClassification - $classification.Continuous | Should -Be $classificationNew.Continuous - $classification.ContinuousLog | Should -Be $classificationNew.ContinuousLog - $classification.ContinuousLogSize | Should -Be $classificationNew.ContinuousLogSize - (Compare-Object ` - -ReferenceObject $classification.ExcludeNamespace ` - -DifferenceObject $classificationNew.ExcludeNamespace).Count | Should -Be 0 - (Compare-Object ` - -ReferenceObject $classification.ScheduleMonthly ` - -DifferenceObject $classificationNew.Schedule.Monthly).Count | Should -Be 0 - $classification.ScheduleRunDuration | Should -Be $classificationNew.Schedule.RunDuration - $classification.ScheduleTime | Should -Be $classificationNew.Schedule.Time - } - } - #endregion -} -finally -{ - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion -} diff --git a/Tests/Integration/DSR_FSRMClassification.config.ps1 b/Tests/Integration/DSR_FSRMClassification.config.ps1 deleted file mode 100644 index d129613e..00000000 --- a/Tests/Integration/DSR_FSRMClassification.config.ps1 +++ /dev/null @@ -1,26 +0,0 @@ -$classification = @{ - Id = 'Default' - Continuous = $false - ContinuousLog = $false - ContinuousLogSize = 2048 - ExcludeNamespace = @('[AllVolumes]\$Extend /','[AllVolumes]\System Volume Information /s') - ScheduleMonthly = @( 12,13 ) - ScheduleRunDuration = 10 - ScheduleTime = '13:00' -} - -Configuration DSR_FSRMClassification_Config { - Import-DscResource -ModuleName FSRMDsc - node localhost { - FSRMClassification Integration_Test { - Id = $classification.Id - Continuous = $classification.Continuous - ContinuousLog = $classification.ContinuousLog - ContinuousLogSize = $classification.ContinuousLogSize - ExcludeNamespace = $classification.ExcludeNamespace - ScheduleMonthly = $classification.ScheduleMonthly - ScheduleRunDuration = $classification.ScheduleRunDuration - ScheduleTime = $classification.ScheduleTime - } - } -} diff --git a/Tests/Integration/DSR_FSRMClassificationProperty.Integration.Tests.ps1 b/Tests/Integration/DSR_FSRMClassificationProperty.Integration.Tests.ps1 deleted file mode 100644 index 45bdbd02..00000000 --- a/Tests/Integration/DSR_FSRMClassificationProperty.Integration.Tests.ps1 +++ /dev/null @@ -1,76 +0,0 @@ -$script:DSCModuleName = 'FSRMDsc' -$script:DSCResourceName = 'DSR_FSRMClassificationProperty' - -#region HEADER -# Integration Test Template Version: 1.1.1 -[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' { - { - & "$($script:DSCResourceName)_Config" -OutputPath $TestDrive - 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 - } - #endregion - - It 'Should have set the resource and all the parameters should match' { - # Get the Classification Property details - $classificationPropertyNew = Get-FSRMClassificationPropertyDefinition -Name $classificationProperty.Name - $classificationProperty.Name | Should -Be $classificationPropertyNew.Name - $classificationProperty.DisplayName | Should -Be $classificationPropertyNew.DisplayName - $classificationProperty.Type | Should -Be $classificationPropertyNew.Type - $classificationProperty.Description | Should -Be $classificationPropertyNew.Description - (Compare-Object ` - -ReferenceObject $classificationProperty.PossibleValue ` - -DifferenceObject $classificationPropertyNew.PossibleValue.Name).Count | Should -Be 0 - (Compare-Object ` - -ReferenceObject $classificationProperty.Parameters ` - -DifferenceObject $classificationPropertyNew.Parameters).Count | Should -Be 0 - } - - # Clean up - Remove-FSRMClassificationPropertyDefinition ` - -Name $classificationProperty.Name ` - -Confirm:$false - } - #endregion -} -finally -{ - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion -} diff --git a/Tests/Integration/DSR_FSRMClassificationProperty.config.ps1 b/Tests/Integration/DSR_FSRMClassificationProperty.config.ps1 deleted file mode 100644 index dfca1236..00000000 --- a/Tests/Integration/DSR_FSRMClassificationProperty.config.ps1 +++ /dev/null @@ -1,24 +0,0 @@ -$classificationproperty = @{ - Name = 'IntegrationTest' - DisplayName = 'Integration Test' - Type = 'SingleChoice' - Ensure = 'Present' - Description = 'Integration Test Property' - PossibleValue = @( 'Value1', 'Value2', 'Value3' ) - Parameters = @( 'Parameter1=Value1', 'Parameter2=Value2') -} - -Configuration DSR_FSRMClassificationProperty_Config { - Import-DscResource -ModuleName FSRMDsc - node localhost { - FSRMClassificationProperty Integration_Test { - Name = $classificationproperty.Name - DisplayName = $classificationproperty.DisplayName - Type = $classificationproperty.Type - Ensure = $classificationproperty.Ensure - Description = $classificationproperty.Description - PossibleValue = $classificationproperty.PossibleValue - Parameters = $classificationproperty.Parameters - } - } -} diff --git a/Tests/Integration/DSR_FSRMClassificationPropertyValue.Integration.Tests.ps1 b/Tests/Integration/DSR_FSRMClassificationPropertyValue.Integration.Tests.ps1 deleted file mode 100644 index 3aed4039..00000000 --- a/Tests/Integration/DSR_FSRMClassificationPropertyValue.Integration.Tests.ps1 +++ /dev/null @@ -1,74 +0,0 @@ -$script:DSCModuleName = 'FSRMDsc' -$script:DSCResourceName = 'DSR_FSRMClassificationPropertyValue' - -#region HEADER -# Integration Test Template Version: 1.1.1 -[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 Classification Property that will be worked with - New-FSRMClassificationPropertyDefinition ` - -Name $classificationProperty.Name ` - -Type $classificationProperty.Type ` - -PossibleValue @(New-FSRMClassificationPropertyValue -Name 'None') - - #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 ` - -ErrorAction Stop - } | 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 Classification Property details - $classificationPropertyValueNew = Get-FSRMClassificationPropertyDefinition -Name $classificationProperty.Name - $classificationPropertyValue.Name | Should -Be $classificationPropertyValueNew.PossibleValue[1].Name - $classificationPropertyValue.Description | Should -Be $classificationPropertyValueNew.PossibleValue[1].Description - } - - # Clean up - Remove-FSRMClassificationPropertyDefinition ` - -Name $classificationProperty.Name ` - -Confirm:$false - } - #endregion -} -finally -{ - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion -} diff --git a/Tests/Integration/DSR_FSRMClassificationPropertyValue.config.ps1 b/Tests/Integration/DSR_FSRMClassificationPropertyValue.config.ps1 deleted file mode 100644 index efb5a09a..00000000 --- a/Tests/Integration/DSR_FSRMClassificationPropertyValue.config.ps1 +++ /dev/null @@ -1,21 +0,0 @@ -$classificationproperty = @{ - Name = 'IntegrationTest' - Type = 'SingleChoice' - PossibleValue = @( 'Value1' ) -} -$classificationPropertyValue = @{ - PropertyName = $classificationproperty.Name - Name = $classificationproperty.PossibleValue[0] - Description = 'Top Secret Description' -} - -Configuration DSR_FSRMClassificationPropertyValue_Config { - Import-DscResource -ModuleName FSRMDsc - node localhost { - FSRMClassificationPropertyValue Integration_Test { - Name = $classificationPropertyValue.Name - PropertyName = $classificationPropertyValue.PropertyName - Description = $classificationpropertyValue.Description - } - } -} diff --git a/Tests/Integration/DSR_FSRMClassificationRule.Tests.ps1 b/Tests/Integration/DSR_FSRMClassificationRule.Tests.ps1 deleted file mode 100644 index 9794250d..00000000 --- a/Tests/Integration/DSR_FSRMClassificationRule.Tests.ps1 +++ /dev/null @@ -1,88 +0,0 @@ -$script:DSCModuleName = 'FSRMDsc' -$script:DSCResourceName = 'DSR_FSRMclassificationRule' - -#region HEADER -# Integration Test Template Version: 1.1.1 -[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 Classification Property that will be worked with - New-FSRMClassificationPropertyDefinition ` - -Name $classificationProperty.Name ` - -Type $classificationProperty.Type ` - -PossibleValue @(New-FSRMClassificationPropertyValue -Name $classificationProperty.PossibleValue[0]) - - #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 ` - -ErrorAction Stop - } | 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 - $classificationRuleNew = Get-FSRMclassificationRule -Name $classificationRule.Name - $classificationRule.Name | Should -Be $classificationRuleNew.Name - $classificationRule.Description | Should -Be $classificationRuleNew.Description - $classificationRule.ClassificationMechanism | Should -Be $classificationRuleNew.ClassificationMechanism - $classificationRule.ContentRegularExpression | Should -Be $classificationRuleNew.ContentRegularExpression - $classificationRule.ContentString | Should -Be $classificationRuleNew.ContentString - $classificationRule.ContentStringCaseSensitive | Should -Be $classificationRuleNew.ContentStringCaseSensitive - $classificationRule.Disabled | Should -Be $classificationRuleNew.Disabled - $classificationRule.Flags | Should -Be $classificationRuleNew.Flags - $classificationRule.Namespace | Should -Be $classificationRuleNew.Namespace - $classificationRule.Parameters | Should -Be $classificationRuleNew.Parameters - $classificationRule.Property | Should -Be $classificationRuleNew.Property - $classificationRule.PropertyValue | Should -Be $classificationRuleNew.PropertyValue - $classificationRule.ReevaluateProperty | Should -Be $classificationRuleNew.ReevaluateProperty - } - - # Clean up - Remove-FSRMClassificationRule ` - -Name $classificationRule.Name ` - -Confirm:$false - Remove-FSRMClassificationPropertyDefinition ` - -Name $classificationProperty.Name ` - -Confirm:$false - } - #endregion -} -finally -{ - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion -} diff --git a/Tests/Integration/DSR_FSRMClassificationRule.config.ps1 b/Tests/Integration/DSR_FSRMClassificationRule.config.ps1 deleted file mode 100644 index 925a57db..00000000 --- a/Tests/Integration/DSR_FSRMClassificationRule.config.ps1 +++ /dev/null @@ -1,41 +0,0 @@ -$classificationProperty = @{ - Name = 'IntegrationTest' - Type = 'SingleChoice' - PossibleValue = @( 'Value1' ) -} -$classificationRule = @{ - Name = 'IntegrationTest' - Description = 'Test Rule Description' - ClassificationMechanism = 'Content Classifier' - ContentRegularExpression = @( 'Regex1','Regex2' ) - ContentString = @( 'String1','String2' ) - ContentStringCaseSensitive = @( 'String1','String2' ) - Disabled = $false - Flags = @( 1024 ) - Namespace = @( '[FolderUsage_MS=User Files]',$ENV:Temp ) - Parameters = @( 'FileName=*.doc','FSRMClearruleInternal=0','FSRMClearPropertyInternal=1024' ) - Property = $classificationProperty.Name - PropertyValue = $classificationProperty.PossibleValue[0] - ReevaluateProperty = 'Never' -} - -Configuration DSR_FSRMClassificationRule_Config { - Import-DscResource -ModuleName FSRMDsc - node localhost { - FSRMClassificationRule Integration_Test { - Name = $classificationRule.Name - Description = $classificationRule.Description - ClassificationMechanism = $classificationRule.ClassificationMechanism - ContentRegularExpression = $classificationRule.ContentRegularExpression - ContentString = $classificationRule.ContentString - ContentStringCaseSensitive = $classificationRule.ContentStringCaseSensitive - Disabled = $classificationRule.Disabled - Flags = $classificationRule.Flags - Namespace = $classificationRule.Namespace - Parameters = $classificationRule.Parameters - Property = $classificationRule.Property - PropertyValue = $classificationRule.PropertyValue - ReevaluateProperty = $classificationRule.ReevaluateProperty - } - } -} diff --git a/Tests/Integration/DSR_FSRMFileGroup.Integration.Tests.ps1 b/Tests/Integration/DSR_FSRMFileGroup.Integration.Tests.ps1 deleted file mode 100644 index 1177bc2d..00000000 --- a/Tests/Integration/DSR_FSRMFileGroup.Integration.Tests.ps1 +++ /dev/null @@ -1,70 +0,0 @@ -$script:DSCModuleName = 'FSRMDsc' -$script:DSCResourceName = 'DSR_FSRMFileGroup' - -#region HEADER -# Integration Test Template Version: 1.1.1 -[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' { - { - & "$($script:DSCResourceName)_Config" -OutputPath $TestDrive - 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 - } - #endregion - - It 'Should have set the resource and all the parameters should match' { - # Get the Rule details - $filegroupNew = Get-FSRMFileGroup -Name $filegroup.Name - $filegroup.Name | Should -Be $filegroupNew.Name - $filegroup.Description | Should -Be $filegroupNew.Description - $filegroup.IncludePattern | Should -Be $filegroupNew.IncludePattern - $filegroup.ExcludePattern | Should -Be $filegroupNew.ExcludePattern - } - - # Clean up - Remove-FSRMFileGroup ` - -Name $filegroup.Name ` - -Confirm:$false - } - #endregion -} -finally -{ - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion -} diff --git a/Tests/Integration/DSR_FSRMFileScreen.Integration.Tests.ps1 b/Tests/Integration/DSR_FSRMFileScreen.Integration.Tests.ps1 deleted file mode 100644 index ce54552e..00000000 --- a/Tests/Integration/DSR_FSRMFileScreen.Integration.Tests.ps1 +++ /dev/null @@ -1,72 +0,0 @@ -$script:DSCModuleName = 'FSRMDsc' -$script:DSCResourceName = 'DSR_FSRMFileScreen' - -#region HEADER -# Integration Test Template Version: 1.1.1 -[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' { - { - & "$($script:DSCResourceName)_Config" -OutputPath $TestDrive - 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 - } - #endregion - - It 'Should have set the resource and all the parameters should match' { - # Get the Rule details - $fileScreenNew = Get-FSRMFileScreen -Path $fileScreen.Path - $fileScreen.Path | Should -Be $fileScreenNew.Path - $fileScreen.Description | Should -Be $fileScreenNew.Description - $fileScreen.Active | Should -Be $fileScreenNew.Active - $fileScreen.IncludeGroup | Should -Be $fileScreenNew.IncludeGroup - $fileScreen.Template | Should -Be $fileScreenNew.Template - $fileScreen.MatchesTemplate | Should -Be $fileScreenNew.MatchesTemplate - } - - # Clean up - Remove-FSRMFileScreen ` - -Path $fileScreen.Path ` - -Confirm:$false - } - #endregion -} -finally -{ - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion -} diff --git a/Tests/Integration/DSR_FSRMFileScreenAction.Integration.Tests.ps1 b/Tests/Integration/DSR_FSRMFileScreenAction.Integration.Tests.ps1 deleted file mode 100644 index 1e5994f5..00000000 --- a/Tests/Integration/DSR_FSRMFileScreenAction.Integration.Tests.ps1 +++ /dev/null @@ -1,79 +0,0 @@ -$script:DSCModuleName = 'FSRMDsc' -$script:DSCResourceName = 'DSR_FSRMFileScreenAction' - -#region HEADER -# Integration Test Template Version: 1.1.1 -[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 File Screen that will be worked with - New-FSRMFileScreen ` - -Path $fileScreen.Path ` - -Description $fileScreen.Description ` - -IncludeGroup $fileScreen.IncludeGroup ` - -Template $fileScreen.Template - - #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 ` - -ErrorAction Stop - } | 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 - $fileScreenNew = Get-FSRMFileScreen -Path $fileScreen.Path - $fileScreenNew.Notification[1].Type | Should -Be $fileScreenAction.Type - $fileScreenNew.Notification[1].Subject | Should -Be $fileScreenAction.Subject - $fileScreenNew.Notification[1].Body | Should -Be $fileScreenAction.Body - $fileScreenNew.Notification[1].MailBCC | Should -Be $fileScreenAction.MailBCC - $fileScreenNew.Notification[1].MailCC | Should -Be $fileScreenAction.MailCC - $fileScreenNew.Notification[1].MailTo | Should -Be $fileScreenAction.MailTo - } - - # Clean up - Remove-FSRMFileScreen ` - -Path $fileScreen.Path ` - -Confirm:$false - } - #endregion -} -finally -{ - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion -} diff --git a/Tests/Integration/DSR_FSRMFileScreenException.Integration.Tests.ps1 b/Tests/Integration/DSR_FSRMFileScreenException.Integration.Tests.ps1 deleted file mode 100644 index be0a85df..00000000 --- a/Tests/Integration/DSR_FSRMFileScreenException.Integration.Tests.ps1 +++ /dev/null @@ -1,79 +0,0 @@ -$script:DSCModuleName = 'FSRMDsc' -$script:DSCResourceName = 'DSR_FSRMFileScreenException' - -#region HEADER -# Integration Test Template Version: 1.1.1 -[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 File Screen that will be worked with - New-FSRMFileScreen ` - -Path $fileScreen.Path ` - -Description $fileScreen.Description ` - -IncludeGroup $fileScreen.IncludeGroup ` - -Template $fileScreen.Template - - #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 ` - -ErrorAction Stop - } | 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 - $fileScreenExceptionNew = Get-FSRMFileScreenException -Path $fileScreenException.Path - $fileScreenException.Path | Should -Be $fileScreenExceptionNew.Path - $fileScreenException.Description | Should -Be $fileScreenExceptionNew.Description - $fileScreenException.IncludeGroup | Should -Be $fileScreenExceptionNew.IncludeGroup - } - - # Clean up - Remove-FSRMFileScreenException ` - -Path $fileScreenException.Path ` - -Confirm:$false - Remove-FSRMFileScreen ` - -Path $fileScreen.Path ` - -Confirm:$false - } - #endregion -} -finally -{ - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion -} diff --git a/Tests/Integration/DSR_FSRMFileScreenTemplate.Integration.Tests.ps1 b/Tests/Integration/DSR_FSRMFileScreenTemplate.Integration.Tests.ps1 deleted file mode 100644 index c3dca7ef..00000000 --- a/Tests/Integration/DSR_FSRMFileScreenTemplate.Integration.Tests.ps1 +++ /dev/null @@ -1,70 +0,0 @@ -$script:DSCModuleName = 'FSRMDsc' -$script:DSCResourceName = 'DSR_FSRMFileScreenTemplate' - -#region HEADER -# Integration Test Template Version: 1.1.1 -[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' { - { - & "$($script:DSCResourceName)_Config" -OutputPath $TestDrive - 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 - } - #endregion - - It 'Should have set the resource and all the parameters should match' { - # Get the Rule details - $fileScreenTemplateNew = Get-FSRMFileScreenTemplate -Name $fileScreenTemplate.Name - $fileScreenTemplate.Name | Should -Be $fileScreenTemplateNew.Name - $fileScreenTemplate.Description | Should -Be $fileScreenTemplateNew.Description - $fileScreenTemplate.Active | Should -Be $fileScreenTemplateNew.Active - $fileScreenTemplate.IncludeGroup | Should -Be $fileScreenTemplateNew.IncludeGroup - } - - # Clean up - Remove-FSRMFileScreenTemplate ` - -Name $fileScreenTemplate.Name ` - -Confirm:$false - } - #endregion -} -finally -{ - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion -} diff --git a/Tests/Integration/DSR_FSRMFileScreenTemplateAction.Integration.Tests.ps1 b/Tests/Integration/DSR_FSRMFileScreenTemplateAction.Integration.Tests.ps1 deleted file mode 100644 index e2686565..00000000 --- a/Tests/Integration/DSR_FSRMFileScreenTemplateAction.Integration.Tests.ps1 +++ /dev/null @@ -1,78 +0,0 @@ -$script:DSCModuleName = 'FSRMDsc' -$script:DSCResourceName = 'DSR_FSRMFileScreenTemplateAction' - -#region HEADER -# Integration Test Template Version: 1.1.1 -[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 File Screen that will be worked with - New-FSRMFileScreenTemplate ` - -Name $fileScreenTemplate.Name ` - -Description $fileScreenTemplate.Description ` - -IncludeGroup $fileScreenTemplate.IncludeGroup - - #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 ` - -ErrorAction Stop - } | 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 - $fileScreenTemplateNew = Get-FSRMFileScreenTemplate -Name $fileScreenTemplate.Name - $fileScreenTemplateNew.Notification[0].Type | Should -Be $fileScreenTemplateAction.Type - $fileScreenTemplateNew.Notification[0].Subject | Should -Be $fileScreenTemplateAction.Subject - $fileScreenTemplateNew.Notification[0].Body | Should -Be $fileScreenTemplateAction.Body - $fileScreenTemplateNew.Notification[0].MailBCC | Should -Be $fileScreenTemplateAction.MailBCC - $fileScreenTemplateNew.Notification[0].MailCC | Should -Be $fileScreenTemplateAction.MailCC - $fileScreenTemplateNew.Notification[0].MailTo | Should -Be $fileScreenTemplateAction.MailTo - } - - # Clean up - Remove-FSRMFileScreenTemplate ` - -Name $fileScreenTemplate.Name ` - -Confirm:$false - } - #endregion -} -finally -{ - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion -} diff --git a/Tests/Integration/DSR_FSRMQuota.Integration.Tests.ps1 b/Tests/Integration/DSR_FSRMQuota.Integration.Tests.ps1 deleted file mode 100644 index 083b2bd8..00000000 --- a/Tests/Integration/DSR_FSRMQuota.Integration.Tests.ps1 +++ /dev/null @@ -1,74 +0,0 @@ -$script:DSCModuleName = 'FSRMDsc' -$script:DSCResourceName = 'DSR_FSRMQuota' - -#region HEADER -# Integration Test Template Version: 1.1.1 -[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' { - { - & "$($script:DSCResourceName)_Config" -OutputPath $TestDrive - 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 - } - #endregion - - It 'Should have set the resource and all the parameters should match' { - # Get the Rule details - $quotaNew = Get-FSRMQuota -Path $quota.Path - $quota.Path | Should -Be $quotaNew.Path - $quota.Description | Should -Be $quotaNew.Description - $quota.Size | Should -Be $quotaNew.Size - $quota.SoftLimit | Should -Be $quotaNew.SoftLimit - (Compare-Object ` - -ReferenceObject $quota.ThresholdPercentages ` - -DifferenceObject $quotaNew.Threshold.Percentage).Count | Should -Be 0 - $quota.Disabled | Should -Be $quotaNew.Disabled - } - - # Clean up - Remove-FSRMQuota ` - -Path $quota.Path ` - -Confirm:$false - } - #endregion -} -finally -{ - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion -} diff --git a/Tests/Integration/DSR_FSRMQuotaAction.Integration.Tests.ps1 b/Tests/Integration/DSR_FSRMQuotaAction.Integration.Tests.ps1 deleted file mode 100644 index 50f73fe6..00000000 --- a/Tests/Integration/DSR_FSRMQuotaAction.Integration.Tests.ps1 +++ /dev/null @@ -1,79 +0,0 @@ -$script:DSCModuleName = 'FSRMDsc' -$script:DSCResourceName = 'DSR_FSRMQuotaAction' - -#region HEADER -# Integration Test Template Version: 1.1.1 -[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 File Screen that will be worked with - New-FSRMQuota ` - -Path $quota.Path ` - -Description $quota.Description ` - -Size $quota.Size ` - -Threshold (New-FSRMQuotaThreshold -Percentage $quota.ThresholdPercentages[0]) - - #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 ` - -ErrorAction Stop - } | 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 - $quotaNew = Get-FSRMQuota -Path $quota.Path - $quotaNew.Threshold[0].Action[0].Type | Should -Be $quotaAction.Type - $quotaNew.Threshold[0].Action[0].Subject | Should -Be $quotaAction.Subject - $quotaNew.Threshold[0].Action[0].Body | Should -Be $quotaAction.Body - $quotaNew.Threshold[0].Action[0].MailBCC | Should -Be $quotaAction.MailBCC - $quotaNew.Threshold[0].Action[0].MailCC | Should -Be $quotaAction.MailCC - $quotaNew.Threshold[0].Action[0].MailTo | Should -Be $quotaAction.MailTo - } - - # Clean up - Remove-FSRMQuota ` - -Path $quota.Path ` - -Confirm:$false - } - #endregion -} -finally -{ - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion -} diff --git a/Tests/Integration/DSR_FSRMQuotaTemplate.Integration.Tests.ps1 b/Tests/Integration/DSR_FSRMQuotaTemplate.Integration.Tests.ps1 deleted file mode 100644 index 853ccc7c..00000000 --- a/Tests/Integration/DSR_FSRMQuotaTemplate.Integration.Tests.ps1 +++ /dev/null @@ -1,73 +0,0 @@ -$script:DSCModuleName = 'FSRMDsc' -$script:DSCResourceName = 'DSR_FSRMQuotaTemplate' - -#region HEADER -# Integration Test Template Version: 1.1.1 -[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' { - { - & "$($script:DSCResourceName)_Config" -OutputPath $TestDrive - 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 - } - #endregion - - It 'Should have set the resource and all the parameters should match' { - # Get the Rule details - $quotaTemplateNew = Get-FSRMQuotaTemplate -Name $quotaTemplate.Name - $quotaTemplate.Name | Should -Be $quotaTemplateNew.Name - $quotaTemplate.Description | Should -Be $quotaTemplateNew.Description - $quotaTemplate.Size | Should -Be $quotaTemplateNew.Size - $quotaTemplate.SoftLimit | Should -Be $quotaTemplateNew.SoftLimit - (Compare-Object ` - -ReferenceObject $quotaTemplate.ThresholdPercentages ` - -DifferenceObject $quotaTemplateNew.Threshold.Percentage).Count | Should -Be 0 - } - - # Clean up - Remove-FSRMQuotaTemplate ` - -Name $quotaTemplate.Name ` - -Confirm:$false - } - #endregion -} -finally -{ - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion -} diff --git a/Tests/Integration/DSR_FSRMQuotaTemplateAction.Integration.Tests.ps1 b/Tests/Integration/DSR_FSRMQuotaTemplateAction.Integration.Tests.ps1 deleted file mode 100644 index 9404619c..00000000 --- a/Tests/Integration/DSR_FSRMQuotaTemplateAction.Integration.Tests.ps1 +++ /dev/null @@ -1,79 +0,0 @@ -$script:DSCModuleName = 'FSRMDsc' -$script:DSCResourceName = 'DSR_FSRMQuotaTemplateAction' - -#region HEADER -# Integration Test Template Version: 1.1.1 -[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 File Screen that will be worked with - New-FSRMQuotaTemplate ` - -Name $quotaTemplate.Name ` - -Description $quotaTemplate.Description ` - -Size $quotaTemplate.Size ` - -Threshold (New-FSRMQuotaThreshold -Percentage $quotaTemplate.ThresholdPercentages[0]) - - #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 ` - -ErrorAction Stop - } | 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 - $quotaTemplateNew = Get-FSRMQuotaTemplate -Name $quotaTemplate.Name - $quotaTemplateNew.Threshold[0].Action[0].Type | Should -Be $quotaAction.Type - $quotaTemplateNew.Threshold[0].Action[0].Subject | Should -Be $quotaAction.Subject - $quotaTemplateNew.Threshold[0].Action[0].Body | Should -Be $quotaAction.Body - $quotaTemplateNew.Threshold[0].Action[0].MailBCC | Should -Be $quotaAction.MailBCC - $quotaTemplateNew.Threshold[0].Action[0].MailCC | Should -Be $quotaAction.MailCC - $quotaTemplateNew.Threshold[0].Action[0].MailTo | Should -Be $quotaAction.MailTo - } - - # Clean up - Remove-FSRMQuotaTemplate ` - -Name $quotaTemplate.Name ` - -Confirm:$false - } - #endregion -} -finally -{ - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion -} diff --git a/Tests/Integration/DSR_FSRMSettings.Integration.Tests.ps1 b/Tests/Integration/DSR_FSRMSettings.Integration.Tests.ps1 deleted file mode 100644 index c73d7a4e..00000000 --- a/Tests/Integration/DSR_FSRMSettings.Integration.Tests.ps1 +++ /dev/null @@ -1,70 +0,0 @@ -$script:DSCModuleName = 'FSRMDsc' -$script:DSCResourceName = 'DSR_FSRMSettings' - -#region HEADER -# Integration Test Template Version: 1.1.1 -[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" { - # Backup existing Settings - $settingsOld = Get-FSRMSetting - - #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 ` - -ErrorAction Stop - } | 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 - $settingsNew = Get-FSRMSetting - $settings.SmtpServer | Should -Be $settingsNew.SmtpServer - $settings.AdminEmailAddress | Should -Be $settingsNew.AdminEmailAddress - $settings.FromEmailAddress | Should -Be $settingsNew.FromEmailAddress - $settings.CommandNotificationLimit | Should -Be $settingsNew.CommandNotificationLimit - $settings.EmailNotificationLimit | Should -Be $settingsNew.EmailNotificationLimit - $settings.EventNotificationLimit | Should -Be $settingsNew.EventNotificationLimit - } - } - #endregion -} -finally -{ - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion -} diff --git a/Tests/Integration/DSR_FSRMSettings.config.ps1 b/Tests/Integration/DSR_FSRMSettings.config.ps1 deleted file mode 100644 index 4538825b..00000000 --- a/Tests/Integration/DSR_FSRMSettings.config.ps1 +++ /dev/null @@ -1,24 +0,0 @@ -$settings = @{ - IsSingleInstance = 'Yes' - SmtpServer = 'smtp.contoso.com' - AdminEmailAddress = 'admin@contoso.com' - FromEmailAddress = 'fsrm@contoso.com' - CommandNotificationLimit = 10 - EmailNotificationLimit = 20 - EventNotificationLimit = 30 -} - -Configuration DSR_FSRMSettings_Config { - Import-DscResource -ModuleName FSRMDsc - node localhost { - FSRMSettings Integration_Test { - IsSingleInstance = $settings.IsSingleInstance - SmtpServer = $settings.SmtpServer - AdminEmailAddress = $settings.AdminEmailAddress - FromEmailAddress = $settings.FromEmailAddress - CommandNotificationLimit = $settings.CommandNotificationLimit - EmailNotificationLimit = $settings.EmailNotificationLimit - EventNotificationLimit = $settings.EventNotificationLimit - } - } -} diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 8bf8b6ad..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,50 +0,0 @@ -#---------------------------------# -# environment configuration # -#---------------------------------# -version: 2.4.1.{build} -image: Visual Studio 2017 -install: - - git clone https://github.com/PowerShell/DscResource.Tests - - - ps: | - $moduleName = 'FSRMDsc' - $mainModuleFolder = "Modules\$moduleName" - Import-Module "$env:APPVEYOR_BUILD_FOLDER\DscResource.Tests\AppVeyor.psm1" - Invoke-AppveyorInstallTask - Install-WindowsFeature -Name fs-resource-manager - Restart-Computer -Force - Start-Sleep -s 10 - -#---------------------------------# -# build configuration # -#---------------------------------# - -build: false - -#---------------------------------# -# test configuration # -#---------------------------------# - -test_script: - - ps: | - # Reinitialize after restart - $moduleName = 'FSRMDsc' - $mainModuleFolder = "Modules\$moduleName" - Import-Module "$env:APPVEYOR_BUILD_FOLDER\DscResource.Tests\AppVeyor.psm1" - - 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 00000000..e6b920c3 --- /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: installFSRMFeatures + displayName: 'Install FSRM Features' + inputs: + targetType: 'inline' + script: 'Install-WindowsFeature -Name fs-resource-manager' + 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: installFSRMFeatures + displayName: 'Install FSRM Features' + inputs: + targetType: 'inline' + script: 'Install-WindowsFeature -Name fs-resource-manager' + 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: installFSRMFeatures + displayName: 'Install FSRM Features' + inputs: + targetType: 'inline' + script: 'Install-WindowsFeature -Name fs-resource-manager' + 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: installFSRMFeatures + displayName: 'Install FSRM Features' + inputs: + targetType: 'inline' + script: 'Install-WindowsFeature -Name fs-resource-manager' + 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 00000000..4630cb82 --- /dev/null +++ b/build.ps1 @@ -0,0 +1,381 @@ +<# + +.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 00000000..3c625dc4 --- /dev/null +++ b/build.yaml @@ -0,0 +1,103 @@ +--- +#################################################### +# ModuleBuilder Configuration # +#################################################### +CopyPaths: + - en-US + - DSCResources +Encoding: UTF8 +VersionedOutputDirectory: true + +#################################################### +# ModuleBuilder Dependent Modules Configuration # +#################################################### + +NestedModule: + DscResource.Common: + CopyOnly: true + Path: ./output/RequiredModules/DscResource.Common + AddToManifest: false + Exclude: PSGetModuleInfo.xml + +#################################################### +# 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: + - Modules/DscResource.Common + Script: + - tests/Unit + ExcludeTag: + Tag: + CodeCoverageThreshold: 70 + +DscTest: + OutputFormat: NUnitXML + ExcludeTag: + - 'Common Tests - New Error-Level Script Analyzer Rules' + ExcludeSourceFile: + - output + ExcludeModuleFile: + - Modules/DscResource.Common + +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 00000000..3b7ba7c6 --- /dev/null +++ b/source/Build.psd1 @@ -0,0 +1,5 @@ +@{ + Path = 'FSRMDsc.psd1' +} +# Waiting for ModuleBuilder to do away with this file +# when all parameters are provided to the function diff --git a/DSCResources/DSR_FSRMAutoQuota/DSR_FSRMAutoQuota.psm1 b/source/DSCResources/DSC_FSRMAutoQuota/DSC_FSRMAutoQuota.psm1 similarity index 84% rename from DSCResources/DSR_FSRMAutoQuota/DSR_FSRMAutoQuota.psm1 rename to source/DSCResources/DSC_FSRMAutoQuota/DSC_FSRMAutoQuota.psm1 index 9acbf06f..ef8e9874 100644 --- a/DSCResources/DSR_FSRMAutoQuota/DSR_FSRMAutoQuota.psm1 +++ b/source/DSCResources/DSC_FSRMAutoQuota/DSC_FSRMAutoQuota.psm1 @@ -1,14 +1,9 @@ $modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules' -# Import the Networking Resource Helper Module -Import-Module -Name (Join-Path -Path $modulePath ` - -ChildPath (Join-Path -Path 'FSRMDsc.ResourceHelper' ` - -ChildPath 'FSRMDsc.ResourceHelper.psm1')) +Import-Module -Name (Join-Path -Path $modulePath -ChildPath 'DscResource.Common') # Import Localization Strings -$LocalizedData = Get-LocalizedData ` - -ResourceName 'DSR_FSRMAutoQuota' ` - -ResourcePath (Split-Path -Parent $Script:MyInvocation.MyCommand.Path) +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS @@ -30,7 +25,7 @@ function Get-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.GettingAutoQuotaMessage) ` + $($script:localizedData.GettingAutoQuotaMessage) ` -f $Path ) -join '' ) @@ -45,7 +40,7 @@ function Get-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.AutoQuotaExistsMessage) ` + $($script:localizedData.AutoQuotaExistsMessage) ` -f $Path ) -join '' ) @@ -59,7 +54,7 @@ function Get-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.AutoQuotaDoesNotExistMessage) ` + $($script:localizedData.AutoQuotaDoesNotExistMessage) ` -f $Path ) -join '' ) @@ -113,7 +108,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.SettingAutoQuotaMessage) ` + $($script:localizedData.SettingAutoQuotaMessage) ` -f $Path ) -join '' ) @@ -130,7 +125,7 @@ function Set-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.EnsureAutoQuotaExistsMessage) ` + $($script:localizedData.EnsureAutoQuotaExistsMessage) ` -f $Path ) -join '' ) @@ -142,7 +137,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.AutoQuotaUpdatedMessage) ` + $($script:localizedData.AutoQuotaUpdatedMessage) ` -f $Path ) -join '' ) } @@ -154,7 +149,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.AutoQuotaCreatedMessage) ` + $($script:localizedData.AutoQuotaCreatedMessage) ` -f $Path ) -join '' ) } @@ -163,7 +158,7 @@ function Set-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.EnsureAutoQuotaDoesNotExistMessage) ` + $($script:localizedData.EnsureAutoQuotaDoesNotExistMessage) ` -f $Path ) -join '' ) @@ -174,7 +169,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.AutoQuotaRemovedMessage) ` + $($script:localizedData.AutoQuotaRemovedMessage) ` -f $Path ) -join '' ) } # if @@ -222,11 +217,11 @@ function Test-TargetResource ) # Flag to signal whether settings are correct - [Boolean] $desiredConfigurationMatch = $true + $desiredConfigurationMatch = $true Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.TestingAutoQuotaMessage) ` + $($script:localizedData.TestingAutoQuotaMessage) ` -f $Path ) -join '' ) @@ -247,7 +242,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.AutoQuotaPropertyNeedsUpdateMessage) ` + $($script:localizedData.AutoQuotaPropertyNeedsUpdateMessage) ` -f $Path, 'Disabled' ) -join '' ) @@ -259,7 +254,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.AutoQuotaPropertyNeedsUpdateMessage) ` + $($script:localizedData.AutoQuotaPropertyNeedsUpdateMessage) ` -f $Path, 'Template' ) -join '' ) @@ -271,7 +266,7 @@ function Test-TargetResource # Ths Auto Quota doesn't exist but should Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.AutoQuotaDoesNotExistButShouldMessage) ` + $($script:localizedData.AutoQuotaDoesNotExistButShouldMessage) ` -f $Path ) -join '' ) @@ -286,7 +281,7 @@ function Test-TargetResource # The Auto Quota exists but should not Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.AutoQuotaExistsButShouldNotMessage) ` + $($script:localizedData.AutoQuotaExistsButShouldNotMessage) ` -f $Path ) -join '' ) @@ -297,7 +292,7 @@ function Test-TargetResource # The Auto Quota does not exist and should not Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.AutoQuotaDoesNotExistAndShouldNotMessage) ` + $($script:localizedData.AutoQuotaDoesNotExistAndShouldNotMessage) ` -f $Path ) -join '' ) } @@ -313,7 +308,7 @@ function Test-TargetResource .PARAMETER Path The path this FSRM Quota applies to. #> -Function Get-AutoQuota +function Get-AutoQuota { [CmdletBinding()] [OutputType([System.Object])] @@ -332,7 +327,7 @@ Function Get-AutoQuota } catch { - Throw $_ + throw $_ } return $autoQuota @@ -355,7 +350,7 @@ Function Get-AutoQuota .PARAMETER Template The name of the FSRM Quota Template to apply to this path. #> -Function Assert-ResourcePropertiesValid +function Assert-ResourcePropertiesValid { [CmdletBinding()] param @@ -381,7 +376,7 @@ Function Assert-ResourcePropertiesValid # Check the path exists if (-not (Test-Path -Path $Path)) { - $errorMessage = $($LocalizedData.AutoQuotaPathDoesNotExistError) -f $Path + $errorMessage = $($script:localizedData.AutoQuotaPathDoesNotExistError) -f $Path $errorArgumentName = 'Path' } @@ -400,14 +395,14 @@ Function Assert-ResourcePropertiesValid } catch [Microsoft.PowerShell.Cmdletization.Cim.CimJobException] { - $errorMessage = $($LocalizedData.AutoQuotaTemplateNotFoundError) -f $Path, $Template + $errorMessage = $($script:localizedData.AutoQuotaTemplateNotFoundError) -f $Path, $Template $errorArgumentName = 'Template' } } else { # A template wasn't specifed - it needs to be - $errorMessage = $($LocalizedData.AutoQuotaTemplateEmptyError) -f $Path + $errorMessage = $($script:localizedData.AutoQuotaTemplateEmptyError) -f $Path $errorArgumentName = 'Template' } diff --git a/DSCResources/DSR_FSRMAutoQuota/DSR_FSRMAutoQuota.schema.mof b/source/DSCResources/DSC_FSRMAutoQuota/DSC_FSRMAutoQuota.schema.mof similarity index 91% rename from DSCResources/DSR_FSRMAutoQuota/DSR_FSRMAutoQuota.schema.mof rename to source/DSCResources/DSC_FSRMAutoQuota/DSC_FSRMAutoQuota.schema.mof index bcd1eb04..6764bdc0 100644 --- a/DSCResources/DSR_FSRMAutoQuota/DSR_FSRMAutoQuota.schema.mof +++ b/source/DSCResources/DSC_FSRMAutoQuota/DSC_FSRMAutoQuota.schema.mof @@ -1,5 +1,5 @@ [ClassVersion("1.0.0.0"), FriendlyName("FSRMAutoQuota")] -class DSR_FSRMAutoQuota : OMI_BaseResource +class DSC_FSRMAutoQuota : OMI_BaseResource { [Key, Description("The path this FSRM Quota applies to.")] String Path; [Write, Description("Specifies whether the FSRM Quota should exist."), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure; diff --git a/DSCResources/DSR_FSRMAutoQuota/README.md b/source/DSCResources/DSC_FSRMAutoQuota/README.md similarity index 100% rename from DSCResources/DSR_FSRMAutoQuota/README.md rename to source/DSCResources/DSC_FSRMAutoQuota/README.md diff --git a/DSCResources/DSR_FSRMAutoQuota/en-US/DSR_FSRMAutoQuota.strings.psd1 b/source/DSCResources/DSC_FSRMAutoQuota/en-US/DSC_FSRMAutoQuota.strings.psd1 similarity index 92% rename from DSCResources/DSR_FSRMAutoQuota/en-US/DSR_FSRMAutoQuota.strings.psd1 rename to source/DSCResources/DSC_FSRMAutoQuota/en-US/DSC_FSRMAutoQuota.strings.psd1 index 50c1791f..919b728f 100644 --- a/DSCResources/DSR_FSRMAutoQuota/en-US/DSR_FSRMAutoQuota.strings.psd1 +++ b/source/DSCResources/DSC_FSRMAutoQuota/en-US/DSC_FSRMAutoQuota.strings.psd1 @@ -9,7 +9,6 @@ ConvertFrom-StringData -StringData @' AutoQuotaUpdatedMessage = FSRM Auto Quota "{0}" has been updated. AutoQuotaRemovedMessage = FSRM Auto Quota "{0}" has been removed. TestingAutoQuotaMessage = Testing FSRM Auto Quota "{0}". - AutoQuotaDoesNotMatchTemplateNeedsUpdateMessage = FSRM Auto Quota "{0}" {1} does not match template. Change required. AutoQuotaPropertyNeedsUpdateMessage = FSRM Auto Quota "{0}" {1} is different. Change required. AutoQuotaDoesNotExistButShouldMessage = FSRM Auto Quota "{0}" does not exist but should. Change required. AutoQuotaExistsButShouldNotMessage = FSRM Auto Quota "{0}" exists but should not. Change required. diff --git a/DSCResources/DSR_FSRMClassification/DSR_FSRMClassification.psm1 b/source/DSCResources/DSC_FSRMClassification/DSC_FSRMClassification.psm1 similarity index 85% rename from DSCResources/DSR_FSRMClassification/DSR_FSRMClassification.psm1 rename to source/DSCResources/DSC_FSRMClassification/DSC_FSRMClassification.psm1 index b043c925..d0c5d762 100644 --- a/DSCResources/DSR_FSRMClassification/DSR_FSRMClassification.psm1 +++ b/source/DSCResources/DSC_FSRMClassification/DSC_FSRMClassification.psm1 @@ -1,14 +1,9 @@ $modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules' -# Import the Networking Resource Helper Module -Import-Module -Name (Join-Path -Path $modulePath ` - -ChildPath (Join-Path -Path 'FSRMDsc.ResourceHelper' ` - -ChildPath 'FSRMDsc.ResourceHelper.psm1')) +Import-Module -Name (Join-Path -Path $modulePath -ChildPath 'DscResource.Common') # Import Localization Strings -$LocalizedData = Get-LocalizedData ` - -ResourceName 'DSR_FSRMClassification' ` - -ResourcePath (Split-Path -Parent $Script:MyInvocation.MyCommand.Path) +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS @@ -30,7 +25,7 @@ function Get-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.GettingClassificationMessage) ` + $($script:localizedData.GettingClassificationMessage) ` -f $Id ) -join '' ) @@ -130,7 +125,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.SettingClassificationMessage) ` + $($script:localizedData.SettingClassificationMessage) ` -f $Id ) -join '' ) @@ -165,38 +160,54 @@ function Set-TargetResource $convertedScheduleMonthly[$counter] = $ScheduleMonthly[$counter] } - $newScheduledTaskParameters += @{ Monthly = $convertedScheduleMonthly } + $newScheduledTaskParameters += @{ + Monthly = $convertedScheduleMonthly + } } elseif ( $schedule.Monthly ) { - $newScheduledTaskParameters += @{ Monthly = $schedule.Monthly } + $newScheduledTaskParameters += @{ + Monthly = $schedule.Monthly + } } if ($PSBoundParameters.ContainsKey('ScheduleWeekly')) { - $newScheduledTaskParameters += @{ Weekly = $ScheduleWeekly } + $newScheduledTaskParameters += @{ + Weekly = $ScheduleWeekly + } } elseif ( $schedule.Weekly ) { - $newScheduledTaskParameters += @{ Weekly = $schedule.Weekly } + $newScheduledTaskParameters += @{ + Weekly = $schedule.Weekly + } } if ($PSBoundParameters.ContainsKey('ScheduleRunDuration')) { - $newScheduledTaskParameters += @{ RunDuration = $ScheduleRunDuration } + $newScheduledTaskParameters += @{ + RunDuration = $ScheduleRunDuration + } } elseif ( $schedule.RunDuration ) { - $newScheduledTaskParameters += @{ RunDuration = $schedule.RunDuration } + $newScheduledTaskParameters += @{ + RunDuration = $schedule.RunDuration + } } if ($PSBoundParameters.ContainsKey('ScheduleTime')) { - $newScheduledTaskParameters += @{ Time = $ScheduleTime } + $newScheduledTaskParameters += @{ + Time = $ScheduleTime + } } elseif ( $schedule.Time ) { - $newScheduledTaskParameters += @{ Time = $schedule.Time } + $newScheduledTaskParameters += @{ + Time = $schedule.Time + } } # Remove the schedule parameters @@ -212,7 +223,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationScheduleUpdatedMessage) ` + $($script:localizedData.ClassificationScheduleUpdatedMessage) ` -f $Id ) -join '' ) } @@ -222,7 +233,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationUpdatedMessage) ` + $($script:localizedData.ClassificationUpdatedMessage) ` -f $Id ) -join '' ) } # Set-TargetResource @@ -303,11 +314,11 @@ function Test-TargetResource ) # Flag to signal whether settings are correct - [Boolean] $desiredConfigurationMatch = $true + $desiredConfigurationMatch = $true Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.TestingClassificationMessage) ` + $($script:localizedData.TestingClassificationMessage) ` -f $Id ) -join '' ) @@ -319,7 +330,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationNeedsUpdateMessage) ` + $($script:localizedData.ClassificationNeedsUpdateMessage) ` -f $Id, 'Continuous' ) -join '' ) @@ -330,7 +341,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationNeedsUpdateMessage) ` + $($script:localizedData.ClassificationNeedsUpdateMessage) ` -f $Id, 'ContinuousLog' ) -join '' ) @@ -341,7 +352,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationNeedsUpdateMessage) ` + $($script:localizedData.ClassificationNeedsUpdateMessage) ` -f $Id, 'ContinuousLogSize' ) -join '' ) @@ -361,7 +372,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationNeedsUpdateMessage) ` + $($script:localizedData.ClassificationNeedsUpdateMessage) ` -f $Id, 'ExcludeNamespace' ) -join '' ) @@ -382,7 +393,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationNeedsUpdateMessage) ` + $($script:localizedData.ClassificationNeedsUpdateMessage) ` -f $Id, 'ScheduleMonthly' ) -join '' ) $desiredConfigurationMatch = $false @@ -402,7 +413,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationNeedsUpdateMessage) ` + $($script:localizedData.ClassificationNeedsUpdateMessage) ` -f $Id, 'ScheduleWeekly' ) -join '' ) @@ -413,7 +424,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationNeedsUpdateMessage) ` + $($script:localizedData.ClassificationNeedsUpdateMessage) ` -f $Id, 'ScheduleRunDuration' ) -join '' ) @@ -424,7 +435,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationNeedsUpdateMessage) ` + $($script:localizedData.ClassificationNeedsUpdateMessage) ` -f $Id, 'ScheduleTime' ) -join '' ) $desiredConfigurationMatch = $false diff --git a/DSCResources/DSR_FSRMClassification/DSR_FSRMClassification.schema.mof b/source/DSCResources/DSC_FSRMClassification/DSC_FSRMClassification.schema.mof similarity index 96% rename from DSCResources/DSR_FSRMClassification/DSR_FSRMClassification.schema.mof rename to source/DSCResources/DSC_FSRMClassification/DSC_FSRMClassification.schema.mof index f9e32261..82a959b0 100644 --- a/DSCResources/DSR_FSRMClassification/DSR_FSRMClassification.schema.mof +++ b/source/DSCResources/DSC_FSRMClassification/DSC_FSRMClassification.schema.mof @@ -1,5 +1,5 @@ [ClassVersion("1.0.0.0"), FriendlyName("FSRMClassification")] -class DSR_FSRMClassification : OMI_BaseResource +class DSC_FSRMClassification : OMI_BaseResource { [Key, Description("This is a unique identifier for this resource.")] String Id; [Write, Description("Enable FSRM Classification continuous mode for new files.")] Boolean Continuous; diff --git a/DSCResources/DSR_FSRMClassification/README.md b/source/DSCResources/DSC_FSRMClassification/README.md similarity index 100% rename from DSCResources/DSR_FSRMClassification/README.md rename to source/DSCResources/DSC_FSRMClassification/README.md diff --git a/DSCResources/DSR_FSRMClassification/en-US/DSR_FSRMClassification.strings.psd1 b/source/DSCResources/DSC_FSRMClassification/en-US/DSC_FSRMClassification.strings.psd1 similarity index 100% rename from DSCResources/DSR_FSRMClassification/en-US/DSR_FSRMClassification.strings.psd1 rename to source/DSCResources/DSC_FSRMClassification/en-US/DSC_FSRMClassification.strings.psd1 diff --git a/DSCResources/DSR_FSRMClassificationProperty/DSR_FSRMClassificationProperty.psm1 b/source/DSCResources/DSC_FSRMClassificationProperty/DSC_FSRMClassificationProperty.psm1 similarity index 86% rename from DSCResources/DSR_FSRMClassificationProperty/DSR_FSRMClassificationProperty.psm1 rename to source/DSCResources/DSC_FSRMClassificationProperty/DSC_FSRMClassificationProperty.psm1 index 6f723df4..0ef04737 100644 --- a/DSCResources/DSR_FSRMClassificationProperty/DSR_FSRMClassificationProperty.psm1 +++ b/source/DSCResources/DSC_FSRMClassificationProperty/DSC_FSRMClassificationProperty.psm1 @@ -1,14 +1,9 @@ $modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules' -# Import the Networking Resource Helper Module -Import-Module -Name (Join-Path -Path $modulePath ` - -ChildPath (Join-Path -Path 'FSRMDsc.ResourceHelper' ` - -ChildPath 'FSRMDsc.ResourceHelper.psm1')) +Import-Module -Name (Join-Path -Path $modulePath -ChildPath 'DscResource.Common') # Import Localization Strings -$LocalizedData = Get-LocalizedData ` - -ResourceName 'DSR_FSRMClassificationProperty' ` - -ResourcePath (Split-Path -Parent $Script:MyInvocation.MyCommand.Path) +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS @@ -38,7 +33,7 @@ function Get-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.GettingClassificationPropertyMessage) ` + $($script:localizedData.GettingClassificationPropertyMessage) ` -f $Name ) -join '' ) @@ -51,7 +46,7 @@ function Get-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationPropertyExistsMessage) ` + $($script:localizedData.ClassificationPropertyExistsMessage) ` -f $Name ) -join '' ) @@ -68,7 +63,7 @@ function Get-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationPropertyDoesNotExistMessage) ` + $($script:localizedData.ClassificationPropertyDoesNotExistMessage) ` -f $Name ) -join '' ) @@ -145,7 +140,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.SettingClassificationPropertyMessage) ` + $($script:localizedData.SettingClassificationPropertyMessage) ` -f $Name ) -join '' ) @@ -159,11 +154,11 @@ function Set-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.EnsureClassificationPropertyExistsMessage) ` + $($script:localizedData.EnsureClassificationPropertyExistsMessage) ` -f $Name ) -join '' ) - # Assemble an ArrayList of DSR_FSRMClassificationPropertyDefinitionValue if + # Assemble an ArrayList of DSC_FSRMClassificationPropertyDefinitionValue if # the PossibleValue parameter was passed $newPossibleValue = @() if ($PSBoundParameters.ContainsKey('PossibleValue')) @@ -210,7 +205,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationPropertyRecreatedMessage) ` + $($script:localizedData.ClassificationPropertyRecreatedMessage) ` -f $Name ) -join '' ) } @@ -220,7 +215,7 @@ function Set-TargetResource Set-FSRMClassificationPropertyDefinition @PSBoundParameters -ErrorAction Stop Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationPropertyUpdatedMessage) ` + $($script:localizedData.ClassificationPropertyUpdatedMessage) ` -f $Name ) -join '' ) } @@ -238,7 +233,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationPropertyCreatedMessage) ` + $($script:localizedData.ClassificationPropertyCreatedMessage) ` -f $Name ) -join '' ) } @@ -247,7 +242,7 @@ function Set-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.EnsureClassificationPropertyDoesNotExistMessage) ` + $($script:localizedData.EnsureClassificationPropertyDoesNotExistMessage) ` -f $Name ) -join '' ) @@ -258,7 +253,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationPropertyRemovedMessage) ` + $($script:localizedData.ClassificationPropertyRemovedMessage) ` -f $Name ) -join '' ) } # if @@ -328,11 +323,11 @@ function Test-TargetResource $Parameters ) # Flag to signal whether settings are correct - [Boolean] $desiredConfigurationMatch = $true + $desiredConfigurationMatch = $true Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.TestingClassificationPropertyMessage) ` + $($script:localizedData.TestingClassificationPropertyMessage) ` -f $Name ) -join '' ) @@ -349,7 +344,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationPropertyNeedsUpdateMessage) ` + $($script:localizedData.ClassificationPropertyNeedsUpdateMessage) ` -f $Name, 'Description' ) -join '' ) $desiredConfigurationMatch = $false @@ -359,7 +354,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationPropertyNeedsUpdateMessage) ` + $($script:localizedData.ClassificationPropertyNeedsUpdateMessage) ` -f $Name, 'DisplayName' ) -join '' ) $desiredConfigurationMatch = $false @@ -369,7 +364,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationPropertyNeedsUpdateMessage) ` + $($script:localizedData.ClassificationPropertyNeedsUpdateMessage) ` -f $Name, 'Type' ) -join '' ) $desiredConfigurationMatch = $false @@ -389,7 +384,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationPropertyNeedsUpdateMessage) ` + $($script:localizedData.ClassificationPropertyNeedsUpdateMessage) ` -f $Name, 'Parameters' ) -join '' ) $desiredConfigurationMatch = $false @@ -402,7 +397,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationPropertyNeedsUpdateMessage) ` + $($script:localizedData.ClassificationPropertyNeedsUpdateMessage) ` -f $Name, 'PossibleValue' ) -join '' ) $desiredConfigurationMatch = $false @@ -414,7 +409,7 @@ function Test-TargetResource # Ths Classification Property doesn't exist but should Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationPropertyDoesNotExistButShouldMessage) ` + $($script:localizedData.ClassificationPropertyDoesNotExistButShouldMessage) ` -f $Name ) -join '' ) $desiredConfigurationMatch = $false @@ -428,7 +423,7 @@ function Test-TargetResource # The Classification Property exists but should not Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationPropertyExistsButShouldNotMessage) ` + $($script:localizedData.ClassificationPropertyExistsButShouldNotMessage) ` -f $Name ) -join '' ) $desiredConfigurationMatch = $false @@ -438,7 +433,7 @@ function Test-TargetResource # The Classification Property does not exist and should not Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationPropertyDoesNotExistAndShouldNotMessage) ` + $($script:localizedData.ClassificationPropertyDoesNotExistAndShouldNotMessage) ` -f $Name ) -join '' ) } @@ -453,7 +448,7 @@ function Test-TargetResource .PARAMETER Name The name of the FSRM Classification Property. #> -Function Get-ClassificationProperty +function Get-ClassificationProperty { param ( @@ -473,7 +468,7 @@ Function Get-ClassificationProperty } catch { - Throw $_ + throw $_ } return $classificationProperty diff --git a/DSCResources/DSR_FSRMClassificationProperty/DSR_FSRMClassificationProperty.schema.mof b/source/DSCResources/DSC_FSRMClassificationProperty/DSC_FSRMClassificationProperty.schema.mof similarity index 95% rename from DSCResources/DSR_FSRMClassificationProperty/DSR_FSRMClassificationProperty.schema.mof rename to source/DSCResources/DSC_FSRMClassificationProperty/DSC_FSRMClassificationProperty.schema.mof index c217423d..eef2e432 100644 --- a/DSCResources/DSR_FSRMClassificationProperty/DSR_FSRMClassificationProperty.schema.mof +++ b/source/DSCResources/DSC_FSRMClassificationProperty/DSC_FSRMClassificationProperty.schema.mof @@ -1,5 +1,5 @@ [ClassVersion("1.0.0.0"), FriendlyName("FSRMClassificationProperty")] -class DSR_FSRMClassificationProperty : OMI_BaseResource +class DSC_FSRMClassificationProperty : OMI_BaseResource { [Key, Description("The name of the FSRM Classification Property.")] String Name; [Required, Description("The type of the FSRM Classification Property."), ValueMap{"OrderedList","MultiChoice","SingleChoice","String","MultiString","Integer","YesNo","DateTime"}, Values{"OrderedList","MultiChoice","SingleChoice","String","MultiString","Integer","YesNo","DateTime"}] String Type; diff --git a/DSCResources/DSR_FSRMClassificationProperty/README.md b/source/DSCResources/DSC_FSRMClassificationProperty/README.md similarity index 100% rename from DSCResources/DSR_FSRMClassificationProperty/README.md rename to source/DSCResources/DSC_FSRMClassificationProperty/README.md diff --git a/DSCResources/DSR_FSRMClassificationProperty/en-US/DSR_FSRMClassificationProperty.strings.psd1 b/source/DSCResources/DSC_FSRMClassificationProperty/en-US/DSC_FSRMClassificationProperty.strings.psd1 similarity index 100% rename from DSCResources/DSR_FSRMClassificationProperty/en-US/DSR_FSRMClassificationProperty.strings.psd1 rename to source/DSCResources/DSC_FSRMClassificationProperty/en-US/DSC_FSRMClassificationProperty.strings.psd1 diff --git a/DSCResources/DSR_FSRMClassificationPropertyValue/DSR_FSRMClassificationPropertyValue.psm1 b/source/DSCResources/DSC_FSRMClassificationPropertyValue/DSC_FSRMClassificationPropertyValue.psm1 similarity index 84% rename from DSCResources/DSR_FSRMClassificationPropertyValue/DSR_FSRMClassificationPropertyValue.psm1 rename to source/DSCResources/DSC_FSRMClassificationPropertyValue/DSC_FSRMClassificationPropertyValue.psm1 index c78b314b..9efd7af9 100644 --- a/DSCResources/DSR_FSRMClassificationPropertyValue/DSR_FSRMClassificationPropertyValue.psm1 +++ b/source/DSCResources/DSC_FSRMClassificationPropertyValue/DSC_FSRMClassificationPropertyValue.psm1 @@ -1,14 +1,9 @@ $modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules' -# Import the Networking Resource Helper Module -Import-Module -Name (Join-Path -Path $modulePath ` - -ChildPath (Join-Path -Path 'FSRMDsc.ResourceHelper' ` - -ChildPath 'FSRMDsc.ResourceHelper.psm1')) +Import-Module -Name (Join-Path -Path $modulePath -ChildPath 'DscResource.Common') # Import Localization Strings -$LocalizedData = Get-LocalizedData ` - -ResourceName 'DSR_FSRMClassificationPropertyValue' ` - -ResourcePath (Split-Path -Parent $Script:MyInvocation.MyCommand.Path) +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS @@ -37,7 +32,7 @@ function Get-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.GettingClassificationPropertyValueMessage) ` + $($script:localizedData.GettingClassificationPropertyValueMessage) ` -f $PropertyName, $Name ) -join '' ) @@ -64,11 +59,11 @@ function Get-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationPropertyValueExistsMessage) ` + $($script:localizedData.ClassificationPropertyValueExistsMessage) ` -f $PropertyName, $Name ) -join '' ) - $returnValue += @{ + $returnValue += @{ Ensure = 'Present' DisplayName = $classificationPropertyValue.DisplayName Description = $classificationPropertyValue.Description @@ -78,7 +73,7 @@ function Get-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationPropertyValueDoesNotExistMessage) ` + $($script:localizedData.ClassificationPropertyValueDoesNotExistMessage) ` -f $PropertyName, $Name ) -join '' ) @@ -132,7 +127,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.SettingClassificationPropertyValueMessage) ` + $($script:localizedData.SettingClassificationPropertyValueMessage) ` -f $PropertyName, $Name ) -join '' ) @@ -165,7 +160,7 @@ function Set-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.EnsureClassificationPropertyValueExistsMessage) ` + $($script:localizedData.EnsureClassificationPropertyValueExistsMessage) ` -f $PropertyName, $Name ) -join '' ) @@ -178,7 +173,7 @@ function Set-TargetResource # Create the Classification Property Value Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationPropertyValueCreatedMessage) ` + $($script:localizedData.ClassificationPropertyValueCreatedMessage) ` -f $PropertyName, $Name ) -join '' ) } @@ -189,7 +184,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationPropertyValueUpdatedMessage) ` + $($script:localizedData.ClassificationPropertyValueUpdatedMessage) ` -f $PropertyName, $Name ) -join '' ) } @@ -200,7 +195,7 @@ function Set-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.EnsureClassificationPropertyValueDoesNotExistMessage) ` + $($script:localizedData.EnsureClassificationPropertyValueDoesNotExistMessage) ` -f $PropertyName, $Name ) -join '' ) @@ -209,7 +204,7 @@ function Set-TargetResource # The Classification Property Value doesn't exist and should not Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationPropertyValueNoChangeMessage) ` + $($script:localizedData.ClassificationPropertyValueNoChangeMessage) ` -f $PropertyName, $Name ) -join '' ) return @@ -221,7 +216,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationPropertyValueRemovedMessage) ` + $($script:localizedData.ClassificationPropertyValueRemovedMessage) ` -f $PropertyName, $Name ) -join '' ) } # if @@ -234,7 +229,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationPropertyValueWrittenMessage) ` + $($script:localizedData.ClassificationPropertyValueWrittenMessage) ` -f $PropertyName, $Name ) -join '' ) } # Set-TargetResource @@ -279,11 +274,11 @@ function Test-TargetResource $Description ) # Flag to signal whether settings are correct - [Boolean] $desiredConfigurationMatch = $true + $desiredConfigurationMatch = $true Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.TestingClassificationPropertyValueMessage) ` + $($script:localizedData.TestingClassificationPropertyValueMessage) ` -f $PropertyName, $Name ) -join '' ) @@ -312,7 +307,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.EnsureClassificationPropertyValueExistsMessage) ` + $($script:localizedData.EnsureClassificationPropertyValueExistsMessage) ` -f $PropertyName, $Name ) -join '' ) @@ -321,7 +316,7 @@ function Test-TargetResource # The Classification Property Value does not exist but should Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationPropertyValueDoesNotExistButShouldMessage) ` + $($script:localizedData.ClassificationPropertyValueDoesNotExistButShouldMessage) ` -f $PropertyName, $Name ) -join '' ) $desiredConfigurationMatch = $false @@ -335,7 +330,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationPropertyValuePropertyNeedsUpdateMessage) ` + $($script:localizedData.ClassificationPropertyValuePropertyNeedsUpdateMessage) ` -f $PropertyName, $Name, 'Description' ) -join '' ) $desiredConfigurationMatch = $false @@ -350,7 +345,7 @@ function Test-TargetResource # The ClassificationPropertyValue doesn't exist and should not Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationPropertyValueDoesNotExistAndShouldNotMessage) ` + $($script:localizedData.ClassificationPropertyValueDoesNotExistAndShouldNotMessage) ` -f $PropertyName, $Name ) -join '' ) } @@ -359,7 +354,7 @@ function Test-TargetResource # The ClassificationPropertyValue exists, but it should be removed Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationPropertyValueExistsAndShouldNotMessage) ` + $($script:localizedData.ClassificationPropertyValueExistsAndShouldNotMessage) ` -f $PropertyName, $Name ) -join '' ) $desiredConfigurationMatch = $false @@ -376,7 +371,7 @@ function Test-TargetResource .PARAMETER Name The FSRM Classification Property value Name. #> -Function Get-ClassificationProperty +function Get-ClassificationProperty { param ( @@ -394,12 +389,12 @@ Function Get-ClassificationProperty catch [Microsoft.PowerShell.Cmdletization.Cim.CimJobException] { New-InvalidArgumentException ` - -Message ($($LocalizedData.ClassificationPropertyNotFoundError) -f $PropertyName) ` + -Message ($($script:localizedData.ClassificationPropertyNotFoundError) -f $PropertyName) ` -ArgumentName $PropertyName } catch { - Throw $_ + throw $_ } return $classificationProperty diff --git a/DSCResources/DSR_FSRMClassificationPropertyValue/DSR_FSRMClassificationPropertyValue.schema.mof b/source/DSCResources/DSC_FSRMClassificationPropertyValue/DSC_FSRMClassificationPropertyValue.schema.mof similarity index 91% rename from DSCResources/DSR_FSRMClassificationPropertyValue/DSR_FSRMClassificationPropertyValue.schema.mof rename to source/DSCResources/DSC_FSRMClassificationPropertyValue/DSC_FSRMClassificationPropertyValue.schema.mof index ef25e79c..a9a00e4d 100644 --- a/DSCResources/DSR_FSRMClassificationPropertyValue/DSR_FSRMClassificationPropertyValue.schema.mof +++ b/source/DSCResources/DSC_FSRMClassificationPropertyValue/DSC_FSRMClassificationPropertyValue.schema.mof @@ -1,5 +1,5 @@ [ClassVersion("1.0.0.0"), FriendlyName("FSRMClassificationPropertyValue")] -class DSR_FSRMClassificationPropertyValue : OMI_BaseResource +class DSC_FSRMClassificationPropertyValue : OMI_BaseResource { [Key, Description("The FSRM Classification Property value Name.")] string Name; [Key, Description("The name of the FSRM Classification Property the value applies to.")] string PropertyName; diff --git a/DSCResources/DSR_FSRMClassificationPropertyValue/README.md b/source/DSCResources/DSC_FSRMClassificationPropertyValue/README.md similarity index 100% rename from DSCResources/DSR_FSRMClassificationPropertyValue/README.md rename to source/DSCResources/DSC_FSRMClassificationPropertyValue/README.md diff --git a/DSCResources/DSR_FSRMClassificationPropertyValue/en-US/DSR_FSRMClassificationPropertyValue.strings.psd1 b/source/DSCResources/DSC_FSRMClassificationPropertyValue/en-US/DSC_FSRMClassificationPropertyValue.strings.psd1 similarity index 94% rename from DSCResources/DSR_FSRMClassificationPropertyValue/en-US/DSR_FSRMClassificationPropertyValue.strings.psd1 rename to source/DSCResources/DSC_FSRMClassificationPropertyValue/en-US/DSC_FSRMClassificationPropertyValue.strings.psd1 index f81e1131..93780037 100644 --- a/DSCResources/DSR_FSRMClassificationPropertyValue/en-US/DSR_FSRMClassificationPropertyValue.strings.psd1 +++ b/source/DSCResources/DSC_FSRMClassificationPropertyValue/en-US/DSC_FSRMClassificationPropertyValue.strings.psd1 @@ -1,7 +1,7 @@ ConvertFrom-StringData -StringData @' GettingClassificationPropertyValueMessage = Getting FSRM Classification Property Definition "{0}" value "{1}". ClassificationPropertyValueExistsMessage = FSRM Classification Property Value Definition "{0}" value "{1}" exists. - ClassificationPropertyValueNotExistMessage = FSRM Classification Property Value Definition "{0}" value "{1}" does not exist. + ClassificationPropertyValueDoesNotExistMessage = FSRM Classification Property Value Definition "{0}" value "{1}" does not exist. SettingClassificationPropertyValueMessage = Setting FSRM Classification Property Value Definition "{0}" value "{1}". EnsureClassificationPropertyValueExistsMessage = Ensuring FSRM Classification Property Value Definition "{0}" value "{1}" exists. EnsureClassificationPropertyValueDoesNotExistMessage = Ensuring FSRM Classification Property Value Definition "{0}" value "{1}" does not exist. diff --git a/DSCResources/DSR_FSRMClassificationRule/DSR_FSRMClassificationRule.psm1 b/source/DSCResources/DSC_FSRMClassificationRule/DSC_FSRMClassificationRule.psm1 similarity index 87% rename from DSCResources/DSR_FSRMClassificationRule/DSR_FSRMClassificationRule.psm1 rename to source/DSCResources/DSC_FSRMClassificationRule/DSC_FSRMClassificationRule.psm1 index d1079cb4..40508c80 100644 --- a/DSCResources/DSR_FSRMClassificationRule/DSR_FSRMClassificationRule.psm1 +++ b/source/DSCResources/DSC_FSRMClassificationRule/DSC_FSRMClassificationRule.psm1 @@ -1,14 +1,9 @@ $modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules' -# Import the Networking Resource Helper Module -Import-Module -Name (Join-Path -Path $modulePath ` - -ChildPath (Join-Path -Path 'FSRMDsc.ResourceHelper' ` - -ChildPath 'FSRMDsc.ResourceHelper.psm1')) +Import-Module -Name (Join-Path -Path $modulePath -ChildPath 'DscResource.Common') # Import Localization Strings -$LocalizedData = Get-LocalizedData ` - -ResourceName 'DSR_FSRMClassificationRule' ` - -ResourcePath (Split-Path -Parent $Script:MyInvocation.MyCommand.Path) +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS @@ -30,7 +25,7 @@ function Get-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.GettingClassificationRuleMessage) ` + $($script:localizedData.GettingClassificationRuleMessage) ` -f $Name ) -join '' ) @@ -44,7 +39,7 @@ function Get-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationRuleExistsMessage) ` + $($script:localizedData.ClassificationRuleExistsMessage) ` -f $Name ) -join '' ) @@ -68,7 +63,7 @@ function Get-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationRuleDoesNotExistMessage) ` + $($script:localizedData.ClassificationRuleDoesNotExistMessage) ` -f $Name ) -join '' ) @@ -195,7 +190,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.SettingClassificationRuleMessage) ` + $($script:localizedData.SettingClassificationRuleMessage) ` -f $Name ) -join '' ) @@ -209,7 +204,7 @@ function Set-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.EnsureClassificationRuleExistsMessage) ` + $($script:localizedData.EnsureClassificationRuleExistsMessage) ` -f $Name ) -join '' ) @@ -220,7 +215,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationRuleUpdatedMessage) ` + $($script:localizedData.ClassificationRuleUpdatedMessage) ` -f $Name ) -join '' ) } @@ -231,7 +226,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationRuleCreatedMessage) ` + $($script:localizedData.ClassificationRuleCreatedMessage) ` -f $Name ) -join '' ) } @@ -240,7 +235,7 @@ function Set-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.EnsureClassificationRuleDoesNotExistMessage) ` + $($script:localizedData.EnsureClassificationRuleDoesNotExistMessage) ` -f $Name ) -join '' ) @@ -251,7 +246,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationRuleRemovedMessage) ` + $($script:localizedData.ClassificationRuleRemovedMessage) ` -f $Name ) -join '' ) } # if @@ -372,11 +367,11 @@ function Test-TargetResource ) # Flag to signal whether settings are correct - [Boolean] $desiredConfigurationMatch = $true + $desiredConfigurationMatch = $true Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.TestingClassificationRuleMessage) ` + $($script:localizedData.TestingClassificationRuleMessage) ` -f $Name ) -join '' ) @@ -390,7 +385,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationRuleExistsAndShouldMessage) ` + $($script:localizedData.ClassificationRuleExistsAndShouldMessage) ` -f $Name ) -join '' ) @@ -399,7 +394,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationRuleNeedsUpdateMessage) ` + $($script:localizedData.ClassificationRuleNeedsUpdateMessage) ` -f $Name, 'Description' ) -join '' ) @@ -410,7 +405,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationRuleNeedsUpdateMessage) ` + $($script:localizedData.ClassificationRuleNeedsUpdateMessage) ` -f $Name, 'Property' ) -join '' ) @@ -421,7 +416,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationRuleNeedsUpdateMessage) ` + $($script:localizedData.ClassificationRuleNeedsUpdateMessage) ` -f $Name, 'PropertyValue' ) -join '' ) @@ -433,7 +428,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationRuleNeedsUpdateMessage) ` + $($script:localizedData.ClassificationRuleNeedsUpdateMessage) ` -f $Name, 'ClassificationMechanism' ) -join '' ) @@ -447,7 +442,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationRuleNeedsUpdateMessage) ` + $($script:localizedData.ClassificationRuleNeedsUpdateMessage) ` -f $Name, 'ContentRegularExpression' ) -join '' ) @@ -461,7 +456,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationRuleNeedsUpdateMessage) ` + $($script:localizedData.ClassificationRuleNeedsUpdateMessage) ` -f $Name, 'ContentString' ) -join '' ) @@ -475,7 +470,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationRuleNeedsUpdateMessage) ` + $($script:localizedData.ClassificationRuleNeedsUpdateMessage) ` -f $Name, 'ContentStringCaseSensitive' ) -join '' ) @@ -486,7 +481,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationRuleNeedsUpdateMessage) ` + $($script:localizedData.ClassificationRuleNeedsUpdateMessage) ` -f $Name, 'Disabled' ) -join '' ) @@ -507,7 +502,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationRuleNeedsUpdateMessage) ` + $($script:localizedData.ClassificationRuleNeedsUpdateMessage) ` -f $Name, 'Flags' ) -join '' ) @@ -527,7 +522,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationRuleNeedsUpdateMessage) ` + $($script:localizedData.ClassificationRuleNeedsUpdateMessage) ` -f $Name, 'Parameters' ) -join '' ) @@ -541,7 +536,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationRuleNeedsUpdateMessage) ` + $($script:localizedData.ClassificationRuleNeedsUpdateMessage) ` -f $Name, 'Namespace' ) -join '' ) @@ -553,7 +548,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationRuleNeedsUpdateMessage) ` + $($script:localizedData.ClassificationRuleNeedsUpdateMessage) ` -f $Name, 'ReevaluateProperty' ) -join '' ) @@ -565,7 +560,7 @@ function Test-TargetResource # Ths Classification Rule doesn't exist but should Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationRuleDoesNotExistButShouldMessage) ` + $($script:localizedData.ClassificationRuleDoesNotExistButShouldMessage) ` -f $Name ) -join '' ) @@ -580,7 +575,7 @@ function Test-TargetResource # The Classification Rule exists but should not Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationRuleExistsButShouldNotMessage) ` + $($script:localizedData.ClassificationRuleExistsButShouldNotMessage) ` -f $Name ) -join '' ) @@ -591,7 +586,7 @@ function Test-TargetResource # The Classification Rule does not exist and should not Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ClassificationRuleDoesNotExistAndShouldNotMessage) ` + $($script:localizedData.ClassificationRuleDoesNotExistAndShouldNotMessage) ` -f $Name ) -join '' ) } @@ -607,7 +602,7 @@ function Test-TargetResource .PARAMETER Name The name of the FSRM Classification Rule. #> -Function Get-ClassificationRule +function Get-ClassificationRule { param ( @@ -626,7 +621,7 @@ Function Get-ClassificationRule } catch { - Throw $_ + throw $_ } return $classificationRule diff --git a/DSCResources/DSR_FSRMClassificationRule/DSR_FSRMClassificationRule.schema.mof b/source/DSCResources/DSC_FSRMClassificationRule/DSC_FSRMClassificationRule.schema.mof similarity index 97% rename from DSCResources/DSR_FSRMClassificationRule/DSR_FSRMClassificationRule.schema.mof rename to source/DSCResources/DSC_FSRMClassificationRule/DSC_FSRMClassificationRule.schema.mof index 18c9a8f4..4ee24d3b 100644 --- a/DSCResources/DSR_FSRMClassificationRule/DSR_FSRMClassificationRule.schema.mof +++ b/source/DSCResources/DSC_FSRMClassificationRule/DSC_FSRMClassificationRule.schema.mof @@ -1,5 +1,5 @@ [ClassVersion("1.0.0.0"), FriendlyName("FSRMClassificationRule")] -class DSR_FSRMClassificationRule : OMI_BaseResource +class DSC_FSRMClassificationRule : OMI_BaseResource { [Key, Description("The name of the FSRM Classification Rule.")] String Name; [Write, Description("The description for the FSRM Classification Rule.")] String Description; diff --git a/DSCResources/DSR_FSRMClassificationRule/README.md b/source/DSCResources/DSC_FSRMClassificationRule/README.md similarity index 100% rename from DSCResources/DSR_FSRMClassificationRule/README.md rename to source/DSCResources/DSC_FSRMClassificationRule/README.md diff --git a/DSCResources/DSR_FSRMClassificationRule/en-US/DSR_FSRMClassificationRule.strings.psd1 b/source/DSCResources/DSC_FSRMClassificationRule/en-US/DSC_FSRMClassificationRule.strings.psd1 similarity index 94% rename from DSCResources/DSR_FSRMClassificationRule/en-US/DSR_FSRMClassificationRule.strings.psd1 rename to source/DSCResources/DSC_FSRMClassificationRule/en-US/DSC_FSRMClassificationRule.strings.psd1 index 9053ed79..1808f92e 100644 --- a/DSCResources/DSR_FSRMClassificationRule/en-US/DSR_FSRMClassificationRule.strings.psd1 +++ b/source/DSCResources/DSC_FSRMClassificationRule/en-US/DSC_FSRMClassificationRule.strings.psd1 @@ -7,7 +7,6 @@ ConvertFrom-StringData -StringData @' EnsureClassificationRuleDoesNotExistMessage = Ensuring FSRM Classification Rule "{0}" does not exist. ClassificationRuleCreatedMessage = FSRM Classification Rule "{0}" has been created. ClassificationRuleUpdatedMessage = FSRM Classification Rule "{0}" has been updated. - ClassificationRuleRecreatedMessage = FSRM Classification Rule "{0}" has been recreated. ClassificationRuleRemovedMessage = FSRM Classification Rule "{0}" has been removed. TestingClassificationRuleMessage = Testing FSRM Classification Rule "{0}". ClassificationRuleExistsAndShouldMessage = FSRM Classification Rule "{0}" exists and should. diff --git a/DSCResources/DSR_FSRMFileGroup/DSR_FSRMFileGroup.psm1 b/source/DSCResources/DSC_FSRMFileGroup/DSC_FSRMFileGroup.psm1 similarity index 84% rename from DSCResources/DSR_FSRMFileGroup/DSR_FSRMFileGroup.psm1 rename to source/DSCResources/DSC_FSRMFileGroup/DSC_FSRMFileGroup.psm1 index 5b497d40..0c343163 100644 --- a/DSCResources/DSR_FSRMFileGroup/DSR_FSRMFileGroup.psm1 +++ b/source/DSCResources/DSC_FSRMFileGroup/DSC_FSRMFileGroup.psm1 @@ -1,14 +1,9 @@ $modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules' -# Import the Networking Resource Helper Module -Import-Module -Name (Join-Path -Path $modulePath ` - -ChildPath (Join-Path -Path 'FSRMDsc.ResourceHelper' ` - -ChildPath 'FSRMDsc.ResourceHelper.psm1')) +Import-Module -Name (Join-Path -Path $modulePath -ChildPath 'DscResource.Common') # Import Localization Strings -$LocalizedData = Get-LocalizedData ` - -ResourceName 'DSR_FSRMFileGroup' ` - -ResourcePath (Split-Path -Parent $Script:MyInvocation.MyCommand.Path) +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS @@ -30,7 +25,7 @@ function Get-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.GettingFileGroupMessage) ` + $($script:localizedData.GettingFileGroupMessage) ` -f $Name ) -join '' ) @@ -44,7 +39,7 @@ function Get-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileGroupExistsMessage) ` + $($script:localizedData.FileGroupExistsMessage) ` -f $Name ) -join '' ) @@ -59,7 +54,7 @@ function Get-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileGroupDoesNotExistMessage) ` + $($script:localizedData.FileGroupDoesNotExistMessage) ` -f $Name ) -join '' ) @@ -120,7 +115,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.SettingFileGroupMessage) ` + $($script:localizedData.SettingFileGroupMessage) ` -f $Name ) -join '' ) @@ -134,7 +129,7 @@ function Set-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.EnsureFileGroupExistsMessage) ` + $($script:localizedData.EnsureFileGroupExistsMessage) ` -f $Name ) -join '' ) @@ -145,7 +140,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileGroupUpdatedMessage) ` + $($script:localizedData.FileGroupUpdatedMessage) ` -f $Name ) -join '' ) } @@ -156,7 +151,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileGroupCreatedMessage) ` + $($script:localizedData.FileGroupCreatedMessage) ` -f $Name ) -join '' ) } @@ -165,7 +160,7 @@ function Set-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.EnsureFileGroupDoesNotExistMessage) ` + $($script:localizedData.EnsureFileGroupDoesNotExistMessage) ` -f $Name ) -join '' ) @@ -176,7 +171,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileGroupRemovedMessage) ` + $($script:localizedData.FileGroupRemovedMessage) ` -f $Name ) -join '' ) } # if @@ -231,11 +226,11 @@ function Test-TargetResource ) # Flag to signal whether settings are correct - [Boolean] $desiredConfigurationMatch = $true + $desiredConfigurationMatch = $true Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.TestingFileGroupMessage) ` + $($script:localizedData.TestingFileGroupMessage) ` -f $Name ) -join '' ) @@ -252,7 +247,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileGroupDescriptionNeedsUpdateMessage) ` + $($script:localizedData.FileGroupDescriptionNeedsUpdateMessage) ` -f $Name ) -join '' ) @@ -265,7 +260,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileGroupIncludePatternNeedsUpdateMessage) ` + $($script:localizedData.FileGroupIncludePatternNeedsUpdateMessage) ` -f $Name ) -join '' ) @@ -278,7 +273,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileGroupExcludePatternNeedsUpdateMessage) ` + $($script:localizedData.FileGroupExcludePatternNeedsUpdateMessage) ` -f $Name ) -join '' ) @@ -290,7 +285,7 @@ function Test-TargetResource # Ths File Group doesn't exist but should Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileGroupDoesNotExistButShouldMessage) ` + $($script:localizedData.FileGroupDoesNotExistButShouldMessage) ` -f $Name ) -join '' ) @@ -305,7 +300,7 @@ function Test-TargetResource # The File Group exists but should not Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileGroupExistsButShouldNotMessage) ` + $($script:localizedData.FileGroupExistsButShouldNotMessage) ` -f $Name ) -join '' ) @@ -316,7 +311,7 @@ function Test-TargetResource # The File Group does not exist and should not Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileGroupDoesNotExistAndShouldNotMessage) ` + $($script:localizedData.FileGroupDoesNotExistAndShouldNotMessage) ` -f $Name ) -join '' ) } @@ -332,7 +327,7 @@ function Test-TargetResource .PARAMETER Name The name of the FSRM File Group. #> -Function Get-FileGroup +function Get-FileGroup { param ( @@ -351,7 +346,7 @@ Function Get-FileGroup } catch { - Throw $_ + throw $_ } return $fileGroup diff --git a/DSCResources/DSR_FSRMFileGroup/DSR_FSRMFileGroup.schema.mof b/source/DSCResources/DSC_FSRMFileGroup/DSC_FSRMFileGroup.schema.mof similarity index 93% rename from DSCResources/DSR_FSRMFileGroup/DSR_FSRMFileGroup.schema.mof rename to source/DSCResources/DSC_FSRMFileGroup/DSC_FSRMFileGroup.schema.mof index 099fae7e..d372d189 100644 --- a/DSCResources/DSR_FSRMFileGroup/DSR_FSRMFileGroup.schema.mof +++ b/source/DSCResources/DSC_FSRMFileGroup/DSC_FSRMFileGroup.schema.mof @@ -1,5 +1,5 @@ [ClassVersion("1.0.0.0"), FriendlyName("FSRMFileGroup")] -class DSR_FSRMFileGroup : OMI_BaseResource +class DSC_FSRMFileGroup : OMI_BaseResource { [Key, Description("The name of the FSRM File Group.")] String Name; [Write, Description("The description for the FSRM File Group.")] String Description; diff --git a/DSCResources/DSR_FSRMFileGroup/README.md b/source/DSCResources/DSC_FSRMFileGroup/README.md similarity index 100% rename from DSCResources/DSR_FSRMFileGroup/README.md rename to source/DSCResources/DSC_FSRMFileGroup/README.md diff --git a/DSCResources/DSR_FSRMFileGroup/en-us/DSR_FSRMFileGroup.strings.psd1 b/source/DSCResources/DSC_FSRMFileGroup/en-US/DSC_FSRMFileGroup.strings.psd1 similarity index 100% rename from DSCResources/DSR_FSRMFileGroup/en-us/DSR_FSRMFileGroup.strings.psd1 rename to source/DSCResources/DSC_FSRMFileGroup/en-US/DSC_FSRMFileGroup.strings.psd1 diff --git a/DSCResources/DSR_FSRMFileScreen/DSR_FSRMFileScreen.psm1 b/source/DSCResources/DSC_FSRMFileScreen/DSC_FSRMFileScreen.psm1 similarity index 87% rename from DSCResources/DSR_FSRMFileScreen/DSR_FSRMFileScreen.psm1 rename to source/DSCResources/DSC_FSRMFileScreen/DSC_FSRMFileScreen.psm1 index 7708cde0..a7871f06 100644 --- a/DSCResources/DSR_FSRMFileScreen/DSR_FSRMFileScreen.psm1 +++ b/source/DSCResources/DSC_FSRMFileScreen/DSC_FSRMFileScreen.psm1 @@ -1,14 +1,9 @@ $modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules' -# Import the Networking Resource Helper Module -Import-Module -Name (Join-Path -Path $modulePath ` - -ChildPath (Join-Path -Path 'FSRMDsc.ResourceHelper' ` - -ChildPath 'FSRMDsc.ResourceHelper.psm1')) +Import-Module -Name (Join-Path -Path $modulePath -ChildPath 'DscResource.Common') # Import Localization Strings -$LocalizedData = Get-LocalizedData ` - -ResourceName 'DSR_FSRMFileScreen' ` - -ResourcePath (Split-Path -Parent $Script:MyInvocation.MyCommand.Path) +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS @@ -30,7 +25,7 @@ function Get-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.GettingFileScreenMessage) ` + $($script:localizedData.GettingFileScreenMessage) ` -f $Path ) -join '' ) @@ -45,7 +40,7 @@ function Get-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileScreenExistsMessage) ` + $($script:localizedData.FileScreenExistsMessage) ` -f $Path ) -join '' ) @@ -62,7 +57,7 @@ function Get-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileScreenDoesNotExistMessage) ` + $($script:localizedData.FileScreenDoesNotExistMessage) ` -f $Path ) -join '' ) @@ -138,7 +133,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.SestingFileScreenMessage) ` + $($script:localizedData.SettingFileScreenMessage) ` -f $Path ) -join '' ) @@ -156,7 +151,7 @@ function Set-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.EnsureFileScreenExistsMessage) ` + $($script:localizedData.EnsureFileScreenExistsMessage) ` -f $Path ) -join '' ) @@ -176,7 +171,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileScreenRecreatedMessage) ` + $($script:localizedData.FileScreenRecreatedMessage) ` -f $Path ) -join '' ) } @@ -188,7 +183,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileScreenUpdatedMessage) ` + $($script:localizedData.FileScreenUpdatedMessage) ` -f $Path ) -join '' ) } @@ -201,7 +196,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileScreenCreatedMessage) ` + $($script:localizedData.FileScreenCreatedMessage) ` -f $Path ) -join '' ) } @@ -210,7 +205,7 @@ function Set-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.EnsureFileScreenDoesNotExistMessage) ` + $($script:localizedData.EnsureFileScreenDoesNotExistMessage) ` -f $Path ) -join '' ) @@ -221,7 +216,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileScreenRemovedMessage) ` + $($script:localizedData.FileScreenRemovedMessage) ` -f $Path ) -join '' ) } # if @@ -291,11 +286,11 @@ function Test-TargetResource ) # Flag to signal whether settings are correct - [Boolean] $desiredConfigurationMatch = $true + $desiredConfigurationMatch = $true Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.TestingFileScreenMessage) ` + $($script:localizedData.TestingFileScreenMessage) ` -f $Path ) -join '' ) @@ -318,7 +313,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileScreenDoesNotMatchTemplateNeedsUpdateMessage) ` + $($script:localizedData.FileScreenDoesNotMatchTemplateNeedsUpdateMessage) ` -f $Path, 'Description' ) -join '' ) @@ -332,7 +327,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileScreenPropertyNeedsUpdateMessage) ` + $($script:localizedData.FileScreenPropertyNeedsUpdateMessage) ` -f $Path, 'Active' ) -join '' ) @@ -346,7 +341,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileScreenPropertyNeedsUpdateMessage) ` + $($script:localizedData.FileScreenPropertyNeedsUpdateMessage) ` -f $Path, 'IncludeGroup' ) -join '' ) @@ -359,7 +354,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileScreenPropertyNeedsUpdateMessage) ` + $($script:localizedData.FileScreenPropertyNeedsUpdateMessage) ` -f $Path, 'Description' ) -join '' ) @@ -371,7 +366,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileScreenPropertyNeedsUpdateMessage) ` + $($script:localizedData.FileScreenPropertyNeedsUpdateMessage) ` -f $Path, 'Template' ) -join '' ) @@ -383,7 +378,7 @@ function Test-TargetResource # The File Screen doesn't exist but should Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileScreenDoesNotExistButShouldMessage) ` + $($script:localizedData.FileScreenDoesNotExistButShouldMessage) ` -f $Path ) -join '' ) @@ -398,7 +393,7 @@ function Test-TargetResource # The File Screen exists but should not Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileScreenExistsButShouldNotMessage) ` + $($script:localizedData.FileScreenExistsButShouldNotMessage) ` -f $Path ) -join '' ) @@ -409,7 +404,7 @@ function Test-TargetResource # The File Screen does not exist and should not Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileScreenDoesNotExistAndShouldNotMessage) ` + $($script:localizedData.FileScreenDoesNotExistAndShouldNotMessage) ` -f $Path ) -join '' ) } @@ -425,7 +420,7 @@ function Test-TargetResource .PARAMETER Path The path this FSRM File Screen applies to. #> -Function Get-FileScreen +function Get-FileScreen { param ( @@ -444,7 +439,7 @@ Function Get-FileScreen } catch { - Throw $_ + throw $_ } return $fileScreen @@ -477,7 +472,7 @@ Function Get-FileScreen .PARAMETER MatchesTemplate Causes the template to use only the template name and Active and Ignore Groups parameters. #> -Function Assert-ResourcePropertiesValid +function Assert-ResourcePropertiesValid { [CmdletBinding()] param @@ -517,7 +512,7 @@ Function Assert-ResourcePropertiesValid { $errorId = 'FileScreenPathDoesNotExistError' $errorCategory = [System.Management.Automation.ErrorCategory]::InvalidArgument - $errorMessage = $($LocalizedData.FileScreenPathDoesNotExistError) -f $Path + $errorMessage = $($script:localizedData.FileScreenPathDoesNotExistError) -f $Path } if ($Ensure -eq 'Absent') @@ -537,7 +532,7 @@ Function Assert-ResourcePropertiesValid { $errorId = 'FileScreenTemplateNotFoundError' $errorCategory = [System.Management.Automation.ErrorCategory]::InvalidArgument - $errorMessage = $($LocalizedData.FileScreenTemplateNotFoundError) -f $Path, $Template + $errorMessage = $($script:localizedData.FileScreenTemplateNotFoundError) -f $Path, $Template } } else @@ -547,7 +542,7 @@ Function Assert-ResourcePropertiesValid { $errorId = 'FileScreenTemplateEmptyError' $errorCategory = [System.Management.Automation.ErrorCategory]::InvalidArgument - $errorMessage = $($LocalizedData.FileScreenTemplateEmptyError) -f $Path + $errorMessage = $($script:localizedData.FileScreenTemplateEmptyError) -f $Path } } diff --git a/DSCResources/DSR_FSRMFileScreen/DSR_FSRMFileScreen.schema.mof b/source/DSCResources/DSC_FSRMFileScreen/DSC_FSRMFileScreen.schema.mof similarity index 95% rename from DSCResources/DSR_FSRMFileScreen/DSR_FSRMFileScreen.schema.mof rename to source/DSCResources/DSC_FSRMFileScreen/DSC_FSRMFileScreen.schema.mof index 50bbcb63..82720db2 100644 --- a/DSCResources/DSR_FSRMFileScreen/DSR_FSRMFileScreen.schema.mof +++ b/source/DSCResources/DSC_FSRMFileScreen/DSC_FSRMFileScreen.schema.mof @@ -1,5 +1,5 @@ [ClassVersion("1.0.0.0"), FriendlyName("FSRMFileScreen")] -class DSR_FSRMFileScreen : OMI_BaseResource +class DSC_FSRMFileScreen : OMI_BaseResource { [Key, Description("The path this FSRM File Screen applies to.")] String Path; [Write, Description("An optional description for this FSRM File Screen.")] String Description; diff --git a/DSCResources/DSR_FSRMFileScreen/README.md b/source/DSCResources/DSC_FSRMFileScreen/README.md similarity index 100% rename from DSCResources/DSR_FSRMFileScreen/README.md rename to source/DSCResources/DSC_FSRMFileScreen/README.md diff --git a/DSCResources/DSR_FSRMFileScreen/en-US/DSR_FSRMFileScreen.strings.psd1 b/source/DSCResources/DSC_FSRMFileScreen/en-US/DSC_FSRMFileScreen.strings.psd1 similarity index 100% rename from DSCResources/DSR_FSRMFileScreen/en-US/DSR_FSRMFileScreen.strings.psd1 rename to source/DSCResources/DSC_FSRMFileScreen/en-US/DSC_FSRMFileScreen.strings.psd1 diff --git a/DSCResources/DSR_FSRMFileScreenAction/DSR_FSRMFileScreenAction.psm1 b/source/DSCResources/DSC_FSRMFileScreenAction/DSC_FSRMFileScreenAction.psm1 similarity index 88% rename from DSCResources/DSR_FSRMFileScreenAction/DSR_FSRMFileScreenAction.psm1 rename to source/DSCResources/DSC_FSRMFileScreenAction/DSC_FSRMFileScreenAction.psm1 index 0ee9494f..1b646f1a 100644 --- a/DSCResources/DSR_FSRMFileScreenAction/DSR_FSRMFileScreenAction.psm1 +++ b/source/DSCResources/DSC_FSRMFileScreenAction/DSC_FSRMFileScreenAction.psm1 @@ -1,14 +1,9 @@ $modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules' -# Import the Networking Resource Helper Module -Import-Module -Name (Join-Path -Path $modulePath ` - -ChildPath (Join-Path -Path 'FSRMDsc.ResourceHelper' ` - -ChildPath 'FSRMDsc.ResourceHelper.psm1')) +Import-Module -Name (Join-Path -Path $modulePath -ChildPath 'DscResource.Common') # Import Localization Strings -$LocalizedData = Get-LocalizedData ` - -ResourceName 'DSR_FSRMFileScreenAction' ` - -ResourcePath (Split-Path -Parent $Script:MyInvocation.MyCommand.Path) +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS @@ -38,7 +33,7 @@ function Get-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.GettingActionMessage) ` + $($script:localizedData.GettingActionMessage) ` -f $Path, $Type ) -join '' ) @@ -49,7 +44,7 @@ function Get-TargetResource catch [Microsoft.PowerShell.Cmdletization.Cim.CimJobException] { New-InvalidArgumentException ` - -Message ($($LocalizedData.FileScreenNotFoundError) -f $Path) ` + -Message ($($script:localizedData.FileScreenNotFoundError) -f $Path) ` -ArgumentName 'Path' } @@ -64,7 +59,7 @@ function Get-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionExistsMessage) ` + $($script:localizedData.ActionExistsMessage) ` -f $Path, $Type ) -join '' ) @@ -90,7 +85,7 @@ function Get-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionNotExistMessage) ` + $($script:localizedData.ActionNotExistMessage) ` -f $Path, $Type ) -join '' ) @@ -238,7 +233,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.SettingActionMessage) ` + $($script:localizedData.SettingActionMessage) ` -f $Path, $Type ) -join '' ) @@ -254,7 +249,7 @@ function Set-TargetResource catch [Microsoft.PowerShell.Cmdletization.Cim.CimJobException] { New-InvalidArgumentException ` - -Message ($($LocalizedData.FileScreenNotFoundError) -f $Path) ` + -Message ($($script:localizedData.FileScreenNotFoundError) -f $Path) ` -ArgumentName 'Path' } @@ -278,7 +273,7 @@ function Set-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.EnsureActionExistsMessage) ` + $($script:localizedData.EnsureActionExistsMessage) ` -f $Path, $Type ) -join '' ) @@ -289,7 +284,7 @@ function Set-TargetResource # Create the action Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionCreatedMessage) ` + $($script:localizedData.ActionCreatedMessage) ` -f $Path, $Type ) -join '' ) } @@ -300,7 +295,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionUpdatedMessage) ` + $($script:localizedData.ActionUpdatedMessage) ` -f $Path, $Type ) -join '' ) } @@ -311,7 +306,7 @@ function Set-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.EnsureActionDoesNotExistMessage) ` + $($script:localizedData.EnsureActionDoesNotExistMessage) ` -f $Path, $Type ) -join '' ) @@ -320,7 +315,7 @@ function Set-TargetResource # The action doesn't exist and should not Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionNoChangeMessage) ` + $($script:localizedData.ActionNoChangeMessage) ` -f $Path, $Type ) -join '' ) @@ -333,7 +328,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionRemovedMessage) ` + $($script:localizedData.ActionRemovedMessage) ` -f $Path, $Type ) -join '' ) } # if @@ -347,7 +342,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionWrittenMessage) ` + $($script:localizedData.ActionWrittenMessage) ` -f $Path, $Type ) -join '' ) } # Set-TargetResource @@ -487,11 +482,11 @@ function Test-TargetResource ) # Flag to signal whether settings are correct - [Boolean] $desiredConfigurationMatch = $true + $desiredConfigurationMatch = $true Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.SettingActionMessage) ` + $($script:localizedData.TestingActionMessage) ` -f $Path, $Type ) -join '' ) @@ -503,7 +498,7 @@ function Test-TargetResource catch [Microsoft.PowerShell.Cmdletization.Cim.CimJobException] { New-InvalidArgumentException ` - -Message ($($LocalizedData.FileScreenNotFoundError) -f $Path) ` + -Message ($($script:localizedData.FileScreenNotFoundError) -f $Path) ` -ArgumentName 'Path' } @@ -513,7 +508,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.EnsureActionExistsMessage) ` + $($script:localizedData.EnsureActionExistsMessage) ` -f $Path, $Type ) -join '' ) @@ -526,7 +521,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Path, $Type, 'Subject' ) -join '' ) @@ -538,7 +533,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Path, $Type, 'Body' ) -join '' ) @@ -550,7 +545,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Path, $Type, 'MailBCC' ) -join '' ) @@ -562,7 +557,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Path, $Type, 'MailCC' ) -join '' ) @@ -574,7 +569,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Path, $Type, 'MailTo' ) -join '' ) @@ -586,7 +581,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Path, $Type, 'Command' ) -join '' ) @@ -598,7 +593,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Path, $Type, 'CommandParameters' ) -join '' ) @@ -610,7 +605,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Path, $Type, 'KillTimeOut' ) -join '' ) @@ -622,7 +617,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Path, $Type, 'RunLimitInterval' ) -join '' ) @@ -634,7 +629,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Path, $Type, 'SecurityLevel' ) -join '' ) @@ -646,7 +641,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Path, $Type, 'ShouldLogError' ) -join '' ) @@ -658,7 +653,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Path, $Type, 'WorkingDirectory' ) -join '' ) @@ -670,7 +665,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Path, $Type, 'EventType' ) -join '' ) @@ -692,7 +687,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Path, $Type, 'ReportTypes' ) -join '' ) @@ -705,7 +700,7 @@ function Test-TargetResource # The action does not exist but should Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionDoesNotExistButShouldMessage) ` + $($script:localizedData.ActionDoesNotExistButShouldMessage) ` -f $Path, $Type ) -join '' ) @@ -719,7 +714,7 @@ function Test-TargetResource # The Action exists, but it should be removed Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionExistsAndShouldNotMessage) ` + $($script:localizedData.ActionExistsAndShouldNotMessage) ` -f $Path, $Type ) -join '' ) @@ -730,7 +725,7 @@ function Test-TargetResource # The action doesn't exist and should not Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionDoesNotExistAndShouldNotMessage) ` + $($script:localizedData.ActionDoesNotExistAndShouldNotMessage) ` -f $Path, $Type ) -join '' ) } # if diff --git a/DSCResources/DSR_FSRMFileScreenAction/DSR_FSRMFileScreenAction.schema.mof b/source/DSCResources/DSC_FSRMFileScreenAction/DSC_FSRMFileScreenAction.schema.mof similarity index 97% rename from DSCResources/DSR_FSRMFileScreenAction/DSR_FSRMFileScreenAction.schema.mof rename to source/DSCResources/DSC_FSRMFileScreenAction/DSC_FSRMFileScreenAction.schema.mof index 41efcd61..9d635449 100644 --- a/DSCResources/DSR_FSRMFileScreenAction/DSR_FSRMFileScreenAction.schema.mof +++ b/source/DSCResources/DSC_FSRMFileScreenAction/DSC_FSRMFileScreenAction.schema.mof @@ -1,5 +1,5 @@ [ClassVersion("1.0.0.0"), FriendlyName("FSRMFileScreenAction")] -class DSR_FSRMFileScreenAction : OMI_BaseResource +class DSC_FSRMFileScreenAction : OMI_BaseResource { [Key, Description("The path of the FSRM File Screen the action applies to.")] string Path; [Key, Description("The type of FSRM Action."), ValueMap{"Email","Event","Command","Report"}, Values{"Email","Event","Command","Report"}] string Type; diff --git a/DSCResources/DSR_FSRMFileScreenAction/README.md b/source/DSCResources/DSC_FSRMFileScreenAction/README.md similarity index 100% rename from DSCResources/DSR_FSRMFileScreenAction/README.md rename to source/DSCResources/DSC_FSRMFileScreenAction/README.md diff --git a/DSCResources/DSR_FSRMFileScreenAction/en-US/DSR_FSRMFileScreenAction.strings.psd1 b/source/DSCResources/DSC_FSRMFileScreenAction/en-US/DSC_FSRMFileScreenAction.strings.psd1 similarity index 100% rename from DSCResources/DSR_FSRMFileScreenAction/en-US/DSR_FSRMFileScreenAction.strings.psd1 rename to source/DSCResources/DSC_FSRMFileScreenAction/en-US/DSC_FSRMFileScreenAction.strings.psd1 diff --git a/DSCResources/DSR_FSRMFileScreenException/DSR_FSRMFileScreenException.psm1 b/source/DSCResources/DSC_FSRMFileScreenException/DSC_FSRMFileScreenException.psm1 similarity index 84% rename from DSCResources/DSR_FSRMFileScreenException/DSR_FSRMFileScreenException.psm1 rename to source/DSCResources/DSC_FSRMFileScreenException/DSC_FSRMFileScreenException.psm1 index ac73ffa2..37def344 100644 --- a/DSCResources/DSR_FSRMFileScreenException/DSR_FSRMFileScreenException.psm1 +++ b/source/DSCResources/DSC_FSRMFileScreenException/DSC_FSRMFileScreenException.psm1 @@ -1,14 +1,9 @@ $modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules' -# Import the Networking Resource Helper Module -Import-Module -Name (Join-Path -Path $modulePath ` - -ChildPath (Join-Path -Path 'FSRMDsc.ResourceHelper' ` - -ChildPath 'FSRMDsc.ResourceHelper.psm1')) +Import-Module -Name (Join-Path -Path $modulePath -ChildPath 'DscResource.Common') # Import Localization Strings -$LocalizedData = Get-LocalizedData ` - -ResourceName 'DSR_FSRMFileScreenException' ` - -ResourcePath (Split-Path -Parent $Script:MyInvocation.MyCommand.Path) +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS @@ -30,7 +25,7 @@ function Get-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.GettingFileScreenExceptionMessage) ` + $($script:localizedData.GettingFileScreenExceptionMessage) ` -f $Path ) -join '' ) @@ -44,7 +39,7 @@ function Get-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileScreenExceptionExistsMessage) ` + $($script:localizedData.FileScreenExceptionExistsMessage) ` -f $Path ) -join '' ) @@ -58,7 +53,7 @@ function Get-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileScreenExceptionDoesNotExistMessage) ` + $($script:localizedData.FileScreenExceptionDoesNotExistMessage) ` -f $Path ) -join '' ) @@ -112,7 +107,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.SettingFileScreenExceptionMessage) ` + $($script:localizedData.SettingFileScreenExceptionMessage) ` -f $Path ) -join '' ) @@ -129,7 +124,7 @@ function Set-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.EnsureFileScreenExceptionExistsMessage) ` + $($script:localizedData.EnsureFileScreenExceptionExistsMessage) ` -f $Path ) -join '' ) @@ -141,7 +136,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileScreenExceptionUpdatedMessage) ` + $($script:localizedData.FileScreenExceptionUpdatedMessage) ` -f $Path ) -join '' ) } @@ -153,7 +148,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileScreenExceptionCreatedMessage) ` + $($script:localizedData.FileScreenExceptionCreatedMessage) ` -f $Path ) -join '' ) } # if @@ -162,7 +157,7 @@ function Set-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.EnsureFileScreenExceptionDoesNotExistMessage) ` + $($script:localizedData.EnsureFileScreenExceptionDoesNotExistMessage) ` -f $Path ) -join '' ) @@ -173,7 +168,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileScreenExceptionRemovedMessage) ` + $($script:localizedData.FileScreenExceptionRemovedMessage) ` -f $Path ) -join '' ) } # if @@ -221,11 +216,11 @@ function Test-TargetResource ) # Flag to signal whether settings are correct - [Boolean] $desiredConfigurationMatch = $true + $desiredConfigurationMatch = $true Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.TestingFileScreenExceptionMessage) ` + $($script:localizedData.TestingFileScreenExceptionMessage) ` -f $Path ) -join '' ) @@ -248,7 +243,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileScreenExceptionPropertyNeedsUpdateMessage) ` + $($script:localizedData.FileScreenExceptionPropertyNeedsUpdateMessage) ` -f $Path, 'IncludeGroup' ) -join '' ) @@ -260,7 +255,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileScreenExceptionPropertyNeedsUpdateMessage) ` + $($script:localizedData.FileScreenExceptionPropertyNeedsUpdateMessage) ` -f $Path, 'Description' ) -join '' ) @@ -272,7 +267,7 @@ function Test-TargetResource # The File Screen Exception doesn't exist but should Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileScreenExceptionDoesNotExistButShouldMessage) ` + $($script:localizedData.FileScreenExceptionDoesNotExistButShouldMessage) ` -f $Path ) -join '' ) @@ -287,7 +282,7 @@ function Test-TargetResource # The File Screen Exception exists but should not Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileScreenExceptionExistsButShouldNotMessage) ` + $($script:localizedData.FileScreenExceptionExistsButShouldNotMessage) ` -f $Path ) -join '' ) @@ -298,7 +293,7 @@ function Test-TargetResource # The File Screen Exception does not exist and should not Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileScreenExceptionDoesNotExistAndShouldNotMessage) ` + $($script:localizedData.FileScreenExceptionDoesNotExistAndShouldNotMessage) ` -f $Path ) -join '' ) } # if @@ -314,7 +309,7 @@ function Test-TargetResource .PARAMETER Path The path this FSRM File Screen applies to. #> -Function Get-FileScreenException +function Get-FileScreenException { param ( @@ -333,7 +328,7 @@ Function Get-FileScreenException } catch { - Throw $_ + throw $_ } return $fileScreenException @@ -356,7 +351,7 @@ Function Get-FileScreenException .PARAMETER IncludeGroup An array of File Groups to include in this File Screen. #> -Function Assert-ResourcePropertiesValid +function Assert-ResourcePropertiesValid { [CmdletBinding()] param @@ -382,7 +377,7 @@ Function Assert-ResourcePropertiesValid # Check the path exists if (-not (Test-Path -Path $Path)) { - $errorMessage = $($LocalizedData.FileScreenExceptionPathDoesNotExistError) -f $Path + $errorMessage = $($script:localizedData.FileScreenExceptionPathDoesNotExistError) -f $Path $errorArgumentName = 'Path' } # if diff --git a/DSCResources/DSR_FSRMFileScreenException/DSR_FSRMFileScreenException.schema.mof b/source/DSCResources/DSC_FSRMFileScreenException/DSC_FSRMFileScreenException.schema.mof similarity index 90% rename from DSCResources/DSR_FSRMFileScreenException/DSR_FSRMFileScreenException.schema.mof rename to source/DSCResources/DSC_FSRMFileScreenException/DSC_FSRMFileScreenException.schema.mof index 82d76cc0..a6fe1fe2 100644 --- a/DSCResources/DSR_FSRMFileScreenException/DSR_FSRMFileScreenException.schema.mof +++ b/source/DSCResources/DSC_FSRMFileScreenException/DSC_FSRMFileScreenException.schema.mof @@ -1,5 +1,5 @@ [ClassVersion("1.0.0.0"), FriendlyName("FSRMFileScreenException")] -class DSR_FSRMFileScreenException : OMI_BaseResource +class DSC_FSRMFileScreenException : OMI_BaseResource { [Key, Description("The path this FSRM File Screen applies to.")] String Path; [Write, Description("An optional description for this FSRM File Screen.")] String Description; diff --git a/DSCResources/DSR_FSRMFileScreenException/README.md b/source/DSCResources/DSC_FSRMFileScreenException/README.md similarity index 100% rename from DSCResources/DSR_FSRMFileScreenException/README.md rename to source/DSCResources/DSC_FSRMFileScreenException/README.md diff --git a/DSCResources/DSR_FSRMFileScreenException/en-US/DSR_FSRMFileScreenException.strings.psd1 b/source/DSCResources/DSC_FSRMFileScreenException/en-US/DSC_FSRMFileScreenException.strings.psd1 similarity index 83% rename from DSCResources/DSR_FSRMFileScreenException/en-US/DSR_FSRMFileScreenException.strings.psd1 rename to source/DSCResources/DSC_FSRMFileScreenException/en-US/DSC_FSRMFileScreenException.strings.psd1 index 5a083824..74172642 100644 --- a/DSCResources/DSR_FSRMFileScreenException/en-US/DSR_FSRMFileScreenException.strings.psd1 +++ b/source/DSCResources/DSC_FSRMFileScreenException/en-US/DSC_FSRMFileScreenException.strings.psd1 @@ -7,7 +7,6 @@ ConvertFrom-StringData -StringData @' EnsureFileScreenExceptionDoesNotExistMessage = Ensuring FSRM File Screen Exception "{0}" does not exist. FileScreenExceptionCreatedMessage = FSRM File Screen Exception "{0}" has been created. FileScreenExceptionUpdatedMessage = FSRM File Screen Exception "{0}" has been updated. - FileScreenExceptionRecreatedMessage = FSRM File Screen Exception "{0}" has been recreated. FileScreenExceptionRemovedMessage = FSRM File Screen Exception "{0}" has been removed. TestingFileScreenExceptionMessage = Testing FSRM File Screen Exception "{0}". FileScreenExceptionPropertyNeedsUpdateMessage = FSRM File Screen Exception "{0}" {1} is different. Change required. @@ -15,6 +14,4 @@ ConvertFrom-StringData -StringData @' FileScreenExceptionExistsButShouldNotMessage = FSRM File Screen Exception "{0}" exists but should not. Change required. FileScreenExceptionDoesNotExistAndShouldNotMessage = FSRM File Screen Exception "{0}" does not exist and should not. Change not required. FileScreenExceptionPathDoesNotExistError = FSRM File Screen Exception "{0}" path does not exist. - FileScreenExceptionTemplateEmptyError = FSRM File Screen Exception "{0}" requires a template name to be set. - FileScreenExceptionTemplateNotFoundError = FSRM File Screen Exception "{0}" template "{1}" not found. '@ diff --git a/DSCResources/DSR_FSRMFileScreenTemplate/DSR_FSRMFileScreenTemplate.psm1 b/source/DSCResources/DSC_FSRMFileScreenTemplate/DSC_FSRMFileScreenTemplate.psm1 similarity index 83% rename from DSCResources/DSR_FSRMFileScreenTemplate/DSR_FSRMFileScreenTemplate.psm1 rename to source/DSCResources/DSC_FSRMFileScreenTemplate/DSC_FSRMFileScreenTemplate.psm1 index 7ba533ce..d258a99c 100644 --- a/DSCResources/DSR_FSRMFileScreenTemplate/DSR_FSRMFileScreenTemplate.psm1 +++ b/source/DSCResources/DSC_FSRMFileScreenTemplate/DSC_FSRMFileScreenTemplate.psm1 @@ -1,14 +1,9 @@ $modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules' -# Import the Networking Resource Helper Module -Import-Module -Name (Join-Path -Path $modulePath ` - -ChildPath (Join-Path -Path 'FSRMDsc.ResourceHelper' ` - -ChildPath 'FSRMDsc.ResourceHelper.psm1')) +Import-Module -Name (Join-Path -Path $modulePath -ChildPath 'DscResource.Common') # Import Localization Strings -$LocalizedData = Get-LocalizedData ` - -ResourceName 'DSR_FSRMFileScreenTemplate' ` - -ResourcePath (Split-Path -Parent $Script:MyInvocation.MyCommand.Path) +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS @@ -30,7 +25,7 @@ function Get-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.GettingFileScreenTemplateMessage) ` + $($script:localizedData.GettingFileScreenTemplateMessage) ` -f $Name ) -join '' ) @@ -45,7 +40,7 @@ function Get-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileScreenTemplateExistsMessage) ` + $($script:localizedData.FileScreenTemplateExistsMessage) ` -f $Name ) -join '' ) @@ -60,7 +55,7 @@ function Get-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileScreenTemplateDoesNotExistMessage) ` + $($script:localizedData.FileScreenTemplateDoesNotExistMessage) ` -f $Name ) -join '' ) @@ -120,6 +115,12 @@ function Set-TargetResource $IncludeGroup ) + Write-Verbose -Message ( @( + "$($MyInvocation.MyCommand): " + $($script:localizedData.SettingFileScreenTemplateMessage) ` + -f $Name + ) -join '' ) + # Remove any parameters that can't be splatted. $null = $PSBoundParameters.Remove('Ensure') @@ -130,7 +131,7 @@ function Set-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.EnsureFileScreenTemplateExistsMessage) ` + $($script:localizedData.EnsureFileScreenTemplateExistsMessage) ` -f $Name ) -join '' ) @@ -142,7 +143,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileScreenTemplateUpdatedMessage) ` + $($script:localizedData.FileScreenTemplateUpdatedMessage) ` -f $Name ) -join '' ) } @@ -154,7 +155,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileScreenTemplateCreatedMessage) ` + $($script:localizedData.FileScreenTemplateCreatedMessage) ` -f $Name ) -join '' ) } @@ -163,7 +164,7 @@ function Set-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.EnsureFileScreenTemplateDoesNotExistMessage) ` + $($script:localizedData.EnsureFileScreenTemplateDoesNotExistMessage) ` -f $Name ) -join '' ) @@ -176,7 +177,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileScreenTemplateRemovedMessage) ` + $($script:localizedData.FileScreenTemplateRemovedMessage) ` -f $Name ) -join '' ) } # if @@ -232,11 +233,11 @@ function Test-TargetResource ) # Flag to signal whether settings are correct - [Boolean] $desiredConfigurationMatch = $true + $desiredConfigurationMatch = $true Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.TestingFileScreenTemplateMessage) ` + $($script:localizedData.TestingFileScreenTemplateMessage) ` -f $Name ) -join '' ) @@ -254,7 +255,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileScreenTemplatePropertyNeedsUpdateMessage) ` + $($script:localizedData.FileScreenTemplatePropertyNeedsUpdateMessage) ` -f $Name, 'Description' ) -join '' ) @@ -266,7 +267,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileScreenTemplatePropertyNeedsUpdateMessage) ` + $($script:localizedData.FileScreenTemplatePropertyNeedsUpdateMessage) ` -f $Name, 'Active' ) -join '' ) @@ -280,7 +281,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileScreenTemplatePropertyNeedsUpdateMessage) ` + $($script:localizedData.FileScreenTemplatePropertyNeedsUpdateMessage) ` -f $Name, 'IncludeGroup' ) -join '' ) @@ -292,7 +293,7 @@ function Test-TargetResource # Ths File Screen Template doesn't exist but should Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileScreenTemplateDoesNotExistButShouldMessage) ` + $($script:localizedData.FileScreenTemplateDoesNotExistButShouldMessage) ` -f $Name ) -join '' ) @@ -307,7 +308,7 @@ function Test-TargetResource # The File Screen Template exists but should not Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileScreenTemplateExistsButShouldNotMessage) ` + $($script:localizedData.FileScreenTemplateExistsButShouldNotMessage) ` -f $Name ) -join '' ) @@ -318,7 +319,7 @@ function Test-TargetResource # The File Screen Template does not exist and should not Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.FileScreenTemplateDoesNotExistAndShouldNotMessage) ` + $($script:localizedData.FileScreenTemplateDoesNotExistAndShouldNotMessage) ` -f $Name ) -join '' ) } @@ -334,7 +335,7 @@ function Test-TargetResource .PARAMETER Name The name of the FSRM File Template. #> -Function Get-FileScreenTemplate +function Get-FileScreenTemplate { param ( @@ -355,7 +356,7 @@ Function Get-FileScreenTemplate } catch { - Throw $_ + throw $_ } return $fileScreenTemplate diff --git a/DSCResources/DSR_FSRMFileScreenTemplate/DSR_FSRMFileScreenTemplate.schema.mof b/source/DSCResources/DSC_FSRMFileScreenTemplate/DSC_FSRMFileScreenTemplate.schema.mof similarity index 92% rename from DSCResources/DSR_FSRMFileScreenTemplate/DSR_FSRMFileScreenTemplate.schema.mof rename to source/DSCResources/DSC_FSRMFileScreenTemplate/DSC_FSRMFileScreenTemplate.schema.mof index 932d47a5..97576412 100644 --- a/DSCResources/DSR_FSRMFileScreenTemplate/DSR_FSRMFileScreenTemplate.schema.mof +++ b/source/DSCResources/DSC_FSRMFileScreenTemplate/DSC_FSRMFileScreenTemplate.schema.mof @@ -1,5 +1,5 @@ [ClassVersion("1.0.0.0"), FriendlyName("FSRMFileScreenTemplate")] -class DSR_FSRMFileScreenTemplate : OMI_BaseResource +class DSC_FSRMFileScreenTemplate : OMI_BaseResource { [Key, Description("The unique name for this FSRM File Screen Template.")] String Name; [Write, Description("An optional description for this FSRM File Screen Template.")] String Description; diff --git a/DSCResources/DSR_FSRMFileScreenTemplate/README.md b/source/DSCResources/DSC_FSRMFileScreenTemplate/README.md similarity index 100% rename from DSCResources/DSR_FSRMFileScreenTemplate/README.md rename to source/DSCResources/DSC_FSRMFileScreenTemplate/README.md diff --git a/DSCResources/DSR_FSRMFileScreenTemplate/en-US/DSR_FSRMFileScreenTemplate.strings.psd1 b/source/DSCResources/DSC_FSRMFileScreenTemplate/en-US/DSC_FSRMFileScreenTemplate.strings.psd1 similarity index 100% rename from DSCResources/DSR_FSRMFileScreenTemplate/en-US/DSR_FSRMFileScreenTemplate.strings.psd1 rename to source/DSCResources/DSC_FSRMFileScreenTemplate/en-US/DSC_FSRMFileScreenTemplate.strings.psd1 diff --git a/DSCResources/DSR_FSRMFileScreenTemplateAction/DSR_FSRMFileScreenTemplateAction.psm1 b/source/DSCResources/DSC_FSRMFileScreenTemplateAction/DSC_FSRMFileScreenTemplateAction.psm1 similarity index 87% rename from DSCResources/DSR_FSRMFileScreenTemplateAction/DSR_FSRMFileScreenTemplateAction.psm1 rename to source/DSCResources/DSC_FSRMFileScreenTemplateAction/DSC_FSRMFileScreenTemplateAction.psm1 index 1a5f5728..d739c061 100644 --- a/DSCResources/DSR_FSRMFileScreenTemplateAction/DSR_FSRMFileScreenTemplateAction.psm1 +++ b/source/DSCResources/DSC_FSRMFileScreenTemplateAction/DSC_FSRMFileScreenTemplateAction.psm1 @@ -1,14 +1,9 @@ $modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules' -# Import the Networking Resource Helper Module -Import-Module -Name (Join-Path -Path $modulePath ` - -ChildPath (Join-Path -Path 'FSRMDsc.ResourceHelper' ` - -ChildPath 'FSRMDsc.ResourceHelper.psm1')) +Import-Module -Name (Join-Path -Path $modulePath -ChildPath 'DscResource.Common') # Import Localization Strings -$LocalizedData = Get-LocalizedData ` - -ResourceName 'DSR_FSRMFileScreenTemplateAction' ` - -ResourcePath (Split-Path -Parent $Script:MyInvocation.MyCommand.Path) +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS @@ -38,7 +33,7 @@ function Get-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.GettingActionMessage) ` + $($script:localizedData.GettingActionMessage) ` -f $Name, $Type ) -join '' ) @@ -49,7 +44,7 @@ function Get-TargetResource catch [Microsoft.PowerShell.Cmdletization.Cim.CimJobException] { New-InvalidArgumentException ` - -Message ($($LocalizedData.FileScreenTemplateNotFoundError) -f $Name, $Type) ` + -Message ($($script:localizedData.FileScreenTemplateNotFoundError) -f $Name, $Type) ` -ArgumentName 'Name' } # try @@ -64,7 +59,7 @@ function Get-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionExistsMessage) ` + $($script:localizedData.ActionExistsMessage) ` -f $Name, $Type ) -join '' ) @@ -90,7 +85,7 @@ function Get-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionNotExistMessage) ` + $($script:localizedData.ActionNotExistMessage) ` -f $Name, $Type ) -join '' ) @@ -238,7 +233,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.SettingActionMessage) ` + $($script:localizedData.SettingActionMessage) ` -f $Name, $Type ) -join '' ) @@ -254,7 +249,7 @@ function Set-TargetResource catch [Microsoft.PowerShell.Cmdletization.Cim.CimJobException] { New-InvalidArgumentException ` - -Message ($($LocalizedData.FileScreenTemplateNotFoundError) -f $Name, $Type) ` + -Message ($($script:localizedData.FileScreenTemplateNotFoundError) -f $Name, $Type) ` -ArgumentName 'Name' } # try @@ -278,7 +273,7 @@ function Set-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.EnsureActionExistsMessage) ` + $($script:localizedData.EnsureActionExistsMessage) ` -f $Name, $Type ) -join '' ) @@ -289,7 +284,7 @@ function Set-TargetResource # Create the action Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionCreatedMessage) ` + $($script:localizedData.ActionCreatedMessage) ` -f $Name, $Type ) -join '' ) } @@ -300,7 +295,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionUpdatedMessage) ` + $($script:localizedData.ActionUpdatedMessage) ` -f $Name, $Type ) -join '' ) } # if @@ -311,7 +306,7 @@ function Set-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.EnsureActionDoesNotExistMessage) ` + $($script:localizedData.EnsureActionDoesNotExistMessage) ` -f $Name, $Type ) -join '' ) @@ -320,7 +315,7 @@ function Set-TargetResource # The action doesn't exist and should not Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionNoChangeMessage) ` + $($script:localizedData.ActionNoChangeMessage) ` -f $Name, $Type ) -join '' ) return @@ -332,7 +327,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionRemovedMessage) ` + $($script:localizedData.ActionRemovedMessage) ` -f $Name, $Type ) -join '' ) } # if @@ -346,7 +341,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionWrittenMessage) ` + $($script:localizedData.ActionWrittenMessage) ` -f $Name, $Type ) -join '' ) } # Set-TargetResource @@ -486,11 +481,11 @@ function Test-TargetResource ) # Flag to signal whether settings are correct - [Boolean] $desiredConfigurationMatch = $true + $desiredConfigurationMatch = $true Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.SettingActionMessage) ` + $($script:localizedData.TestingActionMessage) ` -f $Name, $Type ) -join '' ) @@ -502,30 +497,29 @@ function Test-TargetResource catch [Microsoft.PowerShell.Cmdletization.Cim.CimJobException] { New-InvalidArgumentException ` - -Message ($($LocalizedData.FileScreenTemplateNotFoundError) -f $Name, $Type) ` + -Message ($($script:localizedData.FileScreenTemplateNotFoundError) -f $Name, $Type) ` -ArgumentName 'Name' } # try - $action = $actions | Where-Object { $_.Type -eq $Type } + $action = $actions | Where-Object -FilterScript { $_.Type -eq $Type } if ($Ensure -eq 'Present') { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.EnsureActionExistsMessage) ` + $($script:localizedData.EnsureActionExistsMessage) ` -f $Name, $Type ) -join '' ) if ($action) { # The action exists - check it - #region Parameter Checks if (($PSBoundParameters.ContainsKey('Subject')) ` -and ($action.Subject -ne $Subject)) { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Name, $Type, 'Subject' ) -join '' ) @@ -537,7 +531,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Name, $Type, 'Body' ) -join '' ) @@ -549,7 +543,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Name, $Type, 'MailBCC' ) -join '' ) @@ -561,7 +555,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Name, $Type, 'MailCC' ) -join '' ) @@ -573,7 +567,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Name, $Type, 'MailTo' ) -join '' ) @@ -585,7 +579,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Name, $Type, 'Command' ) -join '' ) @@ -597,7 +591,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Name, $Type, 'CommandParameters' ) -join '' ) @@ -609,7 +603,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Name, $Type, 'KillTimeOut' ) -join '' ) @@ -621,7 +615,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Name, $Type, 'RunLimitInterval' ) -join '' ) @@ -633,7 +627,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Name, $Type, 'SecurityLevel' ) -join '' ) @@ -645,7 +639,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Name, $Type, 'ShouldLogError' ) -join '' ) @@ -657,7 +651,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Name, $Type, 'WorkingDirectory' ) -join '' ) @@ -669,7 +663,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Name, $Type, 'EventType' ) -join '' ) @@ -691,20 +685,19 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Name, $Type, 'ReportTypes' ) -join '' ) $desiredConfigurationMatch = $false } # if - #endregion } else { # The action does not exist but should Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionDoesNotExistButShouldMessage) ` + $($script:localizedData.ActionDoesNotExistButShouldMessage) ` -f $Name, $Type ) -join '' ) @@ -718,7 +711,7 @@ function Test-TargetResource # The Action exists, but it should be removed Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionExistsAndShouldNotMessage) ` + $($script:localizedData.ActionExistsAndShouldNotMessage) ` -f $Name, $Type ) -join '' ) @@ -729,7 +722,7 @@ function Test-TargetResource # The action doesn't exist and should not Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionDoesNotExistAndShouldNotMessage) ` + $($script:localizedData.ActionDoesNotExistAndShouldNotMessage) ` -f $Name, $Type ) -join '' ) } # if @@ -751,7 +744,7 @@ function Test-TargetResource .PARAMETER Type The type of FSRM Action. #> -Function Get-Action +function Get-Action { param ( @@ -778,7 +771,7 @@ Function Get-Action catch [Microsoft.PowerShell.Cmdletization.Cim.CimJobException] { New-InvalidArgumentException ` - -Message ($($LocalizedData.FileScreenTemplateNotFoundError) -f $Name, $Type) ` + -Message ($($script:localizedData.FileScreenTemplateNotFoundError) -f $Name, $Type) ` -ArgumentName 'Name' } # try diff --git a/DSCResources/DSR_FSRMFileScreenTemplateAction/DSR_FSRMFileScreenTemplateAction.schema.mof b/source/DSCResources/DSC_FSRMFileScreenTemplateAction/DSC_FSRMFileScreenTemplateAction.schema.mof similarity index 97% rename from DSCResources/DSR_FSRMFileScreenTemplateAction/DSR_FSRMFileScreenTemplateAction.schema.mof rename to source/DSCResources/DSC_FSRMFileScreenTemplateAction/DSC_FSRMFileScreenTemplateAction.schema.mof index c9aa51e4..db21bbe3 100644 --- a/DSCResources/DSR_FSRMFileScreenTemplateAction/DSR_FSRMFileScreenTemplateAction.schema.mof +++ b/source/DSCResources/DSC_FSRMFileScreenTemplateAction/DSC_FSRMFileScreenTemplateAction.schema.mof @@ -1,5 +1,5 @@ [ClassVersion("1.0.0.0"), FriendlyName("FSRMFileScreenTemplateAction")] -class DSR_FSRMFileScreenTemplateAction : OMI_BaseResource +class DSC_FSRMFileScreenTemplateAction : OMI_BaseResource { [Key, Description("The name of the FSRM File Screen Template that this Action is attached to.")] string Name; [Key, Description("The type of FSRM Action."), ValueMap{"Email","Event","Command","Report"}, Values{"Email","Event","Command","Report"}] string Type; diff --git a/DSCResources/DSR_FSRMFileScreenTemplateAction/README.md b/source/DSCResources/DSC_FSRMFileScreenTemplateAction/README.md similarity index 100% rename from DSCResources/DSR_FSRMFileScreenTemplateAction/README.md rename to source/DSCResources/DSC_FSRMFileScreenTemplateAction/README.md diff --git a/DSCResources/DSR_FSRMFileScreenTemplateAction/en-US/DSR_FSRMFileScreenTemplateAction.strings.psd1 b/source/DSCResources/DSC_FSRMFileScreenTemplateAction/en-US/DSC_FSRMFileScreenTemplateAction.strings.psd1 similarity index 95% rename from DSCResources/DSR_FSRMFileScreenTemplateAction/en-US/DSR_FSRMFileScreenTemplateAction.strings.psd1 rename to source/DSCResources/DSC_FSRMFileScreenTemplateAction/en-US/DSC_FSRMFileScreenTemplateAction.strings.psd1 index d2ca4ddb..7a876b52 100644 --- a/DSCResources/DSR_FSRMFileScreenTemplateAction/en-US/DSR_FSRMFileScreenTemplateAction.strings.psd1 +++ b/source/DSCResources/DSC_FSRMFileScreenTemplateAction/en-US/DSC_FSRMFileScreenTemplateAction.strings.psd1 @@ -16,5 +16,4 @@ ConvertFrom-StringData -StringData @' ActionExistsAndShouldNotMessage = FSRM File Screen Template Action for {1} "{0}" exists but should not. Change required. ActionDoesNotExistAndShouldNotMessage = FSRM File Screen Template Action for {1} "{0}" does not exist and should not. Change not required. FileScreenTemplateNotFoundError = FSRM File Screen Template "{0}" not found. - FileScreenTemplateThresholdNotFoundError = FSRM File Screen Template "{0}" not found. '@ diff --git a/DSCResources/DSR_FSRMQuota/DSR_FSRMQuota.psm1 b/source/DSCResources/DSC_FSRMQuota/DSC_FSRMQuota.psm1 similarity index 88% rename from DSCResources/DSR_FSRMQuota/DSR_FSRMQuota.psm1 rename to source/DSCResources/DSC_FSRMQuota/DSC_FSRMQuota.psm1 index 7d3af39b..a6648b39 100644 --- a/DSCResources/DSR_FSRMQuota/DSR_FSRMQuota.psm1 +++ b/source/DSCResources/DSC_FSRMQuota/DSC_FSRMQuota.psm1 @@ -1,14 +1,9 @@ $modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules' -# Import the Networking Resource Helper Module -Import-Module -Name (Join-Path -Path $modulePath ` - -ChildPath (Join-Path -Path 'FSRMDsc.ResourceHelper' ` - -ChildPath 'FSRMDsc.ResourceHelper.psm1')) +Import-Module -Name (Join-Path -Path $modulePath -ChildPath 'DscResource.Common') # Import Localization Strings -$LocalizedData = Get-LocalizedData ` - -ResourceName 'DSR_FSRMQuota' ` - -ResourcePath (Split-Path -Parent $Script:MyInvocation.MyCommand.Path) +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS @@ -30,7 +25,7 @@ function Get-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.GettingQuotaMessage) ` + $($script:localizedData.GettingQuotaMessage) ` -f $Path ) -join '' ) @@ -45,7 +40,7 @@ function Get-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.QuotaExistsMessage) ` + $($script:localizedData.QuotaExistsMessage) ` -f $Path ) -join '' ) @@ -64,7 +59,7 @@ function Get-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.QuotaDoesNotExistMessage) ` + $($script:localizedData.QuotaDoesNotExistMessage) ` -f $Path ) -join '' ) @@ -155,7 +150,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.SettingQuotaMessage) ` + $($script:localizedData.SettingQuotaMessage) ` -f $Path ) -join '' ) @@ -174,7 +169,7 @@ function Set-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.EnsureQuotaExistsMessage) ` + $($script:localizedData.EnsureQuotaExistsMessage) ` -f $Path ) -join '' ) @@ -200,7 +195,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.QuotaThresholdAddedMessage) ` + $($script:localizedData.QuotaThresholdAddedMessage) ` -f $Path, $ThresholdPercentage ) -join '' ) } @@ -215,14 +210,14 @@ function Set-TargetResource # Scan through the existing thresholds and remove any that are misssing for ($counter = $thresholds.Count - 1; $counter -ge 0; $counter--) { - If ($thresholds[$counter].Percentage -notin $ThresholdPercentages) + if ($thresholds[$counter].Percentage -notin $ThresholdPercentages) { # The threshold percentage exists but shouldn not so remove it $thresholds.Remove($counter) Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.QuotaThresholdRemovedMessage) ` + $($script:localizedData.QuotaThresholdRemovedMessage) ` -f $Path, $thresholds[$counter].Percentage ) -join '' ) } @@ -254,7 +249,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.QuotaRecreatedMessage) ` + $($script:localizedData.QuotaRecreatedMessage) ` -f $Path ) -join '' ) } @@ -267,7 +262,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.QuotaUpdatedMessage) ` + $($script:localizedData.QuotaUpdatedMessage) ` -f $Path ) -join '' ) } @@ -280,7 +275,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.QuotaCreatedMessage) ` + $($script:localizedData.QuotaCreatedMessage) ` -f $Path ) -join '' ) } @@ -289,7 +284,7 @@ function Set-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.EnsureQuotaDoesNotExistMessage) ` + $($script:localizedData.EnsureQuotaDoesNotExistMessage) ` -f $Path ) -join '' ) @@ -300,7 +295,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.QuotaRemovedMessage) ` + $($script:localizedData.QuotaRemovedMessage) ` -f $Path ) -join '' ) } # if @@ -385,11 +380,11 @@ function Test-TargetResource ) # Flag to signal whether settings are correct - [Boolean] $desiredConfigurationMatch = $true + $desiredConfigurationMatch = $true Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.TestingQuotaMessage) ` + $($script:localizedData.TestingQuotaMessage) ` -f $Path ) -join '' ) @@ -412,7 +407,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.QuotaDoesNotMatchTemplateNeedsUpdateMessage) ` + $($script:localizedData.QuotaDoesNotMatchTemplateNeedsUpdateMessage) ` -f $Path, 'Description' ) -join '' ) @@ -426,7 +421,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.QuotaPropertyNeedsUpdateMessage) ` + $($script:localizedData.QuotaPropertyNeedsUpdateMessage) ` -f $Path, 'Size' ) -join '' ) @@ -438,7 +433,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.QuotaPropertyNeedsUpdateMessage) ` + $($script:localizedData.QuotaPropertyNeedsUpdateMessage) ` -f $Path, 'SoftLimit' ) -join '' ) @@ -453,7 +448,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.QuotaPropertyNeedsUpdateMessage) ` + $($script:localizedData.QuotaPropertyNeedsUpdateMessage) ` -f $Path, 'ThresholdPercentages' ) -join '' ) @@ -466,7 +461,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.QuotaPropertyNeedsUpdateMessage) ` + $($script:localizedData.QuotaPropertyNeedsUpdateMessage) ` -f $Path, 'Description' ) -join '' ) @@ -478,7 +473,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.QuotaPropertyNeedsUpdateMessage) ` + $($script:localizedData.QuotaPropertyNeedsUpdateMessage) ` -f $Path, 'Disabled' ) -join '' ) @@ -490,7 +485,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.QuotaPropertyNeedsUpdateMessage) ` + $($script:localizedData.QuotaPropertyNeedsUpdateMessage) ` -f $Path, 'Template' ) -join '' ) @@ -502,7 +497,7 @@ function Test-TargetResource # Ths Quota doesn't exist but should Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.QuotaDoesNotExistButShouldMessage) ` + $($script:localizedData.QuotaDoesNotExistButShouldMessage) ` -f $Path ) -join '' ) @@ -517,7 +512,7 @@ function Test-TargetResource # The Quota exists but should not Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.QuotaExistsButShouldNotMessage) ` + $($script:localizedData.QuotaExistsButShouldNotMessage) ` -f $Path ) -join '' ) @@ -528,7 +523,7 @@ function Test-TargetResource # The Quota does not exist and should not Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.QuotaDoesNotExistAndShouldNotMessage) ` + $($script:localizedData.QuotaDoesNotExistAndShouldNotMessage) ` -f $Path ) -join '' ) } @@ -544,7 +539,7 @@ function Test-TargetResource .PARAMETER Path The path this FSRM Quota applies to. #> -Function Get-Quota +function Get-Quota { param ( @@ -563,7 +558,7 @@ Function Get-Quota } catch { - Throw $_ + throw $_ } return $quota @@ -602,7 +597,7 @@ Function Get-Quota Causes the template to use only the template name and ignore Size, SoftLimit and ThresholdPercentage parameters. #> -Function Assert-ResourcePropertiesValid +function Assert-ResourcePropertiesValid { [CmdletBinding()] param @@ -649,7 +644,7 @@ Function Assert-ResourcePropertiesValid # Check the path exists if (-not (Test-Path -Path $Path)) { - $errorMessage = $($LocalizedData.QuotaPathDoesNotExistError) -f $Path + $errorMessage = $($script:localizedData.QuotaPathDoesNotExistError) -f $Path $errorArgumentName = 'Path' } @@ -668,7 +663,7 @@ Function Assert-ResourcePropertiesValid } catch [Microsoft.PowerShell.Cmdletization.Cim.CimJobException] { - $errorMessage = $($LocalizedData.QuotaTemplateNotFoundError) -f $Path, $Template + $errorMessage = $($script:localizedData.QuotaTemplateNotFoundError) -f $Path, $Template $errorArgumentName = 'Path' } } @@ -677,7 +672,7 @@ Function Assert-ResourcePropertiesValid # A template wasn't specifed, ensure the matches template flag is false if ($MatchesTemplate) { - $errorMessage = $($LocalizedData.QuotaTemplateEmptyError) -f $Path + $errorMessage = $($script:localizedData.QuotaTemplateEmptyError) -f $Path $errorArgumentName = 'Path' } } diff --git a/DSCResources/DSR_FSRMQuota/DSR_FSRMQuota.schema.mof b/source/DSCResources/DSC_FSRMQuota/DSC_FSRMQuota.schema.mof similarity index 96% rename from DSCResources/DSR_FSRMQuota/DSR_FSRMQuota.schema.mof rename to source/DSCResources/DSC_FSRMQuota/DSC_FSRMQuota.schema.mof index 68f76839..8c958120 100644 --- a/DSCResources/DSR_FSRMQuota/DSR_FSRMQuota.schema.mof +++ b/source/DSCResources/DSC_FSRMQuota/DSC_FSRMQuota.schema.mof @@ -1,5 +1,5 @@ [ClassVersion("1.0.0.0"), FriendlyName("FSRMQuota")] -class DSR_FSRMQuota : OMI_BaseResource +class DSC_FSRMQuota : OMI_BaseResource { [Key, Description("The path this FSRM Quota applies to.")] String Path; [Write, Description("An optional description for this FSRM Quota.")] String Description; diff --git a/DSCResources/DSR_FSRMQuota/README.md b/source/DSCResources/DSC_FSRMQuota/README.md similarity index 100% rename from DSCResources/DSR_FSRMQuota/README.md rename to source/DSCResources/DSC_FSRMQuota/README.md diff --git a/DSCResources/DSR_FSRMQuota/en-US/DSR_FSRMQuota.strings.psd1 b/source/DSCResources/DSC_FSRMQuota/en-US/DSC_FSRMQuota.strings.psd1 similarity index 100% rename from DSCResources/DSR_FSRMQuota/en-US/DSR_FSRMQuota.strings.psd1 rename to source/DSCResources/DSC_FSRMQuota/en-US/DSC_FSRMQuota.strings.psd1 diff --git a/DSCResources/DSR_FSRMQuotaAction/DSR_FSRMQuotaAction.psm1 b/source/DSCResources/DSC_FSRMQuotaAction/DSC_FSRMQuotaAction.psm1 similarity index 88% rename from DSCResources/DSR_FSRMQuotaAction/DSR_FSRMQuotaAction.psm1 rename to source/DSCResources/DSC_FSRMQuotaAction/DSC_FSRMQuotaAction.psm1 index a5c5b314..2802745e 100644 --- a/DSCResources/DSR_FSRMQuotaAction/DSR_FSRMQuotaAction.psm1 +++ b/source/DSCResources/DSC_FSRMQuotaAction/DSC_FSRMQuotaAction.psm1 @@ -1,14 +1,9 @@ $modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules' -# Import the Networking Resource Helper Module -Import-Module -Name (Join-Path -Path $modulePath ` - -ChildPath (Join-Path -Path 'FSRMDsc.ResourceHelper' ` - -ChildPath 'FSRMDsc.ResourceHelper.psm1')) +Import-Module -Name (Join-Path -Path $modulePath -ChildPath 'DscResource.Common') # Import Localization Strings -$LocalizedData = Get-LocalizedData ` - -ResourceName 'DSR_FSRMQuotaAction' ` - -ResourcePath (Split-Path -Parent $Script:MyInvocation.MyCommand.Path) +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS @@ -46,7 +41,7 @@ function Get-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.GettingActionMessage) ` + $($script:localizedData.GettingActionMessage) ` -f $Path, $Percentage, $Type ) -join '' ) @@ -67,7 +62,7 @@ function Get-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionNotExistMessage) ` + $($script:localizedData.ActionNotExistMessage) ` -f $Path, $Percentage, $Type ) -join '' ) @@ -79,7 +74,7 @@ function Get-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionExistsMessage) ` + $($script:localizedData.ActionExistsMessage) ` -f $Path, $Percentage, $Type ) -join '' ) @@ -250,7 +245,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.SettingActionMessage) ` + $($script:localizedData.SettingActionMessage) ` -f $Path, $Percentage, $Type ) -join '' ) @@ -270,7 +265,7 @@ function Set-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.EnsureActionExistsMessage) ` + $($script:localizedData.EnsureActionExistsMessage) ` -f $Path, $Percentage, $Type ) -join '' ) @@ -281,7 +276,7 @@ function Set-TargetResource # Create the action Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionCreatedMessage) ` + $($script:localizedData.ActionCreatedMessage) ` -f $Path, $Percentage, $Type ) -join '' ) } @@ -292,7 +287,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionUpdatedMessage) ` + $($script:localizedData.ActionUpdatedMessage) ` -f $Path, $Percentage, $Type ) -join '' ) } @@ -303,7 +298,7 @@ function Set-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.EnsureActionDoesNotExistMessage) ` + $($script:localizedData.EnsureActionDoesNotExistMessage) ` -f $Path, $Percentage, $Type ) -join '' ) @@ -312,7 +307,7 @@ function Set-TargetResource # The action doesn't exist and should not Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionNoChangeMessage) ` + $($script:localizedData.ActionNoChangeMessage) ` -f $Path, $Percentage, $Type ) -join '' ) return @@ -324,7 +319,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionRemovedMessage) ` + $($script:localizedData.ActionRemovedMessage) ` -f $Path, $Percentage, $Type ) -join '' ) } # if @@ -338,7 +333,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionWrittenMessage) ` + $($script:localizedData.ActionWrittenMessage) ` -f $Path, $Percentage, $Type ) -join '' ) } # Set-TargetResource @@ -485,11 +480,11 @@ function Test-TargetResource $ReportTypes ) # Flag to signal whether settings are correct - [Boolean] $desiredConfigurationMatch = $true + $desiredConfigurationMatch = $true Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.SettingActionMessage) ` + $($script:localizedData.TestingActionMessage) ` -f $Path, $Percentage, $Type ) -join '' ) @@ -504,7 +499,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.EnsureActionExistsMessage) ` + $($script:localizedData.EnsureActionExistsMessage) ` -f $Path, $Percentage, $Type ) -join '' ) @@ -513,7 +508,7 @@ function Test-TargetResource # The action does not exist but should Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionDoesNotExistButShouldMessage) ` + $($script:localizedData.ActionDoesNotExistButShouldMessage) ` -f $Path, $Percentage, $Type ) -join '' ) @@ -530,7 +525,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Path, $Percentage, $Type, 'Subject' ) -join '' ) @@ -542,7 +537,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Path, $Percentage, $Type, 'Body' ) -join '' ) @@ -554,7 +549,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Path, $Percentage, $Type, 'MailBCC' ) -join '' ) @@ -566,7 +561,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Path, $Percentage, $Type, 'MailCC' ) -join '' ) @@ -578,7 +573,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Path, $Percentage, $Type, 'MailTo' ) -join '' ) @@ -590,7 +585,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Path, $Percentage, $Type, 'Command' ) -join '' ) @@ -602,7 +597,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Path, $Percentage, $Type, 'CommandParameters' ) -join '' ) @@ -614,7 +609,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Path, $Percentage, $Type, 'KillTimeOut' ) -join '' ) @@ -626,7 +621,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Path, $Percentage, $Type, 'RunLimitInterval' ) -join '' ) @@ -638,7 +633,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Path, $Percentage, $Type, 'SecurityLevel' ) -join '' ) @@ -650,7 +645,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Path, $Percentage, $Type, 'ShouldLogError' ) -join '' ) @@ -662,7 +657,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Path, $Percentage, $Type, 'WorkingDirectory' ) -join '' ) @@ -674,7 +669,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Path, $Percentage, $Type, 'EventType' ) -join '' ) @@ -696,7 +691,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Path, $Percentage, $Type, 'ReportTypes' ) -join '' ) @@ -712,7 +707,7 @@ function Test-TargetResource # The action doesn't exist and should not Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionDoesNotExistAndShouldNotMessage) ` + $($script:localizedData.ActionDoesNotExistAndShouldNotMessage) ` -f $Path, $Percentage, $Type ) -join '' ) } @@ -721,7 +716,7 @@ function Test-TargetResource # The Action exists, but it should be removed Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionExistsAndShouldNotMessage) ` + $($script:localizedData.ActionExistsAndShouldNotMessage) ` -f $Path, $Percentage, $Type ) -join '' ) @@ -748,7 +743,7 @@ function Test-TargetResource .PARAMETER Type The type of FSRM Action. #> -Function Get-Action +function Get-Action { param ( @@ -780,7 +775,7 @@ Function Get-Action catch [Microsoft.PowerShell.Cmdletization.Cim.CimJobException] { New-InvalidArgumentException ` - -Message ($($LocalizedData.QuotaNotFoundError) -f $Path, $Percentage, $Type) ` + -Message ($($script:localizedData.QuotaNotFoundError) -f $Path, $Percentage, $Type) ` -ArgumentName 'Path' } @@ -809,8 +804,9 @@ Function Get-Action } } - $properties = @{'Percentage' = $quota.Threshold[$threshold].Percentage; - 'Action' = $newActions; + $properties = @{ + 'Percentage' = $quota.Threshold[$threshold].Percentage + 'Action' = $newActions } $newSourceObject = New-Object -TypeName 'PSObject' -Property $properties @@ -820,12 +816,12 @@ Function Get-Action if ($null -eq $resultObject.SourceIndex) { New-InvalidArgumentException ` - -Message ($($LocalizedData.QuotaThresholdNotFoundError) -f $Path, $Percentage, $Type) ` + -Message ($($script:localizedData.QuotaThresholdNotFoundError) -f $Path, $Percentage, $Type) ` -ArgumentName 'Path' } # Return the result - Return $resultObject + return $resultObject } <# @@ -839,7 +835,7 @@ Function Get-Action .PARAMETER ResultObject The object returned by Get-Action that will be used to update the Action. #> -Function Set-Action +function Set-Action { param ( @@ -860,9 +856,9 @@ Function Set-Action -Namespace Root/Microsoft/Windows/FSRM ` -ClientOnly ` -Property @{ - Percentage = $object.Percentage - Action = [Microsoft.Management.Infrastructure.CimInstance[]]($object.Action) - } + Percentage = $object.Percentage + Action = [Microsoft.Management.Infrastructure.CimInstance[]]($object.Action) + } } Set-FSRMQuota ` diff --git a/DSCResources/DSR_FSRMQuotaAction/DSR_FSRMQuotaAction.schema.mof b/source/DSCResources/DSC_FSRMQuotaAction/DSC_FSRMQuotaAction.schema.mof similarity index 98% rename from DSCResources/DSR_FSRMQuotaAction/DSR_FSRMQuotaAction.schema.mof rename to source/DSCResources/DSC_FSRMQuotaAction/DSC_FSRMQuotaAction.schema.mof index 853e5bd4..00e55ed5 100644 --- a/DSCResources/DSR_FSRMQuotaAction/DSR_FSRMQuotaAction.schema.mof +++ b/source/DSCResources/DSC_FSRMQuotaAction/DSC_FSRMQuotaAction.schema.mof @@ -1,5 +1,5 @@ [ClassVersion("1.0.0.0"), FriendlyName("FSRMQuotaAction")] -class DSR_FSRMQuotaAction : OMI_BaseResource +class DSC_FSRMQuotaAction : OMI_BaseResource { [Key, Description("The path of the FSRM Quota the action applies to.")] string Path; [Key, Description("This is the threshold percentage the action is attached to.")] uint32 Percentage; diff --git a/DSCResources/DSR_FSRMQuotaAction/README.md b/source/DSCResources/DSC_FSRMQuotaAction/README.md similarity index 100% rename from DSCResources/DSR_FSRMQuotaAction/README.md rename to source/DSCResources/DSC_FSRMQuotaAction/README.md diff --git a/DSCResources/DSR_FSRMQuotaAction/en-US/DSR_FSRMQuotaAction.strings.psd1 b/source/DSCResources/DSC_FSRMQuotaAction/en-US/DSC_FSRMQuotaAction.strings.psd1 similarity index 100% rename from DSCResources/DSR_FSRMQuotaAction/en-US/DSR_FSRMQuotaAction.strings.psd1 rename to source/DSCResources/DSC_FSRMQuotaAction/en-US/DSC_FSRMQuotaAction.strings.psd1 diff --git a/DSCResources/DSR_FSRMQuotaTemplate/DSR_FSRMQuotaTemplate.psm1 b/source/DSCResources/DSC_FSRMQuotaTemplate/DSC_FSRMQuotaTemplate.psm1 similarity index 84% rename from DSCResources/DSR_FSRMQuotaTemplate/DSR_FSRMQuotaTemplate.psm1 rename to source/DSCResources/DSC_FSRMQuotaTemplate/DSC_FSRMQuotaTemplate.psm1 index 62533b40..35b59c86 100644 --- a/DSCResources/DSR_FSRMQuotaTemplate/DSR_FSRMQuotaTemplate.psm1 +++ b/source/DSCResources/DSC_FSRMQuotaTemplate/DSC_FSRMQuotaTemplate.psm1 @@ -1,14 +1,9 @@ $modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules' -# Import the Networking Resource Helper Module -Import-Module -Name (Join-Path -Path $modulePath ` - -ChildPath (Join-Path -Path 'FSRMDsc.ResourceHelper' ` - -ChildPath 'FSRMDsc.ResourceHelper.psm1')) +Import-Module -Name (Join-Path -Path $modulePath -ChildPath 'DscResource.Common') # Import Localization Strings -$LocalizedData = Get-LocalizedData ` - -ResourceName 'DSR_FSRMQuotaTemplate' ` - -ResourcePath (Split-Path -Parent $Script:MyInvocation.MyCommand.Path) +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS @@ -30,7 +25,7 @@ function Get-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.GettingQuotaTemplateMessage) ` + $($script:localizedData.GettingQuotaTemplateMessage) ` -f $Name ) -join '' ) @@ -45,7 +40,7 @@ function Get-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.QuotaTemplateExistsMessage) ` + $($script:localizedData.QuotaTemplateExistsMessage) ` -f $Name ) -join '' ) @@ -61,7 +56,7 @@ function Get-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.QuotaTemplateDoesNotExistMessage) ` + $($script:localizedData.QuotaTemplateDoesNotExistMessage) ` -f $Name ) -join '' ) @@ -128,6 +123,12 @@ function Set-TargetResource $ThresholdPercentages ) + Write-Verbose -Message ( @( + "$($MyInvocation.MyCommand): " + $($script:localizedData.SettingQuotaTemplateMessage) ` + -f $Name + ) -join '' ) + # Remove any parameters that can't be splatted. $null = $PSBoundParameters.Remove('Ensure') $null = $PSBoundParameters.Remove('ThresholdPercentages') @@ -139,7 +140,7 @@ function Set-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.EnsureQuotaTemplateExistsMessage) ` + $($script:localizedData.EnsureQuotaTemplateExistsMessage) ` -f $Name ) -join '' ) @@ -156,14 +157,14 @@ function Set-TargetResource # Scan through the required thresholds and add any that are misssing foreach ($ThresholdPercentage in $ThresholdPercentages) { - If ($ThresholdPercentage -notin $thresholds.Percentage) + if ($ThresholdPercentage -notin $thresholds.Percentage) { # The threshold percentage is missing so add it $thresholds += New-FSRMQuotaThreshold -Percentage $ThresholdPercentage Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.QuotaTemplateThresholdAddedMessage) ` + $($script:localizedData.QuotaTemplateThresholdAddedMessage) ` -f $Name, $ThresholdPercentage ) -join '' ) } @@ -172,14 +173,14 @@ function Set-TargetResource # Scan through the existing thresholds and remove any that are misssing for ($counter = $thresholds.Count - 1; $counter -ge 0; $counter--) { - If ($thresholds[$counter].Percentage -notin $ThresholdPercentages) + if ($thresholds[$counter].Percentage -notin $ThresholdPercentages) { # The threshold percentage exists but shouldn not so remove it $thresholds.Remove($counter) Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.QuotaTemplateThresholdRemovedMessage) ` + $($script:localizedData.QuotaTemplateThresholdRemovedMessage) ` -f $Name, $thresholds[$counter].Percentage ) -join '' ) } @@ -194,7 +195,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.QuotaTemplateUpdatedMessage) ` + $($script:localizedData.QuotaTemplateUpdatedMessage) ` -f $Name ) -join '' ) } @@ -207,7 +208,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.QuotaTemplateCreatedMessage) ` + $($script:localizedData.QuotaTemplateCreatedMessage) ` -f $Name ) -join '' ) } @@ -216,7 +217,7 @@ function Set-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.EnsureQuotaTemplateDoesNotExistMessage) ` + $($script:localizedData.EnsureQuotaTemplateDoesNotExistMessage) ` -f $Name ) -join '' ) @@ -227,7 +228,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.QuotaTemplateRemovedMessage) ` + $($script:localizedData.QuotaTemplateRemovedMessage) ` -f $Name ) -join '' ) } # if @@ -290,11 +291,11 @@ function Test-TargetResource ) # Flag to signal whether settings are correct - [Boolean] $desiredConfigurationMatch = $true + $desiredConfigurationMatch = $true Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.TestingQuotaTemplateMessage) ` + $($script:localizedData.TestingQuotaTemplateMessage) ` -f $Name ) -join '' ) @@ -312,7 +313,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.QuotaTemplatePropertyNeedsUpdateMessage) ` + $($script:localizedData.QuotaTemplatePropertyNeedsUpdateMessage) ` -f $Name, 'Description' ) -join '' ) @@ -324,7 +325,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.QuotaTemplatePropertyNeedsUpdateMessage) ` + $($script:localizedData.QuotaTemplatePropertyNeedsUpdateMessage) ` -f $Name, 'Size' ) -join '' ) @@ -336,7 +337,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.QuotaTemplatePropertyNeedsUpdateMessage) ` + $($script:localizedData.QuotaTemplatePropertyNeedsUpdateMessage) ` -f $Name, 'SoftLimit' ) -join '' ) @@ -351,7 +352,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.QuotaTemplatePropertyNeedsUpdateMessage) ` + $($script:localizedData.QuotaTemplatePropertyNeedsUpdateMessage) ` -f $Name, 'ThresholdPercentages' ) -join '' ) @@ -363,7 +364,7 @@ function Test-TargetResource # Ths Quota Template doesn't exist but should Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.QuotaTemplateDoesNotExistButShouldMessage) ` + $($script:localizedData.QuotaTemplateDoesNotExistButShouldMessage) ` -f $Name ) -join '' ) @@ -378,7 +379,7 @@ function Test-TargetResource # The Quota Template exists but should not Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.QuotaTemplateExistsButShouldNotMessage) ` + $($script:localizedData.QuotaTemplateExistsButShouldNotMessage) ` -f $Name ) -join '' ) @@ -389,7 +390,7 @@ function Test-TargetResource # The Quota Template does not exist and should not Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.QuotaTemplateDoesNotExistAndShouldNotMessage) ` + $($script:localizedData.QuotaTemplateDoesNotExistAndShouldNotMessage) ` -f $Name ) -join '' ) } @@ -405,7 +406,7 @@ function Test-TargetResource .PARAMETER Name The unique name for this FSRM Quota Template. #> -Function Get-QuotaTemplate +function Get-QuotaTemplate { param ( @@ -424,7 +425,7 @@ Function Get-QuotaTemplate } catch { - Throw $_ + throw $_ } return $quotaTemplate diff --git a/DSCResources/DSR_FSRMQuotaTemplate/DSR_FSRMQuotaTemplate.schema.mof b/source/DSCResources/DSC_FSRMQuotaTemplate/DSC_FSRMQuotaTemplate.schema.mof similarity index 94% rename from DSCResources/DSR_FSRMQuotaTemplate/DSR_FSRMQuotaTemplate.schema.mof rename to source/DSCResources/DSC_FSRMQuotaTemplate/DSC_FSRMQuotaTemplate.schema.mof index 547dc0dc..cd062e47 100644 --- a/DSCResources/DSR_FSRMQuotaTemplate/DSR_FSRMQuotaTemplate.schema.mof +++ b/source/DSCResources/DSC_FSRMQuotaTemplate/DSC_FSRMQuotaTemplate.schema.mof @@ -1,5 +1,5 @@ [ClassVersion("1.0.0.0"), FriendlyName("FSRMQuotaTemplate")] -class DSR_FSRMQuotaTemplate : OMI_BaseResource +class DSC_FSRMQuotaTemplate : OMI_BaseResource { [Key, Description("The unique name for this FSRM Quota Template.")] String Name; [Write, Description("An optional description for this FSRM Quota Template.")] String Description; diff --git a/DSCResources/DSR_FSRMQuotaTemplate/README.md b/source/DSCResources/DSC_FSRMQuotaTemplate/README.md similarity index 100% rename from DSCResources/DSR_FSRMQuotaTemplate/README.md rename to source/DSCResources/DSC_FSRMQuotaTemplate/README.md diff --git a/DSCResources/DSR_FSRMQuotaTemplate/en-US/DSR_FSRMQuotaTemplate.strings.psd1 b/source/DSCResources/DSC_FSRMQuotaTemplate/en-US/DSC_FSRMQuotaTemplate.strings.psd1 similarity index 100% rename from DSCResources/DSR_FSRMQuotaTemplate/en-US/DSR_FSRMQuotaTemplate.strings.psd1 rename to source/DSCResources/DSC_FSRMQuotaTemplate/en-US/DSC_FSRMQuotaTemplate.strings.psd1 diff --git a/DSCResources/DSR_FSRMQuotaTemplateAction/DSR_FSRMQuotaTemplateAction.psm1 b/source/DSCResources/DSC_FSRMQuotaTemplateAction/DSC_FSRMQuotaTemplateAction.psm1 similarity index 88% rename from DSCResources/DSR_FSRMQuotaTemplateAction/DSR_FSRMQuotaTemplateAction.psm1 rename to source/DSCResources/DSC_FSRMQuotaTemplateAction/DSC_FSRMQuotaTemplateAction.psm1 index 8adeeff6..5e3467bb 100644 --- a/DSCResources/DSR_FSRMQuotaTemplateAction/DSR_FSRMQuotaTemplateAction.psm1 +++ b/source/DSCResources/DSC_FSRMQuotaTemplateAction/DSC_FSRMQuotaTemplateAction.psm1 @@ -1,14 +1,9 @@ $modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules' -# Import the Networking Resource Helper Module -Import-Module -Name (Join-Path -Path $modulePath ` - -ChildPath (Join-Path -Path 'FSRMDsc.ResourceHelper' ` - -ChildPath 'FSRMDsc.ResourceHelper.psm1')) +Import-Module -Name (Join-Path -Path $modulePath -ChildPath 'DscResource.Common') # Import Localization Strings -$LocalizedData = Get-LocalizedData ` - -ResourceName 'DSR_FSRMQuotaTemplateAction' ` - -ResourcePath (Split-Path -Parent $Script:MyInvocation.MyCommand.Path) +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS @@ -46,7 +41,7 @@ function Get-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.GettingActionMessage) ` + $($script:localizedData.GettingActionMessage) ` -f $Name, $Percentage, $Type ) -join '' ) @@ -67,7 +62,7 @@ function Get-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionNotExistMessage) ` + $($script:localizedData.ActionNotExistMessage) ` -f $Name, $Percentage, $Type ) -join '' ) @@ -79,7 +74,7 @@ function Get-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionExistsMessage) ` + $($script:localizedData.ActionExistsMessage) ` -f $Name, $Percentage, $Type ) -join '' ) @@ -250,7 +245,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.SettingActionMessage) ` + $($script:localizedData.SettingActionMessage) ` -f $Name, $Percentage, $Type ) -join '' ) @@ -270,7 +265,7 @@ function Set-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.EnsureActionExistsMessage) ` + $($script:localizedData.EnsureActionExistsMessage) ` -f $Name, $Percentage, $Type ) -join '' ) @@ -281,7 +276,7 @@ function Set-TargetResource # Create the action Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionCreatedMessage) ` + $($script:localizedData.ActionCreatedMessage) ` -f $Name, $Percentage, $Type ) -join '' ) } @@ -292,7 +287,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionUpdatedMessage) ` + $($script:localizedData.ActionUpdatedMessage) ` -f $Name, $Percentage, $Type ) -join '' ) } @@ -303,7 +298,7 @@ function Set-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.EnsureActionDoesNotExistMessage) ` + $($script:localizedData.EnsureActionDoesNotExistMessage) ` -f $Name, $Percentage, $Type ) -join '' ) @@ -312,7 +307,7 @@ function Set-TargetResource # The action doesn't exist and should not Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionNoChangeMessage) ` + $($script:localizedData.ActionNoChangeMessage) ` -f $Name, $Percentage, $Type ) -join '' ) @@ -325,7 +320,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionRemovedMessage) ` + $($script:localizedData.ActionRemovedMessage) ` -f $Name, $Percentage, $Type ) -join '' ) } # if @@ -339,7 +334,7 @@ function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionWrittenMessage) ` + $($script:localizedData.ActionWrittenMessage) ` -f $Name, $Percentage, $Type ) -join '' ) } # Set-TargetResource @@ -486,11 +481,11 @@ function Test-TargetResource $ReportTypes ) # Flag to signal whether settings are correct - [Boolean] $desiredConfigurationMatch = $true + $desiredConfigurationMatch = $true Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.SettingActionMessage) ` + $($script:localizedData.TestingActionMessage) ` -f $Name, $Percentage, $Type ) -join '' ) @@ -505,7 +500,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.EnsureActionExistsMessage) ` + $($script:localizedData.EnsureActionExistsMessage) ` -f $Name, $Percentage, $Type ) -join '' ) @@ -514,7 +509,7 @@ function Test-TargetResource # The action does not exist but should Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionDoesNotExistButShouldMessage) ` + $($script:localizedData.ActionDoesNotExistButShouldMessage) ` -f $Name, $Percentage, $Type ) -join '' ) @@ -531,7 +526,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Name, $Percentage, $Type, 'Subject' ) -join '' ) @@ -543,7 +538,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Name, $Percentage, $Type, 'Body' ) -join '' ) @@ -555,7 +550,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Name, $Percentage, $Type, 'MailBCC' ) -join '' ) @@ -567,7 +562,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Name, $Percentage, $Type, 'MailCC' ) -join '' ) @@ -579,7 +574,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Name, $Percentage, $Type, 'MailTo' ) -join '' ) @@ -591,7 +586,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Name, $Percentage, $Type, 'Command' ) -join '' ) @@ -603,7 +598,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Name, $Percentage, $Type, 'CommandParameters' ) -join '' ) @@ -615,7 +610,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Name, $Percentage, $Type, 'KillTimeOut' ) -join '' ) @@ -627,7 +622,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Name, $Percentage, $Type, 'RunLimitInterval' ) -join '' ) @@ -639,7 +634,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Name, $Percentage, $Type, 'SecurityLevel' ) -join '' ) @@ -651,7 +646,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Name, $Percentage, $Type, 'ShouldLogError' ) -join '' ) @@ -663,7 +658,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Name, $Percentage, $Type, 'WorkingDirectory' ) -join '' ) @@ -675,7 +670,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Name, $Percentage, $Type, 'EventType' ) -join '' ) @@ -697,7 +692,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionPropertyNeedsUpdateMessage) ` + $($script:localizedData.ActionPropertyNeedsUpdateMessage) ` -f $Name, $Percentage, $Type, 'ReportTypes' ) -join '' ) @@ -713,7 +708,7 @@ function Test-TargetResource # The action doesn't exist and should not Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionDoesNotExistAndShouldNotMessage) ` + $($script:localizedData.ActionDoesNotExistAndShouldNotMessage) ` -f $Name, $Percentage, $Type ) -join '' ) } @@ -722,7 +717,7 @@ function Test-TargetResource # The Action exists, but it should be removed Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.ActionExistsAndShouldNotMessage) ` + $($script:localizedData.ActionExistsAndShouldNotMessage) ` -f $Name, $Percentage, $Type ) -join '' ) @@ -749,7 +744,7 @@ function Test-TargetResource .PARAMETER Type The type of FSRM Action. #> -Function Get-Action +function Get-Action { param ( @@ -769,7 +764,7 @@ Function Get-Action ) $resultObject = [PSObject] @{ - SourceObjects = [System.Collections.ArrayList]@() + SourceObjects = [System.Collections.ArrayList] @() SourceIndex = $null ActionIndex = $null } @@ -784,7 +779,7 @@ Function Get-Action catch [Microsoft.PowerShell.Cmdletization.Cim.CimJobException] { New-InvalidArgumentException ` - -Message ($($LocalizedData.QuotaTemplateNotFoundError) -f $Name, $Percentage, $Type) ` + -Message ($($script:localizedData.QuotaTemplateNotFoundError) -f $Name, $Percentage, $Type) ` -ArgumentName 'Name' $PSCmdlet.ThrowTerminatingError($errorRecord) @@ -816,8 +811,9 @@ Function Get-Action } } - $properties = @{'Percentage' = $quotaTemplate.Threshold[$threshold].Percentage; - 'Action' = $newActions; + $properties = @{ + 'Percentage' = $quotaTemplate.Threshold[$threshold].Percentage + 'Action' = $newActions } $newSourceObject = New-Object -TypeName 'PSObject' -Property $properties @@ -827,12 +823,12 @@ Function Get-Action if ($null -eq $resultObject.SourceIndex) { New-InvalidArgumentException ` - -Message ($($LocalizedData.QuotaTemplateThresholdNotFoundError) -f $Name, $Percentage, $Type) ` + -Message ($($script:localizedData.QuotaTemplateThresholdNotFoundError) -f $Name, $Percentage, $Type) ` -ArgumentName 'Name' } # Return the result - Return $resultObject + return $resultObject } <# @@ -846,7 +842,7 @@ Function Get-Action .PARAMETER ResultObject The object returned by Get-Action that will be used to update the Action. #> -Function Set-Action +function Set-Action { param ( @@ -867,9 +863,9 @@ Function Set-Action -Namespace Root/Microsoft/Windows/FSRM ` -ClientOnly ` -Property @{ - Percentage = $object.Percentage - Action = [Microsoft.Management.Infrastructure.CimInstance[]]($object.Action) - } + Percentage = $object.Percentage + Action = [Microsoft.Management.Infrastructure.CimInstance[]]($object.Action) + } } Set-FSRMQuotaTemplate ` diff --git a/DSCResources/DSR_FSRMQuotaTemplateAction/DSR_FSRMQuotaTemplateAction.schema.mof b/source/DSCResources/DSC_FSRMQuotaTemplateAction/DSC_FSRMQuotaTemplateAction.schema.mof similarity index 97% rename from DSCResources/DSR_FSRMQuotaTemplateAction/DSR_FSRMQuotaTemplateAction.schema.mof rename to source/DSCResources/DSC_FSRMQuotaTemplateAction/DSC_FSRMQuotaTemplateAction.schema.mof index a4fea90f..8595ffaf 100644 --- a/DSCResources/DSR_FSRMQuotaTemplateAction/DSR_FSRMQuotaTemplateAction.schema.mof +++ b/source/DSCResources/DSC_FSRMQuotaTemplateAction/DSC_FSRMQuotaTemplateAction.schema.mof @@ -1,5 +1,5 @@ [ClassVersion("1.0.0.0"), FriendlyName("FSRMQuotaTemplateAction")] -class DSR_FSRMQuotaTemplateAction : OMI_BaseResource +class DSC_FSRMQuotaTemplateAction : OMI_BaseResource { [Key, Description("The name of the FSRM Quota Template that this Action is attached to.")] string Name; [Key, Description("This is the threshold percentage the action is attached to.")] uint32 Percentage; diff --git a/DSCResources/DSR_FSRMQuotaTemplateAction/README.md b/source/DSCResources/DSC_FSRMQuotaTemplateAction/README.md similarity index 100% rename from DSCResources/DSR_FSRMQuotaTemplateAction/README.md rename to source/DSCResources/DSC_FSRMQuotaTemplateAction/README.md diff --git a/DSCResources/DSR_FSRMQuotaTemplateAction/en-US/DSR_FSRMQuotaTemplateAction.strings.psd1 b/source/DSCResources/DSC_FSRMQuotaTemplateAction/en-US/DSC_FSRMQuotaTemplateAction.strings.psd1 similarity index 100% rename from DSCResources/DSR_FSRMQuotaTemplateAction/en-US/DSR_FSRMQuotaTemplateAction.strings.psd1 rename to source/DSCResources/DSC_FSRMQuotaTemplateAction/en-US/DSC_FSRMQuotaTemplateAction.strings.psd1 diff --git a/DSCResources/DSR_FSRMSettings/DSR_FSRMSettings.psm1 b/source/DSCResources/DSC_FSRMSettings/DSC_FSRMSettings.psm1 similarity index 87% rename from DSCResources/DSR_FSRMSettings/DSR_FSRMSettings.psm1 rename to source/DSCResources/DSC_FSRMSettings/DSC_FSRMSettings.psm1 index 8c131b2a..fe397461 100644 --- a/DSCResources/DSR_FSRMSettings/DSR_FSRMSettings.psm1 +++ b/source/DSCResources/DSC_FSRMSettings/DSC_FSRMSettings.psm1 @@ -1,14 +1,9 @@ $modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules' -# Import the Networking Resource Helper Module -Import-Module -Name (Join-Path -Path $modulePath ` - -ChildPath (Join-Path -Path 'FSRMDsc.ResourceHelper' ` - -ChildPath 'FSRMDsc.ResourceHelper.psm1')) +Import-Module -Name (Join-Path -Path $modulePath -ChildPath 'DscResource.Common') # Import Localization Strings -$LocalizedData = Get-LocalizedData ` - -ResourceName 'DSR_FSRMSettings' ` - -ResourcePath (Split-Path -Parent $Script:MyInvocation.MyCommand.Path) +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' <# .SYNOPSIS @@ -31,7 +26,7 @@ function Get-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.GettingSettingsMessage) ` + $($script:localizedData.GettingSettingsMessage) ` ) -join '' ) $settings = Get-FSRMSetting @@ -79,7 +74,7 @@ function Get-TargetResource Specifies the minimum number of seconds between individual running events of an event-type notification. #> -Function Set-TargetResource +function Set-TargetResource { [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess', '')] [CmdletBinding(SupportsShouldProcess = $true)] @@ -117,7 +112,7 @@ Function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.SettingSettingsMessage) ` + $($script:localizedData.SettingSettingsMessage) ` ) -join '' ) # Remove any parameters that can't be splatted. @@ -128,7 +123,7 @@ Function Set-TargetResource Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.SettingsUpdatedMessage) ` + $($script:localizedData.SettingsUpdatedMessage) ` ) -join '' ) } # Set-TargetResource @@ -199,11 +194,11 @@ function Test-TargetResource ) # Flag to signal whether settings are correct - [Boolean] $desiredConfigurationMatch = $true + $desiredConfigurationMatch = $true Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.TestingSettingsMessage) ` + $($script:localizedData.TestingSettingsMessage) ` ) -join '' ) # Lookup the existing Settings @@ -215,7 +210,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.SettingsNeedsUpdateMessage) ` + $($script:localizedData.SettingsNeedsUpdateMessage) ` -f 'SmtpServer' ) -join '' ) @@ -227,7 +222,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.SettingsNeedsUpdateMessage) ` + $($script:localizedData.SettingsNeedsUpdateMessage) ` -f 'AdminEmailAddress' ) -join '' ) @@ -239,7 +234,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.SettingsNeedsUpdateMessage) ` + $($script:localizedData.SettingsNeedsUpdateMessage) ` -f 'FromEmailAddress' ) -join '' ) @@ -251,7 +246,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.SettingsNeedsUpdateMessage) ` + $($script:localizedData.SettingsNeedsUpdateMessage) ` -f 'CommandNotificationLimit' ) -join '' ) @@ -263,8 +258,8 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.EmailNotificationLimit) ` - -f 'FromEmailAddress' + $($script:localizedData.SettingsNeedsUpdateMessage) ` + -f 'EmailNotificationLimit' ) -join '' ) $desiredConfigurationMatch = $false @@ -275,7 +270,7 @@ function Test-TargetResource { Write-Verbose -Message ( @( "$($MyInvocation.MyCommand): " - $($LocalizedData.SettingsNeedsUpdateMessage) ` + $($script:localizedData.SettingsNeedsUpdateMessage) ` -f 'EventNotificationLimit' ) -join '' ) diff --git a/DSCResources/DSR_FSRMSettings/DSR_FSRMSettings.schema.mof b/source/DSCResources/DSC_FSRMSettings/DSC_FSRMSettings.schema.mof similarity index 96% rename from DSCResources/DSR_FSRMSettings/DSR_FSRMSettings.schema.mof rename to source/DSCResources/DSC_FSRMSettings/DSC_FSRMSettings.schema.mof index 8be71921..4aa91438 100644 --- a/DSCResources/DSR_FSRMSettings/DSR_FSRMSettings.schema.mof +++ b/source/DSCResources/DSC_FSRMSettings/DSC_FSRMSettings.schema.mof @@ -1,5 +1,5 @@ [ClassVersion("1.0.0.0"), FriendlyName("FSRMSettings")] -class DSR_FSRMSettings : OMI_BaseResource +class DSC_FSRMSettings : 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 the fully qualified domain name (FQDN) or IP address of the SMTP server that FSRM uses to send email.")] String SmtpServer; diff --git a/DSCResources/DSR_FSRMSettings/README.md b/source/DSCResources/DSC_FSRMSettings/README.md similarity index 100% rename from DSCResources/DSR_FSRMSettings/README.md rename to source/DSCResources/DSC_FSRMSettings/README.md diff --git a/DSCResources/DSR_FSRMSettings/en-US/DSR_FSRMSettings.strings.psd1 b/source/DSCResources/DSC_FSRMSettings/en-US/DSC_FSRMSettings.strings.psd1 similarity index 100% rename from DSCResources/DSR_FSRMSettings/en-US/DSR_FSRMSettings.strings.psd1 rename to source/DSCResources/DSC_FSRMSettings/en-US/DSC_FSRMSettings.strings.psd1 diff --git a/Examples/Resources/FSRMAutoQuota/1-FSRMAutoQuota_Config.ps1 b/source/Examples/Resources/FSRMAutoQuota/1-FSRMAutoQuota_Config.ps1 similarity index 76% rename from Examples/Resources/FSRMAutoQuota/1-FSRMAutoQuota_Config.ps1 rename to source/Examples/Resources/FSRMAutoQuota/1-FSRMAutoQuota_Config.ps1 index 04fef825..47e74ebd 100644 --- a/Examples/Resources/FSRMAutoQuota/1-FSRMAutoQuota_Config.ps1 +++ b/source/Examples/Resources/FSRMAutoQuota/1-FSRMAutoQuota_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 39ff861a-331d-4605-aac9-5a773dde4ec9 -.AUTHOR Daniel Scott-Raynsford -.COMPANYNAME -.COPYRIGHT (c) 2018 Daniel Scott-Raynsford. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PlagueHO/FSRMDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PlagueHO/FSRMDsc +.LICENSEURI https://github.com/dsccommunity/FSRMDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/FSRMDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/FSRMClassification/1-FSRMClassification_Config.ps1 b/source/Examples/Resources/FSRMClassification/1-FSRMClassification_Config.ps1 similarity index 82% rename from Examples/Resources/FSRMClassification/1-FSRMClassification_Config.ps1 rename to source/Examples/Resources/FSRMClassification/1-FSRMClassification_Config.ps1 index 4e2f1cb1..3b58d3d7 100644 --- a/Examples/Resources/FSRMClassification/1-FSRMClassification_Config.ps1 +++ b/source/Examples/Resources/FSRMClassification/1-FSRMClassification_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 87303cbb-e1bc-4b3d-b4da-d21e2f2f4af9 -.AUTHOR Daniel Scott-Raynsford -.COMPANYNAME -.COPYRIGHT (c) 2018 Daniel Scott-Raynsford. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PlagueHO/FSRMDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PlagueHO/FSRMDsc +.LICENSEURI https://github.com/dsccommunity/FSRMDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/FSRMDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/FSRMClassificationProperty/1-FSRMClassificationProperty_SingleChoice_Config.ps1 b/source/Examples/Resources/FSRMClassificationProperty/1-FSRMClassificationProperty_SingleChoice_Config.ps1 similarity index 80% rename from Examples/Resources/FSRMClassificationProperty/1-FSRMClassificationProperty_SingleChoice_Config.ps1 rename to source/Examples/Resources/FSRMClassificationProperty/1-FSRMClassificationProperty_SingleChoice_Config.ps1 index 84e59b08..d5f8972b 100644 --- a/Examples/Resources/FSRMClassificationProperty/1-FSRMClassificationProperty_SingleChoice_Config.ps1 +++ b/source/Examples/Resources/FSRMClassificationProperty/1-FSRMClassificationProperty_SingleChoice_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 014b9323-6d04-44cd-bd28-63f5de78cbdc -.AUTHOR Daniel Scott-Raynsford -.COMPANYNAME -.COPYRIGHT (c) 2018 Daniel Scott-Raynsford. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PlagueHO/FSRMDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PlagueHO/FSRMDsc +.LICENSEURI https://github.com/dsccommunity/FSRMDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/FSRMDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/FSRMClassificationProperty/2-FSRMClassificationProperty_YesNo_Config.ps1 b/source/Examples/Resources/FSRMClassificationProperty/2-FSRMClassificationProperty_YesNo_Config.ps1 similarity index 77% rename from Examples/Resources/FSRMClassificationProperty/2-FSRMClassificationProperty_YesNo_Config.ps1 rename to source/Examples/Resources/FSRMClassificationProperty/2-FSRMClassificationProperty_YesNo_Config.ps1 index 4956d527..f398d4a2 100644 --- a/Examples/Resources/FSRMClassificationProperty/2-FSRMClassificationProperty_YesNo_Config.ps1 +++ b/source/Examples/Resources/FSRMClassificationProperty/2-FSRMClassificationProperty_YesNo_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID c5aa6aff-cad0-45dc-a55c-6fd671574455 -.AUTHOR Daniel Scott-Raynsford -.COMPANYNAME -.COPYRIGHT (c) 2018 Daniel Scott-Raynsford. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PlagueHO/FSRMDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PlagueHO/FSRMDsc +.LICENSEURI https://github.com/dsccommunity/FSRMDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/FSRMDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/FSRMClassificationPropertyValue/1-FSRMClassificationPropertyValue_Config.ps1 b/source/Examples/Resources/FSRMClassificationPropertyValue/1-FSRMClassificationPropertyValue_Config.ps1 similarity index 79% rename from Examples/Resources/FSRMClassificationPropertyValue/1-FSRMClassificationPropertyValue_Config.ps1 rename to source/Examples/Resources/FSRMClassificationPropertyValue/1-FSRMClassificationPropertyValue_Config.ps1 index a552bf2b..e8ec8332 100644 --- a/Examples/Resources/FSRMClassificationPropertyValue/1-FSRMClassificationPropertyValue_Config.ps1 +++ b/source/Examples/Resources/FSRMClassificationPropertyValue/1-FSRMClassificationPropertyValue_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID c38478d7-f209-4a4a-9502-57351baea769 -.AUTHOR Daniel Scott-Raynsford -.COMPANYNAME -.COPYRIGHT (c) 2018 Daniel Scott-Raynsford. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PlagueHO/FSRMDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PlagueHO/FSRMDsc +.LICENSEURI https://github.com/dsccommunity/FSRMDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/FSRMDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/FSRMClassificationRule/1-FSRMClassificationRule_Config.ps1 b/source/Examples/Resources/FSRMClassificationRule/1-FSRMClassificationRule_Config.ps1 similarity index 84% rename from Examples/Resources/FSRMClassificationRule/1-FSRMClassificationRule_Config.ps1 rename to source/Examples/Resources/FSRMClassificationRule/1-FSRMClassificationRule_Config.ps1 index 1b33bbc4..6ab921d5 100644 --- a/Examples/Resources/FSRMClassificationRule/1-FSRMClassificationRule_Config.ps1 +++ b/source/Examples/Resources/FSRMClassificationRule/1-FSRMClassificationRule_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 676c644e-5fc9-4325-b25c-20cf42689bae -.AUTHOR Daniel Scott-Raynsford -.COMPANYNAME -.COPYRIGHT (c) 2018 Daniel Scott-Raynsford. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PlagueHO/FSRMDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PlagueHO/FSRMDsc +.LICENSEURI https://github.com/dsccommunity/FSRMDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/FSRMDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/FSRMFileGroup/1-FSRMFileGroup_Config.ps1 b/source/Examples/Resources/FSRMFileGroup/1-FSRMFileGroup_Config.ps1 similarity index 78% rename from Examples/Resources/FSRMFileGroup/1-FSRMFileGroup_Config.ps1 rename to source/Examples/Resources/FSRMFileGroup/1-FSRMFileGroup_Config.ps1 index fa6c8466..3a990a8b 100644 --- a/Examples/Resources/FSRMFileGroup/1-FSRMFileGroup_Config.ps1 +++ b/source/Examples/Resources/FSRMFileGroup/1-FSRMFileGroup_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 4ca93854-dec0-4762-89a0-623bc8c43380 -.AUTHOR Daniel Scott-Raynsford -.COMPANYNAME -.COPYRIGHT (c) 2018 Daniel Scott-Raynsford. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PlagueHO/FSRMDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PlagueHO/FSRMDsc +.LICENSEURI https://github.com/dsccommunity/FSRMDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/FSRMDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/FSRMFileScreen/1-FSRMFileScreen_Config.ps1 b/source/Examples/Resources/FSRMFileScreen/1-FSRMFileScreen_Config.ps1 similarity index 90% rename from Examples/Resources/FSRMFileScreen/1-FSRMFileScreen_Config.ps1 rename to source/Examples/Resources/FSRMFileScreen/1-FSRMFileScreen_Config.ps1 index a000fa78..20372418 100644 --- a/Examples/Resources/FSRMFileScreen/1-FSRMFileScreen_Config.ps1 +++ b/source/Examples/Resources/FSRMFileScreen/1-FSRMFileScreen_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID d80823d5-59cb-4a41-b1a2-8afcd1a8408e -.AUTHOR Daniel Scott-Raynsford -.COMPANYNAME -.COPYRIGHT (c) 2018 Daniel Scott-Raynsford. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PlagueHO/FSRMDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PlagueHO/FSRMDsc +.LICENSEURI https://github.com/dsccommunity/FSRMDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/FSRMDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/FSRMFileScreen/2-FSRMFileScreen_UsingTemplate_Config.ps1 b/source/Examples/Resources/FSRMFileScreen/2-FSRMFileScreen_UsingTemplate_Config.ps1 similarity index 82% rename from Examples/Resources/FSRMFileScreen/2-FSRMFileScreen_UsingTemplate_Config.ps1 rename to source/Examples/Resources/FSRMFileScreen/2-FSRMFileScreen_UsingTemplate_Config.ps1 index 1f895dcb..54d97809 100644 --- a/Examples/Resources/FSRMFileScreen/2-FSRMFileScreen_UsingTemplate_Config.ps1 +++ b/source/Examples/Resources/FSRMFileScreen/2-FSRMFileScreen_UsingTemplate_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID ad79f76f-568e-4adb-80a2-57db7b9d53d7 -.AUTHOR Daniel Scott-Raynsford -.COMPANYNAME -.COPYRIGHT (c) 2018 Daniel Scott-Raynsford. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PlagueHO/FSRMDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PlagueHO/FSRMDsc +.LICENSEURI https://github.com/dsccommunity/FSRMDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/FSRMDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/FSRMFileScreenAction/1-FSRMFileScreenAction_Config.ps1 b/source/Examples/Resources/FSRMFileScreenAction/1-FSRMFileScreenAction_Config.ps1 similarity index 90% rename from Examples/Resources/FSRMFileScreenAction/1-FSRMFileScreenAction_Config.ps1 rename to source/Examples/Resources/FSRMFileScreenAction/1-FSRMFileScreenAction_Config.ps1 index 023308b9..fe1b0b6e 100644 --- a/Examples/Resources/FSRMFileScreenAction/1-FSRMFileScreenAction_Config.ps1 +++ b/source/Examples/Resources/FSRMFileScreenAction/1-FSRMFileScreenAction_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 84d8b42f-8ec3-48c2-8f64-19f6abcbb627 -.AUTHOR Daniel Scott-Raynsford -.COMPANYNAME -.COPYRIGHT (c) 2018 Daniel Scott-Raynsford. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PlagueHO/FSRMDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PlagueHO/FSRMDsc +.LICENSEURI https://github.com/dsccommunity/FSRMDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/FSRMDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/FSRMFileScreenAction/2-FSRMFileScreenAction_UsingTemplate_Config.ps1 b/source/Examples/Resources/FSRMFileScreenAction/2-FSRMFileScreenAction_UsingTemplate_Config.ps1 similarity index 82% rename from Examples/Resources/FSRMFileScreenAction/2-FSRMFileScreenAction_UsingTemplate_Config.ps1 rename to source/Examples/Resources/FSRMFileScreenAction/2-FSRMFileScreenAction_UsingTemplate_Config.ps1 index aafb6469..9c382da7 100644 --- a/Examples/Resources/FSRMFileScreenAction/2-FSRMFileScreenAction_UsingTemplate_Config.ps1 +++ b/source/Examples/Resources/FSRMFileScreenAction/2-FSRMFileScreenAction_UsingTemplate_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID dfbe101b-d765-47d4-9629-ff2a2ac0ef51 -.AUTHOR Daniel Scott-Raynsford -.COMPANYNAME -.COPYRIGHT (c) 2018 Daniel Scott-Raynsford. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PlagueHO/FSRMDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PlagueHO/FSRMDsc +.LICENSEURI https://github.com/dsccommunity/FSRMDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/FSRMDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/FSRMFileScreenException/1-FSRMFileScreenException_Config.ps1 b/source/Examples/Resources/FSRMFileScreenException/1-FSRMFileScreenException_Config.ps1 similarity index 78% rename from Examples/Resources/FSRMFileScreenException/1-FSRMFileScreenException_Config.ps1 rename to source/Examples/Resources/FSRMFileScreenException/1-FSRMFileScreenException_Config.ps1 index 862084e4..b19e72c6 100644 --- a/Examples/Resources/FSRMFileScreenException/1-FSRMFileScreenException_Config.ps1 +++ b/source/Examples/Resources/FSRMFileScreenException/1-FSRMFileScreenException_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID f6bd598e-c87d-41a7-846d-56b39bc76197 -.AUTHOR Daniel Scott-Raynsford -.COMPANYNAME -.COPYRIGHT (c) 2018 Daniel Scott-Raynsford. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PlagueHO/FSRMDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PlagueHO/FSRMDsc +.LICENSEURI https://github.com/dsccommunity/FSRMDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/FSRMDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/FSRMFileScreenTemplate/1-FSRMFileScreenTemplate_Config.ps1 b/source/Examples/Resources/FSRMFileScreenTemplate/1-FSRMFileScreenTemplate_Config.ps1 similarity index 90% rename from Examples/Resources/FSRMFileScreenTemplate/1-FSRMFileScreenTemplate_Config.ps1 rename to source/Examples/Resources/FSRMFileScreenTemplate/1-FSRMFileScreenTemplate_Config.ps1 index fbaa686d..7d0d990d 100644 --- a/Examples/Resources/FSRMFileScreenTemplate/1-FSRMFileScreenTemplate_Config.ps1 +++ b/source/Examples/Resources/FSRMFileScreenTemplate/1-FSRMFileScreenTemplate_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID e0737f2a-9825-4a99-b3d2-2e99310d0e11 -.AUTHOR Daniel Scott-Raynsford -.COMPANYNAME -.COPYRIGHT (c) 2018 Daniel Scott-Raynsford. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PlagueHO/FSRMDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PlagueHO/FSRMDsc +.LICENSEURI https://github.com/dsccommunity/FSRMDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/FSRMDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/FSRMFileScreenTemplateAction/1-FSRMFileScreenTemplateAction_Config.ps1 b/source/Examples/Resources/FSRMFileScreenTemplateAction/1-FSRMFileScreenTemplateAction_Config.ps1 similarity index 90% rename from Examples/Resources/FSRMFileScreenTemplateAction/1-FSRMFileScreenTemplateAction_Config.ps1 rename to source/Examples/Resources/FSRMFileScreenTemplateAction/1-FSRMFileScreenTemplateAction_Config.ps1 index 15d8c511..be63f1f0 100644 --- a/Examples/Resources/FSRMFileScreenTemplateAction/1-FSRMFileScreenTemplateAction_Config.ps1 +++ b/source/Examples/Resources/FSRMFileScreenTemplateAction/1-FSRMFileScreenTemplateAction_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 62b85bd2-3049-4db7-8313-aa0d829c7db9 -.AUTHOR Daniel Scott-Raynsford -.COMPANYNAME -.COPYRIGHT (c) 2018 Daniel Scott-Raynsford. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PlagueHO/FSRMDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PlagueHO/FSRMDsc +.LICENSEURI https://github.com/dsccommunity/FSRMDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/FSRMDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/FSRMQuota/1-FSRMQuota_Config.ps1 b/source/Examples/Resources/FSRMQuota/1-FSRMQuota_Config.ps1 similarity index 92% rename from Examples/Resources/FSRMQuota/1-FSRMQuota_Config.ps1 rename to source/Examples/Resources/FSRMQuota/1-FSRMQuota_Config.ps1 index f08c3ed3..402360d9 100644 --- a/Examples/Resources/FSRMQuota/1-FSRMQuota_Config.ps1 +++ b/source/Examples/Resources/FSRMQuota/1-FSRMQuota_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 38c8407c-d12a-4c98-bbbc-96b7f8c697f3 -.AUTHOR Daniel Scott-Raynsford -.COMPANYNAME -.COPYRIGHT (c) 2018 Daniel Scott-Raynsford. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PlagueHO/FSRMDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PlagueHO/FSRMDsc +.LICENSEURI https://github.com/dsccommunity/FSRMDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/FSRMDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/FSRMQuota/2-FSRMQuota_UsingTemplate_Config.ps1 b/source/Examples/Resources/FSRMQuota/2-FSRMQuota_UsingTemplate_Config.ps1 similarity index 81% rename from Examples/Resources/FSRMQuota/2-FSRMQuota_UsingTemplate_Config.ps1 rename to source/Examples/Resources/FSRMQuota/2-FSRMQuota_UsingTemplate_Config.ps1 index 3a884c34..24bb438e 100644 --- a/Examples/Resources/FSRMQuota/2-FSRMQuota_UsingTemplate_Config.ps1 +++ b/source/Examples/Resources/FSRMQuota/2-FSRMQuota_UsingTemplate_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 4e1a73f2-c37d-4022-b76a-ceb064f954ce -.AUTHOR Daniel Scott-Raynsford -.COMPANYNAME -.COPYRIGHT (c) 2018 Daniel Scott-Raynsford. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PlagueHO/FSRMDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PlagueHO/FSRMDsc +.LICENSEURI https://github.com/dsccommunity/FSRMDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/FSRMDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/FSRMQuotaAction/1-FSRMQuotaAction_Config.ps1 b/source/Examples/Resources/FSRMQuotaAction/1-FSRMQuotaAction_Config.ps1 similarity index 92% rename from Examples/Resources/FSRMQuotaAction/1-FSRMQuotaAction_Config.ps1 rename to source/Examples/Resources/FSRMQuotaAction/1-FSRMQuotaAction_Config.ps1 index 4fe3e20e..f93f8e44 100644 --- a/Examples/Resources/FSRMQuotaAction/1-FSRMQuotaAction_Config.ps1 +++ b/source/Examples/Resources/FSRMQuotaAction/1-FSRMQuotaAction_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 2ddac8d4-0835-4de7-a2fd-0ab56892bd66 -.AUTHOR Daniel Scott-Raynsford -.COMPANYNAME -.COPYRIGHT (c) 2018 Daniel Scott-Raynsford. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PlagueHO/FSRMDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PlagueHO/FSRMDsc +.LICENSEURI https://github.com/dsccommunity/FSRMDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/FSRMDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/FSRMQuotaAction/2-FSRMQuotaAction_UsingTemplate_Config.ps1 b/source/Examples/Resources/FSRMQuotaAction/2-FSRMQuotaAction_UsingTemplate_Config.ps1 similarity index 81% rename from Examples/Resources/FSRMQuotaAction/2-FSRMQuotaAction_UsingTemplate_Config.ps1 rename to source/Examples/Resources/FSRMQuotaAction/2-FSRMQuotaAction_UsingTemplate_Config.ps1 index 7f072ac5..8b74346f 100644 --- a/Examples/Resources/FSRMQuotaAction/2-FSRMQuotaAction_UsingTemplate_Config.ps1 +++ b/source/Examples/Resources/FSRMQuotaAction/2-FSRMQuotaAction_UsingTemplate_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID fa29cfb3-73ab-40c3-b117-3400ec54ad15 -.AUTHOR Daniel Scott-Raynsford -.COMPANYNAME -.COPYRIGHT (c) 2018 Daniel Scott-Raynsford. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PlagueHO/FSRMDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PlagueHO/FSRMDsc +.LICENSEURI https://github.com/dsccommunity/FSRMDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/FSRMDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/FSRMQuotaTemplate/1-FSRMQuotaTemplate_Config.ps1 b/source/Examples/Resources/FSRMQuotaTemplate/1-FSRMQuotaTemplate_Config.ps1 similarity index 92% rename from Examples/Resources/FSRMQuotaTemplate/1-FSRMQuotaTemplate_Config.ps1 rename to source/Examples/Resources/FSRMQuotaTemplate/1-FSRMQuotaTemplate_Config.ps1 index 80216a01..bae7f475 100644 --- a/Examples/Resources/FSRMQuotaTemplate/1-FSRMQuotaTemplate_Config.ps1 +++ b/source/Examples/Resources/FSRMQuotaTemplate/1-FSRMQuotaTemplate_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 6656deaf-8fc7-4e83-b58b-c0112d1f3c1b -.AUTHOR Daniel Scott-Raynsford -.COMPANYNAME -.COPYRIGHT (c) 2018 Daniel Scott-Raynsford. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PlagueHO/FSRMDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PlagueHO/FSRMDsc +.LICENSEURI https://github.com/dsccommunity/FSRMDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/FSRMDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/FSRMQuotaTemplateAction/1-FSRMQuotaTemplateAction_Config.ps1 b/source/Examples/Resources/FSRMQuotaTemplateAction/1-FSRMQuotaTemplateAction_Config.ps1 similarity index 92% rename from Examples/Resources/FSRMQuotaTemplateAction/1-FSRMQuotaTemplateAction_Config.ps1 rename to source/Examples/Resources/FSRMQuotaTemplateAction/1-FSRMQuotaTemplateAction_Config.ps1 index 91cf5fc0..66e1e7a8 100644 --- a/Examples/Resources/FSRMQuotaTemplateAction/1-FSRMQuotaTemplateAction_Config.ps1 +++ b/source/Examples/Resources/FSRMQuotaTemplateAction/1-FSRMQuotaTemplateAction_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID b89c5e83-74cf-4fac-a8f2-2441998ae750 -.AUTHOR Daniel Scott-Raynsford -.COMPANYNAME -.COPYRIGHT (c) 2018 Daniel Scott-Raynsford. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PlagueHO/FSRMDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PlagueHO/FSRMDsc +.LICENSEURI https://github.com/dsccommunity/FSRMDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/FSRMDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/FSRMSettings/1-FSRMSettings_Config.ps1 b/source/Examples/Resources/FSRMSettings/1-FSRMSettings_Config.ps1 similarity index 79% rename from Examples/Resources/FSRMSettings/1-FSRMSettings_Config.ps1 rename to source/Examples/Resources/FSRMSettings/1-FSRMSettings_Config.ps1 index c281c8e5..c3f4a355 100644 --- a/Examples/Resources/FSRMSettings/1-FSRMSettings_Config.ps1 +++ b/source/Examples/Resources/FSRMSettings/1-FSRMSettings_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID b56be742-6e5c-4347-ac24-86fcb0e5931f -.AUTHOR Daniel Scott-Raynsford -.COMPANYNAME -.COPYRIGHT (c) 2018 Daniel Scott-Raynsford. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PlagueHO/FSRMDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PlagueHO/FSRMDsc +.LICENSEURI https://github.com/dsccommunity/FSRMDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/FSRMDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/source/FSRMDsc.psd1 b/source/FSRMDsc.psd1 new file mode 100644 index 00000000..199a1190 --- /dev/null +++ b/source/FSRMDsc.psd1 @@ -0,0 +1,81 @@ +@{ + # Version number of this module. + moduleVersion = '0.0.1' + + # ID used to uniquely identify this module + GUID = '5cda5979-ede4-4b49-9f77-2daa6f80eef2' + + # Author of this module + Author = 'DSC Community' + + # Company or vendor of this module + CompanyName = 'DSC Community' + + # Copyright statement for this module + Copyright = 'Copyright the DSC Community contributors. All rights reserved.' + + # Description of the functionality provided by this module + Description = 'DSC Resources for File Server Resource Manager configuration.' + + # Minimum version of the Windows PowerShell engine required by this module + PowerShellVersion = '4.0' + + # Minimum version of the common language runtime (CLR) required by this module + CLRVersion = '4.0' + + # 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 = @() + + # 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 = @() + + # Variables to export from this module + 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 = @() + + # DSC resources to export from this module + DscResourcesToExport = @( + 'FSRMSettings' + 'FSRMClassification' + 'FSRMClassificationProperty' + 'FSRMClassificationPropertyValue' + 'FSRMClassificationRule' + 'FSRMFileScreen' + 'FSRMFileScreenAction' + 'FSRMFileScreenTemplate' + 'FSRMFileScreenTemplateAction' + 'FSRMFileScreenException' + 'FSRMFileGroup' + 'FSRMQuota' + 'FSRMQuotaAction' + 'FSRMQuotaTemplate' + 'FSRMQuotaTemplateAction' + 'FSRMAutoQuota' + ) + + # 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 = @{ + + 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 = @('DesiredStateConfiguration', 'DSC', 'DSCResource', 'FSRM', 'FileServerResourceManager') + + # A URL to the license for this module. + LicenseUri = 'https://github.com/dsccommunity/FSRMDsc/blob/master/LICENSE' + + # A URL to the main website for this project. + ProjectUri = 'https://github.com/dsccommunity/FSRMDsc' + + # 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/source/en-US/about_FSRMDsc.help.txt b/source/en-US/about_FSRMDsc.help.txt new file mode 100644 index 00000000..0ee8b062 --- /dev/null +++ b/source/en-US/about_FSRMDsc.help.txt @@ -0,0 +1,25 @@ +TOPIC + about_FSRMDsc + +SHORT DESCRIPTION + DSC Resources for File Server Resource Manager configuration. + +LONG DESCRIPTION + This module contains DSC Resources for File Server Resource Manager configuration. + +EXAMPLES + PS C:\> Get-DscResource -Module FSRMDsc + +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/FSRMDsc + +SEE ALSO + - https://github.com/dsccommunity/FSRMDsc + +KEYWORDS + DSC, DscResource, FSRM, FileServerResourceManager diff --git a/tests/Integration/DSC_FSRMAutoQuota.Integration.Tests.ps1 b/tests/Integration/DSC_FSRMAutoQuota.Integration.Tests.ps1 new file mode 100644 index 00000000..87a0867f --- /dev/null +++ b/tests/Integration/DSC_FSRMAutoQuota.Integration.Tests.ps1 @@ -0,0 +1,82 @@ +$script:dscModuleName = 'FSRMDsc' +$script:dscResourceName = 'DSC_FSRMAutoQuota' + +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 +{ + Describe "$($script:DSCResourceName) Integration Tests" { + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).Config.ps1" + . $configFile + + Describe "$($script:dscResourceName)_Integration" { + $configData = @{ + AllNodes = @( + @{ + NodeName = 'localhost' + Path = [System.String] $TestDrive + Ensure = 'Present' + Disabled = $false + Template = (Get-FSRMQuotaTemplate | Select-Object -First 1).Name + } + ) + } + + It 'Should compile and apply the MOF without throwing' { + { + & "$($script:dscResourceName)_Config" ` + -OutputPath $TestDrive ` + -ConfigurationData $configData + + $startDscConfigurationParameters = @{ + Path = $TestDrive + ComputerName = 'localhost' + Wait = $true + Verbose = $true + Force = $true + ErrorAction = 'Stop' + } + + Start-DscConfiguration @startDscConfigurationParameters + } | 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' { + $current = Get-DscConfiguration | Where-Object -FilterScript { + $_.ConfigurationName -eq "$($script:dscResourceName)_Config" + } + $current.Path | Should -BeExactly $configData.AllNodes[0].Path + $current.Ensure | Should -BeExactly $configData.AllNodes[0].Ensure + $current.Disabled | Should -Be $configData.AllNodes[0].Disabled + $current.Template | Should -BeExactly $configData.AllNodes[0].Template + } + + Remove-FSRMAutoQuota -Path $configData.AllNodes[0].Path -Confirm:$false + } + } +} +finally +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} diff --git a/tests/Integration/DSC_FSRMAutoQuota.config.ps1 b/tests/Integration/DSC_FSRMAutoQuota.config.ps1 new file mode 100644 index 00000000..252ddc5b --- /dev/null +++ b/tests/Integration/DSC_FSRMAutoQuota.config.ps1 @@ -0,0 +1,12 @@ +Configuration DSC_FSRMAutoQuota_Config { + Import-DscResource -ModuleName FSRMDsc + + node localhost { + FSRMAutoQuota Integration_Test { + Path = $Node.Path + Ensure = $Node.Ensure + Disabled = $Node.Disabled + Template = $Node.Template + } + } +} diff --git a/tests/Integration/DSC_FSRMClassification.Integration.Tests.ps1 b/tests/Integration/DSC_FSRMClassification.Integration.Tests.ps1 new file mode 100644 index 00000000..d2c1a870 --- /dev/null +++ b/tests/Integration/DSC_FSRMClassification.Integration.Tests.ps1 @@ -0,0 +1,91 @@ +$script:dscModuleName = 'FSRMDsc' +$script:dscResourceName = 'DSC_FSRMClassification' + +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 +{ + Describe "$($script:DSCResourceName) Integration Tests" { + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).Config.ps1" + . $configFile + + Describe "$($script:dscResourceName)_Integration" { + $configData = @{ + AllNodes = @( + @{ + NodeName = 'localhost' + Id = 'Default' + Continuous = $false + ContinuousLog = $false + ContinuousLogSize = 2048 + ExcludeNamespace = @('[AllVolumes]\$Extend /','[AllVolumes]\System Volume Information /s') + ScheduleMonthly = @( 12,13 ) + ScheduleRunDuration = 10 + ScheduleTime = '13:00' + } + ) + } + + It 'Should compile and apply the MOF without throwing' { + { + & "$($script:dscResourceName)_Config" ` + -OutputPath $TestDrive ` + -ConfigurationData $configData + + $startDscConfigurationParameters = @{ + Path = $TestDrive + ComputerName = 'localhost' + Wait = $true + Verbose = $true + Force = $true + ErrorAction = 'Stop' + } + + Start-DscConfiguration @startDscConfigurationParameters + } | 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' { + $current = Get-DscConfiguration | Where-Object -FilterScript { + $_.ConfigurationName -eq "$($script:dscResourceName)_Config" + } + $current.Continuous | Should -Be $configData.AllNodes[0].Continuous + $current.ContinuousLog | Should -Be $configData.AllNodes[0].ContinuousLog + $current.ContinuousLogSize | Should -Be $configData.AllNodes[0].ContinuousLogSize + (Compare-Object ` + -ReferenceObject $current.ExcludeNamespace ` + -DifferenceObject $configData.AllNodes[0].ExcludeNamespace).Count | Should -Be 0 + (Compare-Object ` + -ReferenceObject $current.ScheduleMonthly ` + -DifferenceObject $configData.AllNodes[0].ScheduleMonthly).Count | Should -Be 0 + $current.ScheduleRunDuration | Should -Be $configData.AllNodes[0].ScheduleRunDuration + ([System.DateTime] $current.ScheduleTime).ToString('HH:mm') | Should -Be $configData.AllNodes[0].ScheduleTime + } + } + } +} +finally +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} diff --git a/tests/Integration/DSC_FSRMClassification.config.ps1 b/tests/Integration/DSC_FSRMClassification.config.ps1 new file mode 100644 index 00000000..51020208 --- /dev/null +++ b/tests/Integration/DSC_FSRMClassification.config.ps1 @@ -0,0 +1,16 @@ +Configuration DSC_FSRMClassification_Config { + Import-DscResource -ModuleName FSRMDsc + + node localhost { + FSRMClassification Integration_Test { + Id = $Node.Id + Continuous = $Node.Continuous + ContinuousLog = $Node.ContinuousLog + ContinuousLogSize = $Node.ContinuousLogSize + ExcludeNamespace = $Node.ExcludeNamespace + ScheduleMonthly = $Node.ScheduleMonthly + ScheduleRunDuration = $Node.ScheduleRunDuration + ScheduleTime = $Node.ScheduleTime + } + } +} diff --git a/tests/Integration/DSC_FSRMClassificationProperty.Integration.Tests.ps1 b/tests/Integration/DSC_FSRMClassificationProperty.Integration.Tests.ps1 new file mode 100644 index 00000000..57cb17e4 --- /dev/null +++ b/tests/Integration/DSC_FSRMClassificationProperty.Integration.Tests.ps1 @@ -0,0 +1,94 @@ +$script:dscModuleName = 'FSRMDsc' +$script:dscResourceName = 'DSC_FSRMClassificationProperty' + +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 +{ + Describe "$($script:DSCResourceName) Integration Tests" { + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).Config.ps1" + . $configFile + + Describe "$($script:dscResourceName)_Integration" { + $configData = @{ + AllNodes = @( + @{ + NodeName = 'localhost' + Name = 'IntegrationTest' + DisplayName = 'Integration Test' + Type = 'SingleChoice' + Ensure = 'Present' + Description = 'Integration Test Property' + PossibleValue = @( 'Value1', 'Value2', 'Value3' ) + Parameters = @( 'Parameter1=Value1', 'Parameter2=Value2') + } + ) + } + + It 'Should compile and apply the MOF without throwing' { + { + & "$($script:dscResourceName)_Config" ` + -OutputPath $TestDrive ` + -ConfigurationData $configData + + $startDscConfigurationParameters = @{ + Path = $TestDrive + ComputerName = 'localhost' + Wait = $true + Verbose = $true + Force = $true + ErrorAction = 'Stop' + } + + Start-DscConfiguration @startDscConfigurationParameters + } | 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' { + $current = Get-DscConfiguration | Where-Object -FilterScript { + $_.ConfigurationName -eq "$($script:dscResourceName)_Config" + } + $current.Name | Should -BeExactly $configData.AllNodes[0].Name + $current.DisplayName | Should -BeExactly $configData.AllNodes[0].DisplayName + $current.Type | Should -BeExactly $configData.AllNodes[0].Type + $current.Description | Should -BeExactly $configData.AllNodes[0].Description + (Compare-Object ` + -ReferenceObject $current.PossibleValue ` + -DifferenceObject $configData.AllNodes[0].PossibleValue).Count | Should -Be 0 + (Compare-Object ` + -ReferenceObject $current.Parameters ` + -DifferenceObject $configData.AllNodes[0].Parameters).Count | Should -Be 0 + } + + # Clean up + Remove-FSRMClassificationPropertyDefinition ` + -Name $configData.AllNodes[0].Name ` + -Confirm:$false + } + } +} +finally +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} diff --git a/tests/Integration/DSC_FSRMClassificationProperty.config.ps1 b/tests/Integration/DSC_FSRMClassificationProperty.config.ps1 new file mode 100644 index 00000000..ae95b4f9 --- /dev/null +++ b/tests/Integration/DSC_FSRMClassificationProperty.config.ps1 @@ -0,0 +1,15 @@ +Configuration DSC_FSRMClassificationProperty_Config { + Import-DscResource -ModuleName FSRMDsc + + node localhost { + FSRMClassificationProperty Integration_Test { + Name = $Node.Name + DisplayName = $Node.DisplayName + Type = $Node.Type + Ensure = $Node.Ensure + Description = $Node.Description + PossibleValue = $Node.PossibleValue + Parameters = $Node.Parameters + } + } +} diff --git a/tests/Integration/DSC_FSRMClassificationPropertyValue.Integration.Tests.ps1 b/tests/Integration/DSC_FSRMClassificationPropertyValue.Integration.Tests.ps1 new file mode 100644 index 00000000..34a73f59 --- /dev/null +++ b/tests/Integration/DSC_FSRMClassificationPropertyValue.Integration.Tests.ps1 @@ -0,0 +1,89 @@ +$script:dscModuleName = 'FSRMDsc' +$script:dscResourceName = 'DSC_FSRMClassificationPropertyValue' + +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 +{ + Describe "$($script:DSCResourceName) Integration Tests" { + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).Config.ps1" + . $configFile + + Describe "$($script:dscResourceName)_Integration" { + $configData = @{ + AllNodes = @( + @{ + NodeName = 'localhost' + Name = 'IntegrationTest' + PropertyName = 'IntegrationTest' + Description = 'Top Secret Description' + } + ) + } + + # Create the Classification Property that will be worked with + New-FSRMClassificationPropertyDefinition ` + -Name $configData.AllNodes[0].Name ` + -Type 'SingleChoice' ` + -PossibleValue @(New-FSRMClassificationPropertyValue -Name 'None') + + It 'Should compile and apply the MOF without throwing' { + { + & "$($script:dscResourceName)_Config" ` + -OutputPath $TestDrive ` + -ConfigurationData $configData + + $startDscConfigurationParameters = @{ + Path = $TestDrive + ComputerName = 'localhost' + Wait = $true + Verbose = $true + Force = $true + ErrorAction = 'Stop' + } + + Start-DscConfiguration @startDscConfigurationParameters + } | 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' { + $current = Get-DscConfiguration | Where-Object -FilterScript { + $_.ConfigurationName -eq "$($script:dscResourceName)_Config" + } + $current.Name | Should -BeExactly $configData.AllNodes[0].Name + $current.PropertyName | Should -BeExactly $configData.AllNodes[0].PropertyName + $current.Description | Should -BeExactly $configData.AllNodes[0].Description + } + + # Clean up + Remove-FSRMClassificationPropertyDefinition ` + -Name $configData.AllNodes[0].Name ` + -Confirm:$false + } + } +} +finally +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} diff --git a/tests/Integration/DSC_FSRMClassificationPropertyValue.config.ps1 b/tests/Integration/DSC_FSRMClassificationPropertyValue.config.ps1 new file mode 100644 index 00000000..bcec0bf7 --- /dev/null +++ b/tests/Integration/DSC_FSRMClassificationPropertyValue.config.ps1 @@ -0,0 +1,11 @@ +Configuration DSC_FSRMClassificationPropertyValue_Config { + Import-DscResource -ModuleName FSRMDsc + + node localhost { + FSRMClassificationPropertyValue Integration_Test { + Name = $Node.Name + PropertyName = $Node.PropertyName + Description = $Node.Description + } + } +} diff --git a/tests/Integration/DSC_FSRMClassificationRule.Tests.ps1 b/tests/Integration/DSC_FSRMClassificationRule.Tests.ps1 new file mode 100644 index 00000000..0f551a59 --- /dev/null +++ b/tests/Integration/DSC_FSRMClassificationRule.Tests.ps1 @@ -0,0 +1,112 @@ +$script:dscModuleName = 'FSRMDsc' +$script:dscResourceName = 'DSC_FSRMclassificationRule' + +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 +{ + Describe "$($script:DSCResourceName) Integration Tests" { + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).Config.ps1" + . $configFile + + Describe "$($script:dscResourceName)_Integration" { + $configData = @{ + AllNodes = @( + @{ + NodeName = 'localhost' + Name = 'IntegrationTest' + Description = 'Test Rule Description' + ClassificationMechanism = 'Content Classifier' + ContentRegularExpression = @( 'Regex1', 'Regex2' ) + ContentString = @( 'String1', 'String2' ) + ContentStringCaseSensitive = @( 'String1', 'String2' ) + Disabled = $false + Flags = @( 1024 ) + Namespace = @( '[FolderUsage_MS=User Files]', $ENV:Temp ) + Parameters = @( 'FileName=*.doc', 'FSRMClearruleInternal=0', 'FSRMClearPropertyInternal=1024' ) + Property = 'IntegrationTest' + PropertyValue = 'Value1' + ReevaluateProperty = 'Never' + } + ) + } + + # Create the Classification Property that will be worked with + New-FSRMClassificationPropertyDefinition ` + -Name $configData.AllNodes[0].Name ` + -Type 'SingleChoice' ` + -PossibleValue @(New-FSRMClassificationPropertyValue -Name 'Value1' ) + + It 'Should compile and apply the MOF without throwing' { + { + & "$($script:dscResourceName)_Config" ` + -OutputPath $TestDrive ` + -ConfigurationData $configData + + $startDscConfigurationParameters = @{ + Path = $TestDrive + ComputerName = 'localhost' + Wait = $true + Verbose = $true + Force = $true + ErrorAction = 'Stop' + } + + Start-DscConfiguration @startDscConfigurationParameters + } | 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' { + $current = Get-DscConfiguration | Where-Object -FilterScript { + $_.ConfigurationName -eq "$($script:dscResourceName)_Config" + } + $current.Name | Should -Be $configData.AllNodes[0].Name + $current.Description | Should -Be $configData.AllNodes[0].Description + $current.ClassificationMechanism | Should -Be $configData.AllNodes[0].ClassificationMechanism + $current.ContentRegularExpression | Should -Be $configData.AllNodes[0].ContentRegularExpression + $current.ContentString | Should -Be $configData.AllNodes[0].ContentString + $current.ContentStringCaseSensitive | Should -Be $configData.AllNodes[0].ContentStringCaseSensitive + $current.Disabled | Should -Be $configData.AllNodes[0].Disabled + $current.Flags | Should -Be 'ClearAutomaticallyClassifiedProperty' + $current.Namespace | Should -Be $configData.AllNodes[0].Namespace + $current.Parameters | Should -Be $configData.AllNodes[0].Parameters + $current.Property | Should -Be $configData.AllNodes[0].Property + $current.PropertyValue | Should -Be $configData.AllNodes[0].PropertyValue + $current.ReevaluateProperty | Should -Be $configData.AllNodes[0].ReevaluateProperty + } + + # Clean up + Remove-FSRMClassificationRule ` + -Name $configData.AllNodes[0].Name ` + -Confirm:$false + Remove-FSRMClassificationPropertyDefinition ` + -Name $configData.AllNodes[0].Name ` + -Confirm:$false + } + } +} +finally +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} diff --git a/tests/Integration/DSC_FSRMClassificationRule.config.ps1 b/tests/Integration/DSC_FSRMClassificationRule.config.ps1 new file mode 100644 index 00000000..3420036d --- /dev/null +++ b/tests/Integration/DSC_FSRMClassificationRule.config.ps1 @@ -0,0 +1,21 @@ +Configuration DSC_FSRMClassificationRule_Config { + Import-DscResource -ModuleName FSRMDsc + + node localhost { + FSRMClassificationRule Integration_Test { + Name = $Node.Name + Description = $Node.Description + ClassificationMechanism = $Node.ClassificationMechanism + ContentRegularExpression = $Node.ContentRegularExpression + ContentString = $Node.ContentString + ContentStringCaseSensitive = $Node.ContentStringCaseSensitive + Disabled = $Node.Disabled + Flags = $Node.Flags + Namespace = $Node.Namespace + Parameters = $Node.Parameters + Property = $Node.Property + PropertyValue = $Node.PropertyValue + ReevaluateProperty = $Node.ReevaluateProperty + } + } +} diff --git a/tests/Integration/DSC_FSRMFileGroup.Integration.Tests.ps1 b/tests/Integration/DSC_FSRMFileGroup.Integration.Tests.ps1 new file mode 100644 index 00000000..410d6e6c --- /dev/null +++ b/tests/Integration/DSC_FSRMFileGroup.Integration.Tests.ps1 @@ -0,0 +1,66 @@ +$script:dscModuleName = 'FSRMDsc' +$script:dscResourceName = 'DSC_FSRMFileGroup' + +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 +{ + Describe "$($script:DSCResourceName) Integration Tests" { + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).Config.ps1" + . $configFile + + Describe "$($script:DSCResourceName)_Integration" { + It 'Should compile and apply the MOF without throwing' { + { + & "$($script:DSCResourceName)_Config" -OutputPath $TestDrive + 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 + $filegroupNew = Get-FSRMFileGroup -Name $filegroup.Name + $filegroup.Name | Should -Be $filegroupNew.Name + $filegroup.Description | Should -Be $filegroupNew.Description + $filegroup.IncludePattern | Should -Be $filegroupNew.IncludePattern + $filegroup.ExcludePattern | Should -Be $filegroupNew.ExcludePattern + } + + # Clean up + Remove-FSRMFileGroup ` + -Name $filegroup.Name ` + -Confirm:$false + } + } +} +finally +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} diff --git a/Tests/Integration/DSR_FSRMFileGroup.config.ps1 b/tests/Integration/DSC_FSRMFileGroup.config.ps1 similarity index 93% rename from Tests/Integration/DSR_FSRMFileGroup.config.ps1 rename to tests/Integration/DSC_FSRMFileGroup.config.ps1 index fcfeecb5..af22f586 100644 --- a/Tests/Integration/DSR_FSRMFileGroup.config.ps1 +++ b/tests/Integration/DSC_FSRMFileGroup.config.ps1 @@ -6,7 +6,7 @@ $filegroup = @{ ExcludePattern = @('*.epsx') } -Configuration DSR_FSRMFileGroup_Config { +Configuration DSC_FSRMFileGroup_Config { Import-DscResource -ModuleName FSRMDsc node localhost { FSRMFileGroup Integration_Test { diff --git a/tests/Integration/DSC_FSRMFileScreen.Integration.Tests.ps1 b/tests/Integration/DSC_FSRMFileScreen.Integration.Tests.ps1 new file mode 100644 index 00000000..26082864 --- /dev/null +++ b/tests/Integration/DSC_FSRMFileScreen.Integration.Tests.ps1 @@ -0,0 +1,68 @@ +$script:dscModuleName = 'FSRMDsc' +$script:dscResourceName = 'DSC_FSRMFileScreen' + +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 +{ + Describe "$($script:DSCResourceName) Integration Tests" { + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).Config.ps1" + . $configFile + + Describe "$($script:DSCResourceName)_Integration" { + It 'Should compile and apply the MOF without throwing' { + { + & "$($script:DSCResourceName)_Config" -OutputPath $TestDrive + 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 + $fileScreenNew = Get-FSRMFileScreen -Path $fileScreen.Path + $fileScreen.Path | Should -Be $fileScreenNew.Path + $fileScreen.Description | Should -Be $fileScreenNew.Description + $fileScreen.Active | Should -Be $fileScreenNew.Active + $fileScreen.IncludeGroup | Should -Be $fileScreenNew.IncludeGroup + $fileScreen.Template | Should -Be $fileScreenNew.Template + $fileScreen.MatchesTemplate | Should -Be $fileScreenNew.MatchesTemplate + } + + # Clean up + Remove-FSRMFileScreen ` + -Path $fileScreen.Path ` + -Confirm:$false + } + } +} +finally +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} diff --git a/Tests/Integration/DSR_FSRMFileScreen.config.ps1 b/tests/Integration/DSC_FSRMFileScreen.config.ps1 similarity index 95% rename from Tests/Integration/DSR_FSRMFileScreen.config.ps1 rename to tests/Integration/DSC_FSRMFileScreen.config.ps1 index 7f577405..21307ec6 100644 --- a/Tests/Integration/DSR_FSRMFileScreen.config.ps1 +++ b/tests/Integration/DSC_FSRMFileScreen.config.ps1 @@ -8,7 +8,7 @@ $fileScreen = @{ MatchesTemplate = $false } -Configuration DSR_FSRMFileScreen_Config { +Configuration DSC_FSRMFileScreen_Config { Import-DscResource -ModuleName FSRMDsc node localhost { FSRMFileScreen Integration_Test { diff --git a/tests/Integration/DSC_FSRMFileScreenAction.Integration.Tests.ps1 b/tests/Integration/DSC_FSRMFileScreenAction.Integration.Tests.ps1 new file mode 100644 index 00000000..ca31a35b --- /dev/null +++ b/tests/Integration/DSC_FSRMFileScreenAction.Integration.Tests.ps1 @@ -0,0 +1,75 @@ +$script:dscModuleName = 'FSRMDsc' +$script:dscResourceName = 'DSC_FSRMFileScreenAction' + +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 +{ + Describe "$($script:DSCResourceName) Integration Tests" { + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).Config.ps1" + . $configFile + + Describe "$($script:DSCResourceName)_Integration" { + # Create the File Screen that will be worked with + New-FSRMFileScreen ` + -Path $fileScreen.Path ` + -Description $fileScreen.Description ` + -IncludeGroup $fileScreen.IncludeGroup ` + -Template $fileScreen.Template + + It 'Should compile and apply the MOF without throwing' { + { + & "$($script:DSCResourceName)_Config" -OutputPath $TestDrive + 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 + $fileScreenNew = Get-FSRMFileScreen -Path $fileScreen.Path + $fileScreenNew.Notification[1].Type | Should -Be $fileScreenAction.Type + $fileScreenNew.Notification[1].Subject | Should -Be $fileScreenAction.Subject + $fileScreenNew.Notification[1].Body | Should -Be $fileScreenAction.Body + $fileScreenNew.Notification[1].MailBCC | Should -Be $fileScreenAction.MailBCC + $fileScreenNew.Notification[1].MailCC | Should -Be $fileScreenAction.MailCC + $fileScreenNew.Notification[1].MailTo | Should -Be $fileScreenAction.MailTo + } + + # Clean up + Remove-FSRMFileScreen ` + -Path $fileScreen.Path ` + -Confirm:$false + } + } +} +finally +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} diff --git a/Tests/Integration/DSR_FSRMFileScreenAction.config.ps1 b/tests/Integration/DSC_FSRMFileScreenAction.config.ps1 similarity index 96% rename from Tests/Integration/DSR_FSRMFileScreenAction.config.ps1 rename to tests/Integration/DSC_FSRMFileScreenAction.config.ps1 index 58dc0025..6721c3b4 100644 --- a/Tests/Integration/DSR_FSRMFileScreenAction.config.ps1 +++ b/tests/Integration/DSC_FSRMFileScreenAction.config.ps1 @@ -16,7 +16,7 @@ $fileScreenAction = @{ MailTo = '[Source Io Owner Email]' } -Configuration DSR_FSRMFileScreenAction_Config { +Configuration DSC_FSRMFileScreenAction_Config { Import-DscResource -ModuleName FSRMDsc node localhost { FSRMFileScreenAction Integration_Test { diff --git a/tests/Integration/DSC_FSRMFileScreenException.Integration.Tests.ps1 b/tests/Integration/DSC_FSRMFileScreenException.Integration.Tests.ps1 new file mode 100644 index 00000000..64c9a314 --- /dev/null +++ b/tests/Integration/DSC_FSRMFileScreenException.Integration.Tests.ps1 @@ -0,0 +1,75 @@ +$script:dscModuleName = 'FSRMDsc' +$script:dscResourceName = 'DSC_FSRMFileScreenException' + +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 +{ + Describe "$($script:DSCResourceName) Integration Tests" { + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).Config.ps1" + . $configFile + + Describe "$($script:DSCResourceName)_Integration" { + # Create the File Screen that will be worked with + New-FSRMFileScreen ` + -Path $fileScreen.Path ` + -Description $fileScreen.Description ` + -IncludeGroup $fileScreen.IncludeGroup ` + -Template $fileScreen.Template + + It 'Should compile and apply the MOF without throwing' { + { + & "$($script:DSCResourceName)_Config" -OutputPath $TestDrive + 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 + $fileScreenExceptionNew = Get-FSRMFileScreenException -Path $fileScreenException.Path + $fileScreenException.Path | Should -Be $fileScreenExceptionNew.Path + $fileScreenException.Description | Should -Be $fileScreenExceptionNew.Description + $fileScreenException.IncludeGroup | Should -Be $fileScreenExceptionNew.IncludeGroup + } + + # Clean up + Remove-FSRMFileScreenException ` + -Path $fileScreenException.Path ` + -Confirm:$false + Remove-FSRMFileScreen ` + -Path $fileScreen.Path ` + -Confirm:$false + } + } +} +finally +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} diff --git a/Tests/Integration/DSR_FSRMFileScreenException.config.ps1 b/tests/Integration/DSC_FSRMFileScreenException.config.ps1 similarity index 95% rename from Tests/Integration/DSR_FSRMFileScreenException.config.ps1 rename to tests/Integration/DSC_FSRMFileScreenException.config.ps1 index 51576b6d..5d10d390 100644 --- a/Tests/Integration/DSR_FSRMFileScreenException.config.ps1 +++ b/tests/Integration/DSC_FSRMFileScreenException.config.ps1 @@ -14,7 +14,7 @@ $fileScreenException = @{ IncludeGroup = [System.Collections.ArrayList]@( 'Audio and Video Files','Executable Files','Backup Files' ) } -Configuration DSR_FSRMFileScreenException_Config { +Configuration DSC_FSRMFileScreenException_Config { Import-DscResource -ModuleName FSRMDsc node localhost { FSRMFileScreenException Integration_Test { diff --git a/tests/Integration/DSC_FSRMFileScreenTemplate.Integration.Tests.ps1 b/tests/Integration/DSC_FSRMFileScreenTemplate.Integration.Tests.ps1 new file mode 100644 index 00000000..db130b59 --- /dev/null +++ b/tests/Integration/DSC_FSRMFileScreenTemplate.Integration.Tests.ps1 @@ -0,0 +1,66 @@ +$script:dscModuleName = 'FSRMDsc' +$script:dscResourceName = 'DSC_FSRMFileScreenTemplate' + +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 +{ + Describe "$($script:DSCResourceName) Integration Tests" { + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).Config.ps1" + . $configFile + + Describe "$($script:DSCResourceName)_Integration" { + It 'Should compile and apply the MOF without throwing' { + { + & "$($script:DSCResourceName)_Config" -OutputPath $TestDrive + 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 + $fileScreenTemplateNew = Get-FSRMFileScreenTemplate -Name $fileScreenTemplate.Name + $fileScreenTemplate.Name | Should -Be $fileScreenTemplateNew.Name + $fileScreenTemplate.Description | Should -Be $fileScreenTemplateNew.Description + $fileScreenTemplate.Active | Should -Be $fileScreenTemplateNew.Active + $fileScreenTemplate.IncludeGroup | Should -Be $fileScreenTemplateNew.IncludeGroup + } + + # Clean up + Remove-FSRMFileScreenTemplate ` + -Name $fileScreenTemplate.Name ` + -Confirm:$false + } + } +} +finally +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} diff --git a/Tests/Integration/DSR_FSRMFileScreenTemplate.config.ps1 b/tests/Integration/DSC_FSRMFileScreenTemplate.config.ps1 similarity index 93% rename from Tests/Integration/DSR_FSRMFileScreenTemplate.config.ps1 rename to tests/Integration/DSC_FSRMFileScreenTemplate.config.ps1 index 6c3ed602..4abd5639 100644 --- a/Tests/Integration/DSR_FSRMFileScreenTemplate.config.ps1 +++ b/tests/Integration/DSC_FSRMFileScreenTemplate.config.ps1 @@ -6,7 +6,7 @@ $fileScreenTemplate = @{ IncludeGroup = [System.Collections.ArrayList]@( 'Audio and Video Files','Executable Files','Backup Files' ) } -Configuration DSR_FSRMFileScreenTemplate_Config { +Configuration DSC_FSRMFileScreenTemplate_Config { Import-DscResource -ModuleName FSRMDsc node localhost { FSRMFileScreenTemplate Integration_Test { diff --git a/tests/Integration/DSC_FSRMFileScreenTemplateAction.Integration.Tests.ps1 b/tests/Integration/DSC_FSRMFileScreenTemplateAction.Integration.Tests.ps1 new file mode 100644 index 00000000..01f57d87 --- /dev/null +++ b/tests/Integration/DSC_FSRMFileScreenTemplateAction.Integration.Tests.ps1 @@ -0,0 +1,74 @@ +$script:dscModuleName = 'FSRMDsc' +$script:dscResourceName = 'DSC_FSRMFileScreenTemplateAction' + +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 +{ + Describe "$($script:DSCResourceName) Integration Tests" { + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).Config.ps1" + . $configFile + + Describe "$($script:DSCResourceName)_Integration" { + # Create the File Screen that will be worked with + New-FSRMFileScreenTemplate ` + -Name $fileScreenTemplate.Name ` + -Description $fileScreenTemplate.Description ` + -IncludeGroup $fileScreenTemplate.IncludeGroup + + It 'Should compile and apply the MOF without throwing' { + { + & "$($script:DSCResourceName)_Config" -OutputPath $TestDrive + 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 + $fileScreenTemplateNew = Get-FSRMFileScreenTemplate -Name $fileScreenTemplate.Name + $fileScreenTemplateNew.Notification[0].Type | Should -Be $fileScreenTemplateAction.Type + $fileScreenTemplateNew.Notification[0].Subject | Should -Be $fileScreenTemplateAction.Subject + $fileScreenTemplateNew.Notification[0].Body | Should -Be $fileScreenTemplateAction.Body + $fileScreenTemplateNew.Notification[0].MailBCC | Should -Be $fileScreenTemplateAction.MailBCC + $fileScreenTemplateNew.Notification[0].MailCC | Should -Be $fileScreenTemplateAction.MailCC + $fileScreenTemplateNew.Notification[0].MailTo | Should -Be $fileScreenTemplateAction.MailTo + } + + # Clean up + Remove-FSRMFileScreenTemplate ` + -Name $fileScreenTemplate.Name ` + -Confirm:$false + } + } +} +finally +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} diff --git a/Tests/Integration/DSR_FSRMFileScreenTemplateAction.config.ps1 b/tests/Integration/DSC_FSRMFileScreenTemplateAction.config.ps1 similarity index 96% rename from Tests/Integration/DSR_FSRMFileScreenTemplateAction.config.ps1 rename to tests/Integration/DSC_FSRMFileScreenTemplateAction.config.ps1 index 5eeebedb..a57fe6fe 100644 --- a/Tests/Integration/DSR_FSRMFileScreenTemplateAction.config.ps1 +++ b/tests/Integration/DSC_FSRMFileScreenTemplateAction.config.ps1 @@ -14,7 +14,7 @@ $fileScreenTemplateAction = @{ MailTo = '[Source Io Owner Email]' } -Configuration DSR_FSRMFileScreenTemplateAction_Config { +Configuration DSC_FSRMFileScreenTemplateAction_Config { Import-DscResource -ModuleName FSRMDsc node localhost { FSRMFileScreenTemplateAction Integration_Test { diff --git a/tests/Integration/DSC_FSRMQuota.Integration.Tests.ps1 b/tests/Integration/DSC_FSRMQuota.Integration.Tests.ps1 new file mode 100644 index 00000000..18b87423 --- /dev/null +++ b/tests/Integration/DSC_FSRMQuota.Integration.Tests.ps1 @@ -0,0 +1,70 @@ +$script:dscModuleName = 'FSRMDsc' +$script:dscResourceName = 'DSC_FSRMQuota' + +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 +{ + Describe "$($script:DSCResourceName) Integration Tests" { + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).Config.ps1" + . $configFile + + Describe "$($script:DSCResourceName)_Integration" { + It 'Should compile and apply the MOF without throwing' { + { + & "$($script:DSCResourceName)_Config" -OutputPath $TestDrive + 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 + $quotaNew = Get-FSRMQuota -Path $quota.Path + $quota.Path | Should -Be $quotaNew.Path + $quota.Description | Should -Be $quotaNew.Description + $quota.Size | Should -Be $quotaNew.Size + $quota.SoftLimit | Should -Be $quotaNew.SoftLimit + (Compare-Object ` + -ReferenceObject $quota.ThresholdPercentages ` + -DifferenceObject $quotaNew.Threshold.Percentage).Count | Should -Be 0 + $quota.Disabled | Should -Be $quotaNew.Disabled + } + + # Clean up + Remove-FSRMQuota ` + -Path $quota.Path ` + -Confirm:$false + } + } +} +finally +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} diff --git a/Tests/Integration/DSR_FSRMQuota.config.ps1 b/tests/Integration/DSC_FSRMQuota.config.ps1 similarity index 94% rename from Tests/Integration/DSR_FSRMQuota.config.ps1 rename to tests/Integration/DSC_FSRMQuota.config.ps1 index 2f087ce8..27f0517f 100644 --- a/Tests/Integration/DSR_FSRMQuota.config.ps1 +++ b/tests/Integration/DSC_FSRMQuota.config.ps1 @@ -8,7 +8,7 @@ $quota = @{ Disabled = $false } -Configuration DSR_FSRMQuota_Config { +Configuration DSC_FSRMQuota_Config { Import-DscResource -ModuleName FSRMDsc node localhost { FSRMQuota Integration_Test { diff --git a/tests/Integration/DSC_FSRMQuotaAction.Integration.Tests.ps1 b/tests/Integration/DSC_FSRMQuotaAction.Integration.Tests.ps1 new file mode 100644 index 00000000..9217b074 --- /dev/null +++ b/tests/Integration/DSC_FSRMQuotaAction.Integration.Tests.ps1 @@ -0,0 +1,75 @@ +$script:dscModuleName = 'FSRMDsc' +$script:dscResourceName = 'DSC_FSRMQuotaAction' + +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 +{ + Describe "$($script:DSCResourceName) Integration Tests" { + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).Config.ps1" + . $configFile + + Describe "$($script:DSCResourceName)_Integration" { + # Create the File Screen that will be worked with + New-FSRMQuota ` + -Path $quota.Path ` + -Description $quota.Description ` + -Size $quota.Size ` + -Threshold (New-FSRMQuotaThreshold -Percentage $quota.ThresholdPercentages[0]) + + It 'Should compile and apply the MOF without throwing' { + { + & "$($script:DSCResourceName)_Config" -OutputPath $TestDrive + 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 + $quotaNew = Get-FSRMQuota -Path $quota.Path + $quotaNew.Threshold[0].Action[0].Type | Should -Be $quotaAction.Type + $quotaNew.Threshold[0].Action[0].Subject | Should -Be $quotaAction.Subject + $quotaNew.Threshold[0].Action[0].Body | Should -Be $quotaAction.Body + $quotaNew.Threshold[0].Action[0].MailBCC | Should -Be $quotaAction.MailBCC + $quotaNew.Threshold[0].Action[0].MailCC | Should -Be $quotaAction.MailCC + $quotaNew.Threshold[0].Action[0].MailTo | Should -Be $quotaAction.MailTo + } + + # Clean up + Remove-FSRMQuota ` + -Path $quota.Path ` + -Confirm:$false + } + } +} +finally +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} diff --git a/Tests/Integration/DSR_FSRMQuotaAction.config.ps1 b/tests/Integration/DSC_FSRMQuotaAction.config.ps1 similarity index 96% rename from Tests/Integration/DSR_FSRMQuotaAction.config.ps1 rename to tests/Integration/DSC_FSRMQuotaAction.config.ps1 index c131fac7..183ed3e7 100644 --- a/Tests/Integration/DSR_FSRMQuotaAction.config.ps1 +++ b/tests/Integration/DSC_FSRMQuotaAction.config.ps1 @@ -16,7 +16,7 @@ $quotaAction = @{ MailTo = '[Source Io Owner Email]' } -Configuration DSR_FSRMQuotaAction_Config { +Configuration DSC_FSRMQuotaAction_Config { Import-DscResource -ModuleName FSRMDsc node localhost { FSRMQuotaAction Integration_Test { diff --git a/tests/Integration/DSC_FSRMQuotaTemplate.Integration.Tests.ps1 b/tests/Integration/DSC_FSRMQuotaTemplate.Integration.Tests.ps1 new file mode 100644 index 00000000..2f54c69e --- /dev/null +++ b/tests/Integration/DSC_FSRMQuotaTemplate.Integration.Tests.ps1 @@ -0,0 +1,69 @@ +$script:dscModuleName = 'FSRMDsc' +$script:dscResourceName = 'DSC_FSRMQuotaTemplate' + +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 +{ + Describe "$($script:DSCResourceName) Integration Tests" { + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).Config.ps1" + . $configFile + + Describe "$($script:DSCResourceName)_Integration" { + It 'Should compile and apply the MOF without throwing' { + { + & "$($script:DSCResourceName)_Config" -OutputPath $TestDrive + 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 + $quotaTemplateNew = Get-FSRMQuotaTemplate -Name $quotaTemplate.Name + $quotaTemplate.Name | Should -Be $quotaTemplateNew.Name + $quotaTemplate.Description | Should -Be $quotaTemplateNew.Description + $quotaTemplate.Size | Should -Be $quotaTemplateNew.Size + $quotaTemplate.SoftLimit | Should -Be $quotaTemplateNew.SoftLimit + (Compare-Object ` + -ReferenceObject $quotaTemplate.ThresholdPercentages ` + -DifferenceObject $quotaTemplateNew.Threshold.Percentage).Count | Should -Be 0 + } + + # Clean up + Remove-FSRMQuotaTemplate ` + -Name $quotaTemplate.Name ` + -Confirm:$false + } + } +} +finally +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} diff --git a/Tests/Integration/DSR_FSRMQuotaTemplate.config.ps1 b/tests/Integration/DSC_FSRMQuotaTemplate.config.ps1 similarity index 93% rename from Tests/Integration/DSR_FSRMQuotaTemplate.config.ps1 rename to tests/Integration/DSC_FSRMQuotaTemplate.config.ps1 index 1916eb74..77091734 100644 --- a/Tests/Integration/DSR_FSRMQuotaTemplate.config.ps1 +++ b/tests/Integration/DSC_FSRMQuotaTemplate.config.ps1 @@ -7,7 +7,7 @@ $quotaTemplate = @{ ThresholdPercentages = [System.Collections.ArrayList]@( 85, 100 ) } -Configuration DSR_FSRMQuotaTemplate_Config { +Configuration DSC_FSRMQuotaTemplate_Config { Import-DscResource -ModuleName FSRMDsc node localhost { FSRMQuotaTemplate Integration_Test { diff --git a/tests/Integration/DSC_FSRMQuotaTemplateAction.Integration.Tests.ps1 b/tests/Integration/DSC_FSRMQuotaTemplateAction.Integration.Tests.ps1 new file mode 100644 index 00000000..6cfc4cc6 --- /dev/null +++ b/tests/Integration/DSC_FSRMQuotaTemplateAction.Integration.Tests.ps1 @@ -0,0 +1,75 @@ +$script:dscModuleName = 'FSRMDsc' +$script:dscResourceName = 'DSC_FSRMQuotaTemplateAction' + +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 +{ + Describe "$($script:DSCResourceName) Integration Tests" { + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).Config.ps1" + . $configFile + + Describe "$($script:DSCResourceName)_Integration" { + # Create the File Screen that will be worked with + New-FSRMQuotaTemplate ` + -Name $quotaTemplate.Name ` + -Description $quotaTemplate.Description ` + -Size $quotaTemplate.Size ` + -Threshold (New-FSRMQuotaThreshold -Percentage $quotaTemplate.ThresholdPercentages[0]) + + It 'Should compile and apply the MOF without throwing' { + { + & "$($script:DSCResourceName)_Config" -OutputPath $TestDrive + 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 + $quotaTemplateNew = Get-FSRMQuotaTemplate -Name $quotaTemplate.Name + $quotaTemplateNew.Threshold[0].Action[0].Type | Should -Be $quotaAction.Type + $quotaTemplateNew.Threshold[0].Action[0].Subject | Should -Be $quotaAction.Subject + $quotaTemplateNew.Threshold[0].Action[0].Body | Should -Be $quotaAction.Body + $quotaTemplateNew.Threshold[0].Action[0].MailBCC | Should -Be $quotaAction.MailBCC + $quotaTemplateNew.Threshold[0].Action[0].MailCC | Should -Be $quotaAction.MailCC + $quotaTemplateNew.Threshold[0].Action[0].MailTo | Should -Be $quotaAction.MailTo + } + + # Clean up + Remove-FSRMQuotaTemplate ` + -Name $quotaTemplate.Name ` + -Confirm:$false + } + } +} +finally +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} diff --git a/Tests/Integration/DSR_FSRMQuotaTemplateAction.config.ps1 b/tests/Integration/DSC_FSRMQuotaTemplateAction.config.ps1 similarity index 96% rename from Tests/Integration/DSR_FSRMQuotaTemplateAction.config.ps1 rename to tests/Integration/DSC_FSRMQuotaTemplateAction.config.ps1 index 06f77cb1..52ede1f1 100644 --- a/Tests/Integration/DSR_FSRMQuotaTemplateAction.config.ps1 +++ b/tests/Integration/DSC_FSRMQuotaTemplateAction.config.ps1 @@ -15,7 +15,7 @@ $quotaAction = @{ MailTo = '[Source Io Owner Email]' } -Configuration DSR_FSRMQuotaTemplateAction_Config { +Configuration DSC_FSRMQuotaTemplateAction_Config { Import-DscResource -ModuleName FSRMDsc node localhost { FSRMQuotaTemplateAction Integration_Test { diff --git a/tests/Integration/DSC_FSRMSettings.Integration.Tests.ps1 b/tests/Integration/DSC_FSRMSettings.Integration.Tests.ps1 new file mode 100644 index 00000000..bc546742 --- /dev/null +++ b/tests/Integration/DSC_FSRMSettings.Integration.Tests.ps1 @@ -0,0 +1,84 @@ +$script:dscModuleName = 'FSRMDsc' +$script:dscResourceName = 'DSC_FSRMSettings' + +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 +{ + Describe "$($script:DSCResourceName) Integration Tests" { + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).Config.ps1" + . $configFile + + Describe "$($script:DSCResourceName)_Integration" { + $configData = @{ + AllNodes = @( + @{ + NodeName = 'localhost' + SmtpServer = 'smtp.contoso.com' + AdminEmailAddress = 'admin@contoso.com' + FromEmailAddress = 'fsrm@contoso.com' + CommandNotificationLimit = 10 + EmailNotificationLimit = 20 + EventNotificationLimit = 30 + } + ) + } + + It 'Should compile and apply the MOF without throwing' { + { + & "$($script:dscResourceName)_Config" ` + -OutputPath $TestDrive ` + -ConfigurationData $configData + + $startDscConfigurationParameters = @{ + Path = $TestDrive + ComputerName = 'localhost' + Wait = $true + Verbose = $true + Force = $true + ErrorAction = 'Stop' + } + + Start-DscConfiguration @startDscConfigurationParameters + } | 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' { + $current = Get-DscConfiguration | Where-Object -FilterScript { + $_.ConfigurationName -eq "$($script:dscResourceName)_Config" + } + $current.SmtpServer | Should -Be $configData.AllNodes[0].SmtpServer + $current.AdminEmailAddress | Should -Be $configData.AllNodes[0].AdminEmailAddress + $current.FromEmailAddress | Should -Be $configData.AllNodes[0].FromEmailAddress + $current.CommandNotificationLimit | Should -Be $configData.AllNodes[0].CommandNotificationLimit + $current.EmailNotificationLimit | Should -Be $configData.AllNodes[0].EmailNotificationLimit + $current.EventNotificationLimit | Should -Be $configData.AllNodes[0].EventNotificationLimit + } + } + } +} +finally +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} diff --git a/tests/Integration/DSC_FSRMSettings.config.ps1 b/tests/Integration/DSC_FSRMSettings.config.ps1 new file mode 100644 index 00000000..e4eea874 --- /dev/null +++ b/tests/Integration/DSC_FSRMSettings.config.ps1 @@ -0,0 +1,15 @@ +Configuration DSC_FSRMSettings_Config { + Import-DscResource -ModuleName FSRMDsc + + node localhost { + FSRMSettings Integration_Test { + IsSingleInstance = 'Yes' + SmtpServer = $Node.SmtpServer + AdminEmailAddress = $Node.AdminEmailAddress + FromEmailAddress = $Node.FromEmailAddress + CommandNotificationLimit = $Node.CommandNotificationLimit + EmailNotificationLimit = $Node.EmailNotificationLimit + EventNotificationLimit = $Node.EventNotificationLimit + } + } +} 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/DSR_FSRMAutoQuota.Tests.ps1 b/tests/Unit/DSC_FSRMAutoQuota.Tests.ps1 similarity index 87% rename from Tests/Unit/DSR_FSRMAutoQuota.Tests.ps1 rename to tests/Unit/DSC_FSRMAutoQuota.Tests.ps1 index 751ec4f9..66d85810 100644 --- a/Tests/Unit/DSR_FSRMAutoQuota.Tests.ps1 +++ b/tests/Unit/DSC_FSRMAutoQuota.Tests.ps1 @@ -1,31 +1,37 @@ -$script:DSCModuleName = 'FSRMDsc' -$script:DSCResourceName = 'DSR_FSRMAutoQuota' +$script:dscModuleName = 'FSRMDsc' +$script:dscResourceName = 'DSC_FSRMAutoQuota' -Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global +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' -#region HEADER -# Unit 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'))) ) + Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.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 { - #region Pester Tests - InModuleScope $script:DSCResourceName { - $script:DSCResourceName = 'DSR_FSRMAutoQuota' - + InModuleScope $script:dscResourceName { # Create the Mock -CommandName Objects that will be used for running tests $script:TestAutoQuota = [PSObject]@{ Path = $ENV:Temp @@ -41,7 +47,7 @@ try Template = $script:TestAutoQuota.Template } - Describe "$($script:DSCResourceName)\Get-TargetResource" { + Describe 'DSC_FSRMAutoQuota\Get-TargetResource' { Context 'No auto quotas exist' { Mock -CommandName Get-FsrmAutoQuota @@ -72,7 +78,7 @@ try } } - Describe "$($script:DSCResourceName)\Set-TargetResource" { + Describe 'DSC_FSRMAutoQuota\Set-TargetResource' { Context 'auto quota does not exist but should' { Mock -CommandName Assert-ResourcePropertiesValid Mock -CommandName Get-FsrmAutoQuota @@ -188,7 +194,7 @@ try } } - Describe "$($script:DSCResourceName)\Test-TargetResource" { + Describe 'DSC_FSRMAutoQuota\Test-TargetResource' { Context 'auto quota path does not exist' { Mock -CommandName Get-FsrmQuotaTemplate Mock -CommandName Test-Path -MockWith { $false } @@ -197,7 +203,7 @@ try $testTargetResourceParameters = $script:TestAutoQuota.Clone() $errorRecord = Get-InvalidArgumentRecord ` - -Message ($($LocalizedData.AutoQuotaPathDoesNotExistError) -f $testTargetResourceParameters.Path) ` + -Message ($($script:localizedData.AutoQuotaPathDoesNotExistError) -f $testTargetResourceParameters.Path) ` -ArgumentName 'Path' { Test-TargetResource @testTargetResourceParameters } | Should -Throw $errorRecord @@ -211,7 +217,7 @@ try $testTargetResourceParameters = $script:TestAutoQuota.Clone() $errorRecord = Get-InvalidArgumentRecord ` - -Message ($($LocalizedData.AutoQuotaTemplateNotFoundError) -f $testTargetResourceParameters.Path,$testTargetResourceParameters.Template) ` + -Message ($($script:localizedData.AutoQuotaTemplateNotFoundError) -f $testTargetResourceParameters.Path,$testTargetResourceParameters.Template) ` -ArgumentName 'Template' { Test-TargetResource @testTargetResourceParameters } | Should -Throw $errorRecord @@ -226,7 +232,7 @@ try $testTargetResourceParameters.Template = '' $errorRecord = Get-InvalidArgumentRecord ` - -Message ($($LocalizedData.AutoQuotaTemplateEmptyError) -f $testTargetResourceParameters.Path) ` + -Message ($($script:localizedData.AutoQuotaTemplateEmptyError) -f $testTargetResourceParameters.Path) ` -ArgumentName 'Template' { Test-TargetResource @testTargetResourceParameters } | Should -Throw $errorRecord @@ -333,11 +339,8 @@ try } } } - #endregion } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Invoke-TestCleanup } diff --git a/Tests/Unit/DSR_FSRMClassification.Tests.ps1 b/tests/Unit/DSC_FSRMClassification.Tests.ps1 similarity index 92% rename from Tests/Unit/DSR_FSRMClassification.Tests.ps1 rename to tests/Unit/DSC_FSRMClassification.Tests.ps1 index ca9ab4e0..78b0780a 100644 --- a/Tests/Unit/DSR_FSRMClassification.Tests.ps1 +++ b/tests/Unit/DSC_FSRMClassification.Tests.ps1 @@ -1,31 +1,37 @@ -$script:DSCModuleName = 'FSRMDsc' -$script:DSCResourceName = 'DSR_FSRMClassification' +$script:dscModuleName = 'FSRMDsc' +$script:dscResourceName = 'DSC_FSRMClassification' -Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global +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' -#region HEADER -# Unit 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'))) ) + Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.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 { - #region Pester Tests - InModuleScope $script:DSCResourceName { - $script:DSCResourceName = 'DSR_FSRMClassification' - + InModuleScope $script:dscResourceName { # Create the Mock -CommandName Objects that will be used for running tests $script:ClassificationMonthly = [PSObject] @{ Id = 'Default' @@ -95,7 +101,7 @@ try Schedule = $script:MockScheduledTaskWeekly } - Describe "$($script:DSCResourceName)\Get-TargetResource" { + Describe 'DSC_FSRMClassification\Get-TargetResource' { Context 'Monthly schedule configuration' { Mock -CommandName Get-FSRMClassification -MockWith { $script:MockClassificationMonthly } @@ -135,7 +141,7 @@ try } } - Describe "$($script:DSCResourceName)\Set-TargetResource" { + Describe 'DSC_FSRMClassification\Set-TargetResource' { Context 'classification has a different Continuous property' { Mock -CommandName Get-FSRMClassification -MockWith { $script:MockClassificationMonthly } Mock -CommandName Set-FSRMClassification @@ -281,7 +287,7 @@ try } } - Describe "$($script:DSCResourceName)\Test-TargetResource" { + Describe 'DSC_FSRMClassification\Test-TargetResource' { Context 'classification has no property differences' { Mock -CommandName Get-FSRMClassification -MockWith { $script:MockClassificationMonthly } @@ -408,11 +414,8 @@ try } } } - #endregion } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Invoke-TestCleanup } diff --git a/Tests/Unit/DSR_FSRMClassificationProperty.Tests.ps1 b/tests/Unit/DSC_FSRMClassificationProperty.Tests.ps1 similarity index 93% rename from Tests/Unit/DSR_FSRMClassificationProperty.Tests.ps1 rename to tests/Unit/DSC_FSRMClassificationProperty.Tests.ps1 index 3d22ce10..43e69f2e 100644 --- a/Tests/Unit/DSR_FSRMClassificationProperty.Tests.ps1 +++ b/tests/Unit/DSC_FSRMClassificationProperty.Tests.ps1 @@ -1,31 +1,37 @@ -$script:DSCModuleName = 'FSRMDsc' -$script:DSCResourceName = 'DSR_FSRMClassificationProperty' +$script:dscModuleName = 'FSRMDsc' +$script:dscResourceName = 'DSC_FSRMClassificationProperty' -Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global +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' -#region HEADER -# Unit 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'))) ) + Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.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 { - #region Pester Tests - InModuleScope $script:DSCResourceName { - $script:DSCResourceName = 'DSR_FSRMClassificationProperty' - + InModuleScope $script:dscResourceName { # Create the Mock -CommandName Objects that will be used for running tests $script:MockClassificationPossibleValue1 = New-CimInstance ` -ClassName 'MSFT_FSRMClassificationPropertyDefinitionValue' ` @@ -78,7 +84,7 @@ try PossibleValue = [Microsoft.Management.Infrastructure.CimInstance[]]@( $script:MockClassificationPossibleValue1, $script:MockClassificationPossibleValue2, $script:MockClassificationPossibleValue3 ) } - Describe "$($script:DSCResourceName)\Get-TargetResource" { + Describe 'DSC_FSRMClassificationProperty\Get-TargetResource' { Context 'No classification properties exist' { Mock -CommandName Get-FSRMClassificationPropertyDefinition @@ -112,7 +118,7 @@ try } } - Describe "$($script:DSCResourceName)\Set-TargetResource" { + Describe 'DSC_FSRMClassificationProperty\Set-TargetResource' { Context 'classification property does not exist but should' { Mock -CommandName Get-FSRMClassificationPropertyDefinition Mock -CommandName New-FSRMClassificationPropertyDefinition @@ -289,7 +295,7 @@ try } } - Describe "$($script:DSCResourceName)\Test-TargetResource" { + Describe 'DSC_FSRMClassificationProperty\Test-TargetResource' { Context 'classification property does not exist but should' { Mock -CommandName Get-FSRMClassificationPropertyDefinition @@ -432,11 +438,8 @@ try } } } - #endregion } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Invoke-TestCleanup } diff --git a/Tests/Unit/DSR_FSRMClassificationPropertyValue.Tests.ps1 b/tests/Unit/DSC_FSRMClassificationPropertyValue.Tests.ps1 similarity index 87% rename from Tests/Unit/DSR_FSRMClassificationPropertyValue.Tests.ps1 rename to tests/Unit/DSC_FSRMClassificationPropertyValue.Tests.ps1 index 66981774..df1c9069 100644 --- a/Tests/Unit/DSR_FSRMClassificationPropertyValue.Tests.ps1 +++ b/tests/Unit/DSC_FSRMClassificationPropertyValue.Tests.ps1 @@ -1,31 +1,37 @@ -$script:DSCModuleName = 'FSRMDsc' -$script:DSCResourceName = 'DSR_FSRMClassificationPropertyValue' +$script:dscModuleName = 'FSRMDsc' +$script:dscResourceName = 'DSC_FSRMClassificationPropertyValue' -Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global +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' -#region HEADER -# Unit 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'))) ) + Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.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 { - #region Pester Tests - InModuleScope $script:DSCResourceName { - $script:DSCResourceName = 'DSR_FSRMClassificationPropertyValue' - + InModuleScope $script:dscResourceName { # Create the Mock -CommandName Objects that will be used for running tests $script:MockClassificationPossibleValue1 = New-CimInstance ` -ClassName 'MSFT_FSRMClassificationPropertyDefinitionValue' ` @@ -88,7 +94,7 @@ try Verbose = $true } - Describe "$($script:DSCResourceName)\Get-TargetResource" { + Describe 'DSC_FSRMClassificationPropertyValue\Get-TargetResource' { Context 'Classification Property does not exist' { Mock -CommandName Get-FsrmClassificationPropertyDefinition { throw (New-Object -TypeName Microsoft.PowerShell.Cmdletization.Cim.CimJobException) } @@ -97,7 +103,7 @@ try $null = $getTargetResourceParameters.Remove('Description') $errorRecord = Get-InvalidArgumentRecord ` - -Message ($($LocalizedData.ClassificationPropertyNotFoundError) -f $getTargetResourceParameters.PropertyName) ` + -Message ($($script:localizedData.ClassificationPropertyNotFoundError) -f $getTargetResourceParameters.PropertyName) ` -ArgumentName $getTargetResourceParameters.PropertyName { $result = Get-TargetResource @getTargetResourceParameters } | Should -Throw $errorRecord @@ -143,7 +149,7 @@ try } } - Describe "$($script:DSCResourceName)\Set-TargetResource" { + Describe 'DSC_FSRMClassificationPropertyValue\Set-TargetResource' { Context 'Classification Property does not exist' { Mock -CommandName Get-FsrmClassificationPropertyDefinition -MockWith { throw (New-Object -TypeName Microsoft.PowerShell.Cmdletization.Cim.CimJobException) } Mock -CommandName Set-FsrmClassificationPropertyDefinition @@ -152,7 +158,7 @@ try $setTargetResourceParameters = $script:ClassificationPossibleValue1.Clone() $errorRecord = Get-InvalidArgumentRecord ` - -Message ($($LocalizedData.ClassificationPropertyNotFoundError) -f $setTargetResourceParameters.PropertyName) ` + -Message ($($script:localizedData.ClassificationPropertyNotFoundError) -f $setTargetResourceParameters.PropertyName) ` -ArgumentName $setTargetResourceParameters.PropertyName { Set-TargetResource @setTargetResourceParameters } | Should -Throw $errorRecord @@ -212,7 +218,7 @@ try } } - Describe "$($script:DSCResourceName)\Test-TargetResource" { + Describe 'DSC_FSRMClassificationPropertyValue\Test-TargetResource' { Context 'Classification Property does not exist' { Mock -CommandName Get-FsrmClassificationPropertyDefinition -MockWith { throw (New-Object -TypeName Microsoft.PowerShell.Cmdletization.Cim.CimJobException) } @@ -220,7 +226,7 @@ try $testTargetResourceParameters = $script:ClassificationPossibleValue1.Clone() $errorRecord = Get-InvalidArgumentRecord ` - -Message ($($LocalizedData.ClassificationPropertyNotFoundError) -f $testTargetResourceParameters.PropertyName) ` + -Message ($($script:localizedData.ClassificationPropertyNotFoundError) -f $testTargetResourceParameters.PropertyName) ` -ArgumentName $testTargetResourceParameters.PropertyName { Test-TargetResource @testTargetResourceParameters } | Should -Throw $errorRecord @@ -288,11 +294,8 @@ try } } } - #endregion } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Invoke-TestCleanup } diff --git a/Tests/Unit/DSR_FSRMClassificationRule.Tests.ps1 b/tests/Unit/DSC_FSRMClassificationRule.Tests.ps1 similarity index 95% rename from Tests/Unit/DSR_FSRMClassificationRule.Tests.ps1 rename to tests/Unit/DSC_FSRMClassificationRule.Tests.ps1 index 1ef3fea6..f593c088 100644 --- a/Tests/Unit/DSR_FSRMClassificationRule.Tests.ps1 +++ b/tests/Unit/DSC_FSRMClassificationRule.Tests.ps1 @@ -1,31 +1,37 @@ -$script:DSCModuleName = 'FSRMDsc' -$script:DSCResourceName = 'DSR_FSRMClassificationRule' +$script:dscModuleName = 'FSRMDsc' +$script:dscResourceName = 'DSC_FSRMClassificationRule' -Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global +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' -#region HEADER -# Unit 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'))) ) + Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.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 { - #region Pester Tests - InModuleScope $script:DSCResourceName { - $script:DSCResourceName = 'DSR_FSRMClassificationRule' - + InModuleScope $script:dscResourceName { # Create the Mock -CommandName Objects that will be used for running tests $script:MockClassificationRule = New-CimInstance ` -ClassName 'MSFT_FSRMClassificationRule' ` @@ -64,7 +70,7 @@ try Verbose = $true } - Describe "$($script:DSCResourceName)\Get-TargetResource" { + Describe 'DSC_FSRMClassificationRule\Get-TargetResource' { Context 'No classification rules exist' { Mock -CommandName Get-FSRMClassificationRule @@ -105,7 +111,7 @@ try } } - Describe "$($script:DSCResourceName)\Set-TargetResource" { + Describe 'DSC_FSRMClassificationRule\Set-TargetResource' { Context 'classification rule does not exist but should' { Mock -CommandName Get-FSRMClassificationRule Mock -CommandName New-FSRMClassificationRule @@ -436,7 +442,7 @@ try } } - Describe "$($script:DSCResourceName)\Test-TargetResource" { + Describe 'DSC_FSRMClassificationRule\Test-TargetResource' { Context 'classification rule does not exist but should' { Mock -CommandName Get-FSRMClassificationRule @@ -691,11 +697,8 @@ try } } } - #endregion } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Invoke-TestCleanup } diff --git a/Tests/Unit/DSR_FSRMFileGroup.Tests.ps1 b/tests/Unit/DSC_FSRMFileGroup.Tests.ps1 similarity index 89% rename from Tests/Unit/DSR_FSRMFileGroup.Tests.ps1 rename to tests/Unit/DSC_FSRMFileGroup.Tests.ps1 index fcfa2c15..9e2804ec 100644 --- a/Tests/Unit/DSR_FSRMFileGroup.Tests.ps1 +++ b/tests/Unit/DSC_FSRMFileGroup.Tests.ps1 @@ -1,31 +1,37 @@ -$script:DSCModuleName = 'FSRMDsc' -$script:DSCResourceName = 'DSR_FSRMFileGroup' +$script:dscModuleName = 'FSRMDsc' +$script:dscResourceName = 'DSC_FSRMFileGroup' -Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global +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' -#region HEADER -# Unit 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'))) ) + Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.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 { - #region Pester Tests - InModuleScope $script:DSCResourceName { - $script:DSCResourceName = 'DSR_FSRMFileGroup' - + InModuleScope $script:dscResourceName { # Create the Mock -CommandName Objects that will be used for running tests $script:FileGroup = [PSObject]@{ Name = 'Test Group' @@ -36,7 +42,7 @@ try Verbose = $true } - Describe "$($script:DSCResourceName)\Get-TargetResource" { + Describe 'DSC_FSRMFileGroup\Get-TargetResource' { Context 'No file groups exist' { Mock -CommandName Get-FsrmFileGroup @@ -68,7 +74,7 @@ try } } - Describe "$($script:DSCResourceName)\Set-TargetResource" { + Describe 'DSC_FSRMFileGroup\Set-TargetResource' { Context 'File Group does not exist but should' { Mock -CommandName Get-FsrmFileGroup Mock -CommandName New-FsrmFileGroup @@ -201,7 +207,7 @@ try } } - Describe "$($script:DSCResourceName)\Test-TargetResource" { + Describe 'DSC_FSRMFileGroup\Test-TargetResource' { Context 'File Group does not exist but should' { Mock -CommandName Get-FsrmFileGroup @@ -312,11 +318,8 @@ try } } } - #endregion } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Invoke-TestCleanup } diff --git a/Tests/Unit/DSR_FSRMFileScreen.Tests.ps1 b/tests/Unit/DSC_FSRMFileScreen.Tests.ps1 similarity index 91% rename from Tests/Unit/DSR_FSRMFileScreen.Tests.ps1 rename to tests/Unit/DSC_FSRMFileScreen.Tests.ps1 index becf97d3..e1bcd085 100644 --- a/Tests/Unit/DSR_FSRMFileScreen.Tests.ps1 +++ b/tests/Unit/DSC_FSRMFileScreen.Tests.ps1 @@ -1,32 +1,37 @@ -$script:DSCModuleName = 'FSRMDsc' -$script:DSCResourceName = 'DSR_FSRMFileScreen' +$script:dscModuleName = 'FSRMDsc' +$script:dscResourceName = 'DSC_FSRMFileScreen' -Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global - -#region HEADER -# Unit 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'))) ) +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 { - #region Pester Tests - InModuleScope $script:DSCResourceName { - $script:DSCResourceName = 'DSR_FSRMFileScreen' - + InModuleScope $script:dscResourceName { # Create the Mock -CommandName Objects that will be used for running tests $script:TestFileScreen = [PSObject]@{ Path = $ENV:Temp @@ -51,7 +56,7 @@ try $script:MockFileScreenMatch = $script:MockFileScreen.Clone() $script:MockFileScreenMatch.MatchesTemplate = $true - Describe "$($script:DSCResourceName)\Get-TargetResource" { + Describe 'DSC_FSRMFileScreen\Get-TargetResource' { Context 'No File Screens exist' { Mock -CommandName Get-FsrmFileScreen @@ -85,7 +90,7 @@ try } } - Describe "$($script:DSCResourceName)\Set-TargetResource" { + Describe 'DSC_FSRMFileScreen\Set-TargetResource' { Context 'File Screen does not exist but should' { Mock -CommandName Assert-ResourcePropertiesValid Mock -CommandName Get-FsrmFileScreen @@ -224,7 +229,7 @@ try } } - Describe "$($script:DSCResourceName)\Test-TargetResource" { + Describe 'DSC_FSRMFileScreen\Test-TargetResource' { Context 'File Screen path does not exist' { Mock -CommandName Get-FsrmFileScreenTemplate Mock -CommandName Test-Path -MockWith { $false } @@ -234,7 +239,7 @@ try $errorId = 'FileScreenPathDoesNotExistError' $errorCategory = [System.Management.Automation.ErrorCategory]::InvalidArgument - $errorMessage = $($LocalizedData.FileScreenPathDoesNotExistError) -f $testTargetResourceParameters.Path + $errorMessage = $($script:localizedData.FileScreenPathDoesNotExistError) -f $testTargetResourceParameters.Path $exception = New-Object -TypeName System.InvalidOperationException ` -ArgumentList $errorMessage $errorRecord = New-Object -TypeName System.Management.Automation.ErrorRecord ` @@ -252,7 +257,7 @@ try $errorId = 'FileScreenTemplateNotFoundError' $errorCategory = [System.Management.Automation.ErrorCategory]::InvalidArgument - $errorMessage = $($LocalizedData.FileScreenTemplateNotFoundError) -f $testTargetResourceParameters.Path, $testTargetResourceParameters.Template + $errorMessage = $($script:localizedData.FileScreenTemplateNotFoundError) -f $testTargetResourceParameters.Path, $testTargetResourceParameters.Template $exception = New-Object -TypeName System.InvalidOperationException ` -ArgumentList $errorMessage $errorRecord = New-Object -TypeName System.Management.Automation.ErrorRecord ` @@ -270,7 +275,7 @@ try $errorId = 'FileScreenTemplateEmptyError' $errorCategory = [System.Management.Automation.ErrorCategory]::InvalidArgument - $errorMessage = $($LocalizedData.FileScreenTemplateEmptyError) -f $testTargetResourceParameters.Path + $errorMessage = $($script:localizedData.FileScreenTemplateEmptyError) -f $testTargetResourceParameters.Path $exception = New-Object -TypeName System.InvalidOperationException ` -ArgumentList $errorMessage $errorRecord = New-Object -TypeName System.Management.Automation.ErrorRecord ` @@ -448,11 +453,8 @@ try } } } - #endregion } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Invoke-TestCleanup } diff --git a/Tests/Unit/DSR_FSRMFileScreenAction.Tests.ps1 b/tests/Unit/DSC_FSRMFileScreenAction.Tests.ps1 similarity index 92% rename from Tests/Unit/DSR_FSRMFileScreenAction.Tests.ps1 rename to tests/Unit/DSC_FSRMFileScreenAction.Tests.ps1 index acc41e74..60d2f229 100644 --- a/Tests/Unit/DSR_FSRMFileScreenAction.Tests.ps1 +++ b/tests/Unit/DSC_FSRMFileScreenAction.Tests.ps1 @@ -1,31 +1,37 @@ -$script:DSCModuleName = 'FSRMDsc' -$script:DSCResourceName = 'DSR_FSRMFileScreenAction' +$script:dscModuleName = 'FSRMDsc' +$script:dscResourceName = 'DSC_FSRMFileScreenAction' -Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global +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' -#region HEADER -# Unit 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'))) ) + Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.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 { - #region Pester Tests - InModuleScope $script:DSCResourceName { - $script:DSCResourceName = 'DSR_FSRMFileScreenAction' - + InModuleScope $script:dscResourceName { # Create the Mock -CommandName Objects that will be used for running tests # General purpose Action Mocks $script:MockEmail = New-CimInstance ` @@ -165,7 +171,7 @@ try ReportTypes = $script:MockReport.ReportTypes } - Describe "$($script:DSCResourceName)\Get-TargetResource" { + Describe 'DSC_FSRMFileScreenAction\Get-TargetResource' { Context 'File Screen does not exist' { Mock -CommandName Get-FsrmFileScreen { throw (New-Object -TypeName Microsoft.PowerShell.Cmdletization.Cim.CimJobException) } @@ -173,7 +179,7 @@ try $getTargetResourceParameters = $script:TestFileScreenActionEmail.Clone() $errorRecord = Get-InvalidArgumentRecord ` - -Message ($($LocalizedData.FileScreenNotFoundError) -f $getTargetResourceParameters.Path) ` + -Message ($($script:localizedData.FileScreenNotFoundError) -f $getTargetResourceParameters.Path) ` -ArgumentName 'Path' { $result = Get-TargetResource @getTargetResourceParameters } | Should -Throw $errorRecord @@ -219,7 +225,7 @@ try } } - Describe "$($script:DSCResourceName)\Set-TargetResource" { + Describe 'DSC_FSRMFileScreenAction\Set-TargetResource' { Context 'File Screen does not exist' { Mock -CommandName Get-FsrmFileScreen -MockWith { throw (New-Object -TypeName Microsoft.PowerShell.Cmdletization.Cim.CimJobException) } Mock -CommandName Set-FsrmFileScreen @@ -228,7 +234,7 @@ try $setTargetResourceParameters = $script:TestFileScreenActionEmail.Clone() $errorRecord = Get-InvalidArgumentRecord ` - -Message ($($LocalizedData.FileScreenNotFoundError) -f $setTargetResourceParameters.Path) ` + -Message ($($script:localizedData.FileScreenNotFoundError) -f $setTargetResourceParameters.Path) ` -ArgumentName 'Path' { Set-TargetResource @setTargetResourceParameters } | Should -Throw $errorRecord @@ -287,7 +293,7 @@ try } } - Describe "$($script:DSCResourceName)\Test-TargetResource" { + Describe 'DSC_FSRMFileScreenAction\Test-TargetResource' { Context 'File Screen does not exist' { Mock -CommandName Get-FsrmFileScreen -MockWith { throw (New-Object -TypeName Microsoft.PowerShell.Cmdletization.Cim.CimJobException) } @@ -295,7 +301,7 @@ try $testTargetResourceParameters = $script:TestFileScreenActionEmail.Clone() $errorRecord = Get-InvalidArgumentRecord ` - -Message ($($LocalizedData.FileScreenNotFoundError) -f $testTargetResourceParameters.Path) ` + -Message ($($script:localizedData.FileScreenNotFoundError) -f $testTargetResourceParameters.Path) ` -ArgumentName 'Path' { Test-TargetResource @testTargetResourceParameters } | Should -Throw $errorRecord @@ -529,11 +535,8 @@ try } } } - #endregion } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Invoke-TestCleanup } diff --git a/Tests/Unit/DSR_FSRMFileScreenException.Tests.ps1 b/tests/Unit/DSC_FSRMFileScreenException.Tests.ps1 similarity index 88% rename from Tests/Unit/DSR_FSRMFileScreenException.Tests.ps1 rename to tests/Unit/DSC_FSRMFileScreenException.Tests.ps1 index 61c32b2e..b62af3bc 100644 --- a/Tests/Unit/DSR_FSRMFileScreenException.Tests.ps1 +++ b/tests/Unit/DSC_FSRMFileScreenException.Tests.ps1 @@ -1,31 +1,37 @@ -$script:DSCModuleName = 'FSRMDsc' -$script:DSCResourceName = 'DSR_FSRMFileScreenException' +$script:dscModuleName = 'FSRMDsc' +$script:dscResourceName = 'DSC_FSRMFileScreenException' -Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global +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' -#region HEADER -# Unit 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'))) ) + Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.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 { - #region Pester Tests - InModuleScope $script:DSCResourceName { - $script:DSCResourceName = 'DSR_FSRMFileScreenException' - + InModuleScope $script:dscResourceName { # Create the Mock -CommandName Objects that will be used for running tests $script:TestFileScreenException = [PSObject]@{ Path = $ENV:Temp @@ -41,7 +47,7 @@ try IncludeGroup = $script:TestFileScreenException.IncludeGroup.Clone() } - Describe "$($script:DSCResourceName)\Get-TargetResource" { + Describe 'DSC_FSRMFileScreenException\Get-TargetResource' { Context 'No File Screen Exceptions exist' { Mock -CommandName Get-FsrmFileScreenException @@ -72,7 +78,7 @@ try } } - Describe "$($script:DSCResourceName)\Set-TargetResource" { + Describe 'DSC_FSRMFileScreenException\Set-TargetResource' { Context 'File Screen Exception does not exist but should' { Mock -CommandName Get-FsrmFileScreenException Mock -CommandName New-FsrmFileScreenException @@ -183,7 +189,7 @@ try } } - Describe "$($script:DSCResourceName)\Test-TargetResource" { + Describe 'DSC_FSRMFileScreenException\Test-TargetResource' { Context 'File Screen Exception path does not exist' { Mock -CommandName Get-FsrmFileScreenException Mock -CommandName Test-Path -MockWith { $false } @@ -192,7 +198,7 @@ try $testTargetResourceParameters = $script:TestFileScreenException.Clone() $errorRecord = Get-InvalidArgumentRecord ` - -Message ($($LocalizedData.FileScreenExceptionPathDoesNotExistError) -f $testTargetResourceParameters.Path) ` + -Message ($($script:localizedData.FileScreenExceptionPathDoesNotExistError) -f $testTargetResourceParameters.Path) ` -ArgumentName 'Path' { Test-TargetResource @testTargetResourceParameters } | Should -Throw $errorRecord @@ -293,11 +299,8 @@ try } } } - #endregion } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Invoke-TestCleanup } diff --git a/Tests/Unit/DSR_FSRMFileScreenTemplate.Tests.ps1 b/tests/Unit/DSC_FSRMFileScreenTemplate.Tests.ps1 similarity index 90% rename from Tests/Unit/DSR_FSRMFileScreenTemplate.Tests.ps1 rename to tests/Unit/DSC_FSRMFileScreenTemplate.Tests.ps1 index ebdb9cbc..d6973778 100644 --- a/Tests/Unit/DSR_FSRMFileScreenTemplate.Tests.ps1 +++ b/tests/Unit/DSC_FSRMFileScreenTemplate.Tests.ps1 @@ -1,31 +1,37 @@ -$script:DSCModuleName = 'FSRMDsc' -$script:DSCResourceName = 'DSR_FSRMFileScreenTemplate' +$script:dscModuleName = 'FSRMDsc' +$script:dscResourceName = 'DSC_FSRMFileScreenTemplate' -Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global +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' -#region HEADER -# Unit 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'))) ) + Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.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 { - #region Pester Tests - InModuleScope $script:DSCResourceName { - $script:DSCResourceName = 'DSR_FSRMFileScreenTemplate' - + InModuleScope $script:dscResourceName { # Create the Mock -CommandName Objects that will be used for running tests $script:TestFileScreenTemplate = [PSObject]@{ Name = 'Block Some Files' @@ -43,7 +49,7 @@ try IncludeGroup = $TestFileScreenTemplate.IncludeGroup } - Describe "$($script:DSCResourceName)\Get-TargetResource" { + Describe 'DSC_FSRMFileScreenTemplate\Get-TargetResource' { Context 'No File Screen templates exist' { Mock -CommandName Get-FsrmFileScreenTemplate @@ -75,7 +81,7 @@ try } } - Describe "$($script:DSCResourceName)\Set-TargetResource" { + Describe 'DSC_FSRMFileScreenTemplate\Set-TargetResource' { Context 'File Screen template does not exist but should' { Mock -CommandName Get-FsrmFileScreenTemplate Mock -CommandName New-FsrmFileScreenTemplate @@ -208,7 +214,7 @@ try } } - Describe "$($script:DSCResourceName)\Test-TargetResource" { + Describe 'DSC_FSRMFileScreenTemplate\Test-TargetResource' { Context 'File Screen template does not exist but should' { Mock -CommandName Get-FsrmFileScreenTemplate @@ -318,11 +324,8 @@ try } } } - #endregion } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Invoke-TestCleanup } diff --git a/Tests/Unit/DSR_FSRMFileScreenTemplateAction.Tests.ps1 b/tests/Unit/DSC_FSRMFileScreenTemplateAction.Tests.ps1 similarity index 92% rename from Tests/Unit/DSR_FSRMFileScreenTemplateAction.Tests.ps1 rename to tests/Unit/DSC_FSRMFileScreenTemplateAction.Tests.ps1 index c8ff8681..b0955d65 100644 --- a/Tests/Unit/DSR_FSRMFileScreenTemplateAction.Tests.ps1 +++ b/tests/Unit/DSC_FSRMFileScreenTemplateAction.Tests.ps1 @@ -1,31 +1,37 @@ -$script:DSCModuleName = 'FSRMDsc' -$script:DSCResourceName = 'DSR_FSRMFileScreenTemplateAction' +$script:dscModuleName = 'FSRMDsc' +$script:dscResourceName = 'DSC_FSRMFileScreenTemplateAction' -Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global +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' -#region HEADER -# Unit 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'))) ) + Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.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 { - #region Pester Tests - InModuleScope $script:DSCResourceName { - $script:DSCResourceName = 'DSR_FSRMFileScreenTemplateAction' - + InModuleScope $script:dscResourceName { # Create the Mock -CommandName Objects that will be used for running tests # General purpose Action Mocks $script:MockEmail = New-CimInstance ` @@ -165,7 +171,7 @@ try ReportTypes = $script:MockReport.ReportTypes } - Describe "$($script:DSCResourceName)\Get-TargetResource" { + Describe 'DSC_FSRMFileScreenTemplateAction\Get-TargetResource' { Context 'File Screen template does not exist' { Mock -CommandName Get-FsrmFileScreenTemplate { throw (New-Object -TypeName Microsoft.PowerShell.Cmdletization.Cim.CimJobException) } @@ -173,7 +179,7 @@ try $getTargetResourceParameters = $script:TestFileScreenTemplateActionEmail.Clone() $errorRecord = Get-InvalidArgumentRecord ` - -Message ($($LocalizedData.FileScreenTemplateNotFoundError) -f $getTargetResourceParameters.Name, $getTargetResourceParameters.Type) ` + -Message ($($script:localizedData.FileScreenTemplateNotFoundError) -f $getTargetResourceParameters.Name, $getTargetResourceParameters.Type) ` -ArgumentName 'Name' { $result = Get-TargetResource @getTargetResourceParameters } | Should -Throw $errorRecord @@ -219,7 +225,7 @@ try } } - Describe "$($script:DSCResourceName)\Set-TargetResource" { + Describe 'DSC_FSRMFileScreenTemplateAction\Set-TargetResource' { Context 'File Screen template does not exist' { Mock -CommandName Get-FsrmFileScreenTemplate -MockWith { throw (New-Object -TypeName Microsoft.PowerShell.Cmdletization.Cim.CimJobException) } Mock -CommandName Set-FsrmFileScreenTemplate @@ -228,7 +234,7 @@ try $setTargetResourceParameters = $script:TestFileScreenTemplateActionEmail.Clone() $errorRecord = Get-InvalidArgumentRecord ` - -Message ($($LocalizedData.FileScreenTemplateNotFoundError) -f $setTargetResourceParameters.Name, $setTargetResourceParameters.Type) ` + -Message ($($script:localizedData.FileScreenTemplateNotFoundError) -f $setTargetResourceParameters.Name, $setTargetResourceParameters.Type) ` -ArgumentName 'Name' { Set-TargetResource @setTargetResourceParameters } | Should -Throw $errorRecord @@ -288,7 +294,7 @@ try } } - Describe "$($script:DSCResourceName)\Test-TargetResource" { + Describe 'DSC_FSRMFileScreenTemplateAction\Test-TargetResource' { Context 'File Screen template does not exist' { Mock -CommandName Get-FsrmFileScreenTemplate -MockWith { throw (New-Object -TypeName Microsoft.PowerShell.Cmdletization.Cim.CimJobException) } @@ -296,7 +302,7 @@ try $testTargetResourceParameters = $script:TestFileScreenTemplateActionEmail.Clone() $errorRecord = Get-InvalidArgumentRecord ` - -Message ($($LocalizedData.FileScreenTemplateNotFoundError) -f $testTargetResourceParameters.Name, $testTargetResourceParameters.Type) ` + -Message ($($script:localizedData.FileScreenTemplateNotFoundError) -f $testTargetResourceParameters.Name, $testTargetResourceParameters.Type) ` -ArgumentName 'Name' { Test-TargetResource @testTargetResourceParameters } | Should -Throw $errorRecord @@ -531,11 +537,8 @@ try } } } - #endregion } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Invoke-TestCleanup } diff --git a/Tests/Unit/DSR_FSRMQuota.Tests.ps1 b/tests/Unit/DSC_FSRMQuota.Tests.ps1 similarity index 92% rename from Tests/Unit/DSR_FSRMQuota.Tests.ps1 rename to tests/Unit/DSC_FSRMQuota.Tests.ps1 index dd7d19f6..ee787453 100644 --- a/Tests/Unit/DSR_FSRMQuota.Tests.ps1 +++ b/tests/Unit/DSC_FSRMQuota.Tests.ps1 @@ -1,31 +1,37 @@ -$script:DSCModuleName = 'FSRMDsc' -$script:DSCResourceName = 'DSR_FSRMQuota' +$script:dscModuleName = 'FSRMDsc' +$script:dscResourceName = 'DSC_FSRMQuota' -Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global +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' -#region HEADER -# Unit 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'))) ) + Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.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 { - #region Pester Tests - InModuleScope $script:DSCResourceName { - $script:DSCResourceName = 'DSR_FSRMQuota' - + InModuleScope $script:dscResourceName { # Create the Mock -CommandName Objects that will be used for running tests $script:TestQuota = [PSObject]@{ Path = $ENV:Temp @@ -72,7 +78,7 @@ try $script:MockQuotaMatch = $script:MockQuota.Clone() $script:MockQuotaMatch.MatchesTemplate = $true - Describe "$($script:DSCResourceName)\Get-TargetResource" { + Describe 'DSC_FSRMQuota\Get-TargetResource' { Context 'No quotas exist' { Mock -CommandName Get-FsrmQuota @@ -106,7 +112,7 @@ try } } - Describe "$($script:DSCResourceName)\Set-TargetResource" { + Describe 'DSC_FSRMQuota\Set-TargetResource' { Context 'quota does not exist but should' { Mock -CommandName Assert-ResourcePropertiesValid Mock -CommandName Get-FsrmQuota @@ -291,7 +297,7 @@ try } } - Describe "$($script:DSCResourceName)\Test-TargetResource" { + Describe 'DSC_FSRMQuota\Test-TargetResource' { Context 'quota path does not exist' { Mock -CommandName Get-FsrmQuotaTemplate Mock -CommandName Test-Path -MockWith { $false } @@ -300,7 +306,7 @@ try $testTargetResourceParameters = $script:TestQuota.Clone() $errorRecord = Get-InvalidArgumentRecord ` - -Message ($($LocalizedData.QuotaPathDoesNotExistError) -f $testTargetResourceParameters.Path) ` + -Message ($($script:localizedData.QuotaPathDoesNotExistError) -f $testTargetResourceParameters.Path) ` -ArgumentName 'Path' { Test-TargetResource @testTargetResourceParameters } | Should -Throw $errorRecord @@ -314,7 +320,7 @@ try $testTargetResourceParameters = $script:TestQuota.Clone() $errorRecord = Get-InvalidArgumentRecord ` - -Message ($($LocalizedData.QuotaTemplateNotFoundError) -f $testTargetResourceParameters.Path, $testTargetResourceParameters.Template) ` + -Message ($($script:localizedData.QuotaTemplateNotFoundError) -f $testTargetResourceParameters.Path, $testTargetResourceParameters.Template) ` -ArgumentName 'Path' { Test-TargetResource @testTargetResourceParameters } | Should -Throw $errorRecord @@ -328,7 +334,7 @@ try $testTargetResourceParameters.Template = '' $errorRecord = Get-InvalidArgumentRecord ` - -Message ($($LocalizedData.QuotaTemplateEmptyError) -f $testTargetResourceParameters.Path) ` + -Message ($($script:localizedData.QuotaTemplateEmptyError) -f $testTargetResourceParameters.Path) ` -ArgumentName 'Path' { Test-TargetResource @testTargetResourceParameters } | Should -Throw $errorRecord @@ -554,11 +560,8 @@ try } } } - #endregion } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Invoke-TestCleanup } diff --git a/Tests/Unit/DSR_FSRMQuotaAction.Tests.ps1 b/tests/Unit/DSC_FSRMQuotaAction.Tests.ps1 similarity index 90% rename from Tests/Unit/DSR_FSRMQuotaAction.Tests.ps1 rename to tests/Unit/DSC_FSRMQuotaAction.Tests.ps1 index 365bf3ff..3a467662 100644 --- a/Tests/Unit/DSR_FSRMQuotaAction.Tests.ps1 +++ b/tests/Unit/DSC_FSRMQuotaAction.Tests.ps1 @@ -1,31 +1,37 @@ -$script:DSCModuleName = 'FSRMDsc' -$script:DSCResourceName = 'DSR_FSRMQuotaAction' +$script:dscModuleName = 'FSRMDsc' +$script:dscResourceName = 'DSC_FSRMQuotaAction' -Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global +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' -#region HEADER -# Unit 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'))) ) + Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.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 { - #region Pester Tests - InModuleScope $script:DSCResourceName { - $script:DSCResourceName = 'DSR_FSRMQuotaAction' - + InModuleScope $script:dscResourceName { # Create the Mock -CommandName Objects that will be used for running tests # General purpose Action Mocks $script:MockEmail = New-CimInstance ` @@ -179,7 +185,7 @@ try ReportTypes = $script:MockReport.ReportTypes } - Describe "$($script:DSCResourceName)\Get-TargetResource" { + Describe 'DSC_FSRMQuotaAction\Get-TargetResource' { Context 'Quota does not exist' { Mock -CommandName Get-FsrmQuota { throw (New-Object -TypeName Microsoft.PowerShell.Cmdletization.Cim.CimJobException) } @@ -187,7 +193,7 @@ try $getTargetResourceParameters = $script:TestQuotaActionEmail.Clone() $errorRecord = Get-InvalidArgumentRecord ` - -Message ($($LocalizedData.QuotaNotFoundError) -f $getTargetResourceParameters.Path, $getTargetResourceParameters.Percentage, $getTargetResourceParameters.Type) ` + -Message ($($script:localizedData.QuotaNotFoundError) -f $getTargetResourceParameters.Path, $getTargetResourceParameters.Percentage, $getTargetResourceParameters.Type) ` -ArgumentName 'Path' { $result = Get-TargetResource @getTargetResourceParameters } | Should -Throw $errorRecord @@ -206,7 +212,7 @@ try $getTargetResourceParameters.Percentage = 99 $errorRecord = Get-InvalidArgumentRecord ` - -Message ($($LocalizedData.QuotaThresholdNotFoundError) -f $getTargetResourceParameters.Path, $getTargetResourceParameters.Percentage, $getTargetResourceParameters.Type) ` + -Message ($($script:localizedData.QuotaThresholdNotFoundError) -f $getTargetResourceParameters.Path, $getTargetResourceParameters.Percentage, $getTargetResourceParameters.Type) ` -ArgumentName 'Path' { $result = Get-TargetResource @getTargetResourceParameters } | Should -Throw $errorRecord @@ -252,7 +258,7 @@ try } } - Describe "$($script:DSCResourceName)\Set-TargetResource" { + Describe 'DSC_FSRMQuotaAction\Set-TargetResource' { Context 'Quota does not exist' { Mock -CommandName Get-FsrmQuota -MockWith { throw (New-Object -TypeName Microsoft.PowerShell.Cmdletization.Cim.CimJobException) } Mock -CommandName Set-FsrmQuota @@ -261,7 +267,7 @@ try $setTargetResourceParameters = $script:TestQuotaActionEmail.Clone() $errorRecord = Get-InvalidArgumentRecord ` - -Message ($($LocalizedData.QuotaNotFoundError) -f $setTargetResourceParameters.Path, $setTargetResourceParameters.Percentage, $setTargetResourceParameters.Type) ` + -Message ($($script:localizedData.QuotaNotFoundError) -f $setTargetResourceParameters.Path, $setTargetResourceParameters.Percentage, $setTargetResourceParameters.Type) ` -ArgumentName 'Path' { Set-TargetResource @setTargetResourceParameters } | Should -Throw $errorRecord @@ -282,7 +288,7 @@ try $setTargetResourceParameters.Percentage = 99 $errorRecord = Get-InvalidArgumentRecord ` - -Message ($($LocalizedData.QuotaThresholdNotFoundError) -f $setTargetResourceParameters.Path, $setTargetResourceParameters.Percentage, $setTargetResourceParameters.Type) ` + -Message ($($script:localizedData.QuotaThresholdNotFoundError) -f $setTargetResourceParameters.Path, $setTargetResourceParameters.Percentage, $setTargetResourceParameters.Type) ` -ArgumentName 'Path' { Set-TargetResource @setTargetResourceParameters } | Should -Throw $errorRecord @@ -342,7 +348,7 @@ try } } - Describe "$($script:DSCResourceName)\Test-TargetResource" { + Describe 'DSC_FSRMQuotaAction\Test-TargetResource' { Context 'Quota does not exist' { Mock -CommandName Get-FsrmQuota -MockWith { throw (New-Object -TypeName Microsoft.PowerShell.Cmdletization.Cim.CimJobException) } @@ -350,7 +356,7 @@ try $testTargetResourceParameters = $script:TestQuotaActionEmail.Clone() $errorRecord = Get-InvalidArgumentRecord ` - -Message ($($LocalizedData.QuotaNotFoundError) -f $testTargetResourceParameters.Path, $testTargetResourceParameters.Percentage, $testTargetResourceParameters.Type) ` + -Message ($($script:localizedData.QuotaNotFoundError) -f $testTargetResourceParameters.Path, $testTargetResourceParameters.Percentage, $testTargetResourceParameters.Type) ` -ArgumentName 'Path' { Test-TargetResource @testTargetResourceParameters } | Should -Throw $errorRecord @@ -369,7 +375,7 @@ try $testTargetResourceParameters.Percentage = 99 $errorRecord = Get-InvalidArgumentRecord ` - -Message ($($LocalizedData.QuotaThresholdNotFoundError) -f $testTargetResourceParameters.Path, $testTargetResourceParameters.Percentage, $testTargetResourceParameters.Type) ` + -Message ($($script:localizedData.QuotaThresholdNotFoundError) -f $testTargetResourceParameters.Path, $testTargetResourceParameters.Percentage, $testTargetResourceParameters.Type) ` -ArgumentName 'Path' { Test-TargetResource @testTargetResourceParameters } | Should -Throw $errorRecord @@ -604,11 +610,8 @@ try } } } - #endregion } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Invoke-TestCleanup } diff --git a/Tests/Unit/DSR_FSRMQuotaTemplate.Tests.ps1 b/tests/Unit/DSC_FSRMQuotaTemplate.Tests.ps1 similarity index 92% rename from Tests/Unit/DSR_FSRMQuotaTemplate.Tests.ps1 rename to tests/Unit/DSC_FSRMQuotaTemplate.Tests.ps1 index 100a7caf..c0d8708a 100644 --- a/Tests/Unit/DSR_FSRMQuotaTemplate.Tests.ps1 +++ b/tests/Unit/DSC_FSRMQuotaTemplate.Tests.ps1 @@ -1,31 +1,37 @@ -$script:DSCModuleName = 'FSRMDsc' -$script:DSCResourceName = 'DSR_FSRMQuotaTemplate' +$script:dscModuleName = 'FSRMDsc' +$script:dscResourceName = 'DSC_FSRMQuotaTemplate' -Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global +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' -#region HEADER -# Unit 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'))) ) + Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.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 { - #region Pester Tests - InModuleScope $script:DSCResourceName { - $script:DSCResourceName = 'DSR_FSRMQuotaTemplate' - + InModuleScope $script:dscResourceName { # Create the Mock -CommandName Objects that will be used for running tests $script:TestQuotaTemplate = [PSObject]@{ Name = '5 GB Limit' @@ -63,7 +69,7 @@ try ) } - Describe "$($script:DSCResourceName)\Get-TargetResource" { + Describe 'DSC_FSRMQuotaTemplate\Get-TargetResource' { Context 'No quota templates exist' { Mock -CommandName Get-FsrmQuotaTemplate @@ -94,7 +100,7 @@ try } } - Describe "$($script:DSCResourceName)\Set-TargetResource" { + Describe 'DSC_FSRMQuotaTemplate\Set-TargetResource' { Context 'Quota template does not exist but should' { Mock -CommandName Get-FsrmQuotaTemplate Mock -CommandName New-FsrmQuotaTemplate @@ -271,7 +277,7 @@ try } } - Describe "$($script:DSCResourceName)\Test-TargetResource" { + Describe 'DSC_FSRMQuotaTemplate\Test-TargetResource' { Context 'Quota template does not exist but should' { Mock -CommandName Get-FsrmQuotaTemplate @@ -414,11 +420,8 @@ try } } } - #endregion } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Invoke-TestCleanup } diff --git a/Tests/Unit/DSR_FSRMQuotaTemplateAction.Tests.ps1 b/tests/Unit/DSC_FSRMQuotaTemplateAction.Tests.ps1 similarity index 90% rename from Tests/Unit/DSR_FSRMQuotaTemplateAction.Tests.ps1 rename to tests/Unit/DSC_FSRMQuotaTemplateAction.Tests.ps1 index 92741944..58d526b2 100644 --- a/Tests/Unit/DSR_FSRMQuotaTemplateAction.Tests.ps1 +++ b/tests/Unit/DSC_FSRMQuotaTemplateAction.Tests.ps1 @@ -1,31 +1,37 @@ -$script:DSCModuleName = 'FSRMDsc' -$script:DSCResourceName = 'DSR_FSRMQuotaTemplateAction' +$script:dscModuleName = 'FSRMDsc' +$script:dscResourceName = 'DSC_FSRMQuotaTemplateAction' -Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global +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' -#region HEADER -# Unit 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'))) ) + Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.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 { - #region Pester Tests - InModuleScope $script:DSCResourceName { - $script:DSCResourceName = 'DSR_FSRMQuotaTemplateAction' - + InModuleScope $script:dscResourceName { # Create the Mock -CommandName Objects that will be used for running tests # General purpose Action Mocks $script:MockEmail = New-CimInstance ` @@ -177,7 +183,7 @@ try ReportTypes = $script:MockReport.ReportTypes } - Describe "$($script:DSCResourceName)\Get-TargetResource" { + Describe 'DSC_FSRMQuotaTemplateAction\Get-TargetResource' { Context 'Quota template does not exist' { Mock -CommandName Get-FsrmQuotaTemplate { throw (New-Object -TypeName Microsoft.PowerShell.Cmdletization.Cim.CimJobException) } @@ -185,7 +191,7 @@ try $getTargetResourceParameters = $script:TestQuotaTemplateActionEmail.Clone() $errorRecord = Get-InvalidArgumentRecord ` - -Message ($($LocalizedData.QuotaTemplateNotFoundError) -f $getTargetResourceParameters.Name, $getTargetResourceParameters.Percentage, $getTargetResourceParameters.Type) ` + -Message ($($script:localizedData.QuotaTemplateNotFoundError) -f $getTargetResourceParameters.Name, $getTargetResourceParameters.Percentage, $getTargetResourceParameters.Type) ` -ArgumentName 'Name' { $result = Get-TargetResource @getTargetResourceParameters } | Should -Throw $errorRecord @@ -204,7 +210,7 @@ try $getTargetResourceParameters.Percentage = 99 $errorRecord = Get-InvalidArgumentRecord ` - -Message ($($LocalizedData.QuotaTemplateThresholdNotFoundError) -f $getTargetResourceParameters.Name, $getTargetResourceParameters.Percentage, $getTargetResourceParameters.Type) ` + -Message ($($script:localizedData.QuotaTemplateThresholdNotFoundError) -f $getTargetResourceParameters.Name, $getTargetResourceParameters.Percentage, $getTargetResourceParameters.Type) ` -ArgumentName 'Name' { $result = Get-TargetResource @getTargetResourceParameters } | Should -Throw $errorRecord @@ -250,7 +256,7 @@ try } } - Describe "$($script:DSCResourceName)\Set-TargetResource" { + Describe 'DSC_FSRMQuotaTemplateAction\Set-TargetResource' { Context 'Quota template does not exist' { Mock -CommandName Get-FsrmQuotaTemplate -MockWith { throw (New-Object -TypeName Microsoft.PowerShell.Cmdletization.Cim.CimJobException) } Mock -CommandName Set-FsrmQuotaTemplate @@ -259,7 +265,7 @@ try $setTargetResourceParameters = $script:TestQuotaTemplateActionEmail.Clone() $errorRecord = Get-InvalidArgumentRecord ` - -Message ($($LocalizedData.QuotaTemplateNotFoundError) -f $setTargetResourceParameters.Name, $setTargetResourceParameters.Percentage, $setTargetResourceParameters.Type) ` + -Message ($($script:localizedData.QuotaTemplateNotFoundError) -f $setTargetResourceParameters.Name, $setTargetResourceParameters.Percentage, $setTargetResourceParameters.Type) ` -ArgumentName 'Name' { Set-TargetResource @setTargetResourceParameters } | Should -Throw $errorRecord @@ -280,7 +286,7 @@ try $setTargetResourceParameters.Percentage = 99 $errorRecord = Get-InvalidArgumentRecord ` - -Message ($($LocalizedData.QuotaTemplateThresholdNotFoundError) -f $setTargetResourceParameters.Name, $setTargetResourceParameters.Percentage, $setTargetResourceParameters.Type) ` + -Message ($($script:localizedData.QuotaTemplateThresholdNotFoundError) -f $setTargetResourceParameters.Name, $setTargetResourceParameters.Percentage, $setTargetResourceParameters.Type) ` -ArgumentName 'Name' { Set-TargetResource @setTargetResourceParameters } | Should -Throw $errorRecord @@ -340,7 +346,7 @@ try } } - Describe "$($script:DSCResourceName)\Test-TargetResource" { + Describe 'DSC_FSRMQuotaTemplateAction\Test-TargetResource' { Context 'Quota template does not exist' { Mock -CommandName Get-FsrmQuotaTemplate -MockWith { throw (New-Object -TypeName Microsoft.PowerShell.Cmdletization.Cim.CimJobException) } @@ -348,7 +354,7 @@ try $testTargetResourceParameters = $script:TestQuotaTemplateActionEmail.Clone() $errorRecord = Get-InvalidArgumentRecord ` - -Message ($($LocalizedData.QuotaTemplateNotFoundError) -f $testTargetResourceParameters.Name, $testTargetResourceParameters.Percentage, $testTargetResourceParameters.Type) ` + -Message ($($script:localizedData.QuotaTemplateNotFoundError) -f $testTargetResourceParameters.Name, $testTargetResourceParameters.Percentage, $testTargetResourceParameters.Type) ` -ArgumentName 'Name' { Test-TargetResource @testTargetResourceParameters } | Should -Throw $errorRecord @@ -367,7 +373,7 @@ try $testTargetResourceParameters.Percentage = 99 $errorRecord = Get-InvalidArgumentRecord ` - -Message ($($LocalizedData.QuotaTemplateThresholdNotFoundError) -f $testTargetResourceParameters.Name, $testTargetResourceParameters.Percentage, $testTargetResourceParameters.Type) ` + -Message ($($script:localizedData.QuotaTemplateThresholdNotFoundError) -f $testTargetResourceParameters.Name, $testTargetResourceParameters.Percentage, $testTargetResourceParameters.Type) ` -ArgumentName 'Name' { Test-TargetResource @testTargetResourceParameters } | Should -Throw $errorRecord @@ -602,11 +608,8 @@ try } } } - #endregion } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Invoke-TestCleanup } diff --git a/Tests/Unit/DSR_FSRMSettings.Tests.ps1 b/tests/Unit/DSC_FSRMSettings.Tests.ps1 similarity index 88% rename from Tests/Unit/DSR_FSRMSettings.Tests.ps1 rename to tests/Unit/DSC_FSRMSettings.Tests.ps1 index 4c5454a1..bc79ce11 100644 --- a/Tests/Unit/DSR_FSRMSettings.Tests.ps1 +++ b/tests/Unit/DSC_FSRMSettings.Tests.ps1 @@ -1,31 +1,37 @@ -$script:DSCModuleName = 'FSRMDsc' -$script:DSCResourceName = 'DSR_FSRMSettings' +$script:dscModuleName = 'FSRMDsc' +$script:dscResourceName = 'DSC_FSRMSettings' -Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global +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' -#region HEADER -# Unit 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'))) ) + Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.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 { - #region Pester Tests - InModuleScope $script:DSCResourceName { - $script:DSCResourceName = 'DSR_FSRMSettings' - + InModuleScope $script:dscResourceName { # Create the Mock -CommandName Objects that will be used for running tests $script:Settings = [PSObject] @{ IsSingleInstance = 'Yes' @@ -51,7 +57,7 @@ try EventNotificationLimit = $script:Settings.EventNotificationLimit } - Describe "$($script:DSCResourceName)\Get-TargetResource" { + Describe 'DSC_FSRMSettings\Get-TargetResource' { Context 'Settings Exist' { Mock -CommandName Get-FSRMSetting -MockWith { $script:MockSettings } @@ -71,7 +77,7 @@ try } } - Describe "$($script:DSCResourceName)\Set-TargetResource" { + Describe 'DSC_FSRMSettings\Set-TargetResource' { Context 'Settings has a different SmtpServer property' { Mock -CommandName Set-FSRMSetting @@ -167,7 +173,7 @@ try } } - Describe "$($script:DSCResourceName)\Test-TargetResource" { + Describe 'DSC_FSRMSettings\Test-TargetResource' { Context 'Settings has no property differences' { Mock -CommandName Get-FSRMSetting -MockWith { $script:MockSettings } @@ -266,11 +272,8 @@ try } } } - #endregion } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Invoke-TestCleanup }