Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean xWindowsFeatureSet, xWindowsOptionalFeatureSet, and xProcessSet and add tests #297

Merged
merged 4 commits into from
Dec 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ function Get-TargetResource
#>
function Set-TargetResource
{
[CmdletBinding(SupportsShouldProcess = $true)]
[CmdletBinding()]
param
(
[Parameter(Mandatory = $true)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ function Set-TargetResource

Assert-ResourcePrerequisitesValid

switch ($LogLevel)
$dismLogLevel = switch ($LogLevel)
{
'ErrorsOnly' { $dismLogLevel = 'Errors' }
'ErrorsAndWarning' { $dismLogLevel = 'Warnings' }
'ErrorsAndWarningAndInformation' { $dismLogLevel = 'WarningsInfo' }
'ErrorsOnly' { 'Errors'; break }
'ErrorsAndWarning' { 'Warnings'; break }
'ErrorsAndWarningAndInformation' { 'WarningsInfo'; break }
}

# Construct splatting hashtable for DISM cmdlets
Expand Down
88 changes: 2 additions & 86 deletions DSCResources/xProcessSet/xProcessSet.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -19,93 +19,9 @@ CompanyName = 'Microsoft Corporation'
Copyright = '(c) 2016 Microsoft. All rights reserved.'

# Description of the functionality provided by this module
Description = 'Allows starting and stopping of a group of windows processes with no arguments.'
Description = 'Provides a mechanism to configure and manage multiple xWindowsProcess resources on a target node.'

# Minimum version of the Windows PowerShell engine required by this module
# PowerShellVersion = ''

# 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 = ''

# Processor architecture (None, X86, Amd64) required by this module
# ProcessorArchitecture = ''

# 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 = '*'

# 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 = @()

# A URL to the license for this module.
# LicenseUri = ''

# A URL to the main website for this project.
# ProjectUri = ''

# A URL to an icon representing this module.
# IconUri = ''

# ReleaseNotes of this module
# ReleaseNotes = ''

} # 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 = ''
PowerShellVersion = '4.0'

}
59 changes: 52 additions & 7 deletions DSCResources/xProcessSet/xProcessSet.schema.psm1
Original file line number Diff line number Diff line change
@@ -1,8 +1,48 @@
Set-StrictMode -Version 'latest'
$errorActionPreference = 'stop'
$errorActionPreference = 'Stop'
Set-StrictMode -Version 'Latest'

Import-Module -Name (Join-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -ChildPath 'ResourceSetHelper.psm1')
# Import ResourceSetHelper for New-ResourceSetConfigurationScriptBlock
$script:dscResourcesFolderFilePath = Split-Path -Path $PSScriptRoot -Parent
$script:resourceSetHelperFilePath = Join-Path -Path $script:dscResourcesFolderFilePath -ChildPath 'ResourceSetHelper.psm1'
Import-Module -Name $script:resourceSetHelperFilePath

<#
.SYNOPSIS
A composite DSC resource to configure a set of similar xWindowsProcess resources.
No arguments can be passed into these xWindowsProcess resources.

.PARAMETER Path
The file paths to the executables of the processes to start or stop. Only the names of the
files may be specified if they are all accessible through the environment path. Relative
paths are not supported.

.PARAMETER Ensure
Specifies whether or not the processes should exist.

To start processes, set this property to Present.
To stop processes, set this property to Absent.

.PARAMETER Credential
The credential of the user account to start the processes under.

.PARAMETER StandardOutputPath
The file path to write the standard output to. Any existing file at this path
will be overwritten.This property cannot be specified at the same time as Credential
when running the processes as a local user.

.PARAMETER StandardErrorPath
The file path to write the standard error output to. Any existing file at this path
will be overwritten.

.PARAMETER StandardInputPath
The file path to get standard input from. This property cannot be specified at the
same time as Credential when running the processes as a local user.

.PARAMETER WorkingDirectory
The file path to use as the working directory for the processes. Any existing file
at this path will be overwritten. This property cannot be specified at the same time
as Credential when running the processes as a local user.
#>
Configuration xProcessSet
{
[CmdletBinding()]
Expand All @@ -13,23 +53,28 @@ Configuration xProcessSet
[String[]]
$Path,

[ValidateNotNullOrEmpty()]
[System.Management.Automation.PSCredential]
$Credential,

[ValidateSet('Present', 'Absent')]
[String]
$Ensure,

[ValidateNotNullOrEmpty()]
[System.Management.Automation.PSCredential]
[System.Management.Automation.Credential()]
$Credential,

[ValidateNotNullOrEmpty()]
[String]
$StandardOutputPath,

[ValidateNotNullOrEmpty()]
[String]
$StandardErrorPath,

[ValidateNotNullOrEmpty()]
[String]
$StandardInputPath,

[ValidateNotNullOrEmpty()]
[String]
$WorkingDirectory
)
Expand Down
88 changes: 2 additions & 86 deletions DSCResources/xWindowsFeatureSet/xWindowsFeatureSet.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -19,93 +19,9 @@ CompanyName = 'Microsoft Corporation'
Copyright = '(c) 2016 Microsoft. All rights reserved.'

# Description of the functionality provided by this module
Description = 'Allows installation and uninstallation of a group of windows features and their subfeatures.'
Description = 'Provides a mechanism to configure and manage multiple xWindowsFeature resources on a target node.'

# Minimum version of the Windows PowerShell engine required by this module
# PowerShellVersion = ''

# 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 = ''

# Processor architecture (None, X86, Amd64) required by this module
# ProcessorArchitecture = ''

# 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 = '*'

# 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 = @()

# A URL to the license for this module.
# LicenseUri = ''

# A URL to the main website for this project.
# ProjectUri = ''

# A URL to an icon representing this module.
# IconUri = ''

# ReleaseNotes of this module
# ReleaseNotes = ''

} # 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 = ''
PowerShellVersion = '4.0'

}
37 changes: 34 additions & 3 deletions DSCResources/xWindowsFeatureSet/xWindowsFeatureSet.schema.psm1
Original file line number Diff line number Diff line change
@@ -1,8 +1,38 @@
Set-StrictMode -Version 'latest'
$errorActionPreference = 'stop'
$errorActionPreference = 'Stop'
Set-StrictMode -Version 'Latest'

Import-Module -Name (Join-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -ChildPath 'ResourceSetHelper.psm1')
# Import ResourceSetHelper for New-ResourceSetConfigurationScriptBlock
$script:dscResourcesFolderFilePath = Split-Path -Path $PSScriptRoot -Parent
$script:resourceSetHelperFilePath = Join-Path -Path $script:dscResourcesFolderFilePath -ChildPath 'ResourceSetHelper.psm1'
Import-Module -Name $script:resourceSetHelperFilePath

<#
.SYNOPSIS
A composite DSC resource to configure a set of similar xWindowsFeature resources.

.PARAMETER Name
The name of the roles or features to install or uninstall.

.PARAMETER Ensure
Specifies whether the roles or features should be installed or uninstalled.

To install the features, set this property to Present.
To uninstall the features, set this property to Absent.

.PARAMETER IncludeAllSubFeature
Specifies whether or not all subfeatures should be installed or uninstalled alongside the specified roles or features.

If this property is true and Ensure is set to Present, all subfeatures will be installed.
If this property is false and Ensure is set to Present, subfeatures will not be installed or uninstalled.
If Ensure is set to Absent, all subfeatures will be uninstalled.

.PARAMETER Credential
The credential of the user account under which to install or uninstall the roles or features.

.PARAMETER LogPath
The custom file path to which to log this operation.
If not passed in, the default log path will be used (%windir%\logs\ServerManager.log).
#>
Configuration xWindowsFeatureSet
{
[CmdletBinding()]
Expand All @@ -26,6 +56,7 @@ Configuration xWindowsFeatureSet

[ValidateNotNull()]
[System.Management.Automation.PSCredential]
[System.Management.Automation.Credential()]
$Credential,

[ValidateNotNullOrEmpty()]
Expand Down
Loading