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

Release of version 3.7.0.0 of xPSDesiredStateConfiguration #64

Merged
merged 27 commits into from
Feb 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a812c70
Replacing before_deploy with deploy_script
KarolKaczmarek Dec 8, 2015
a3c43fc
Adds support for Server 2012R2 and later where WindowsOptionalFeature…
iainbrighton Dec 13, 2015
9b67a54
xService Dependencies bugfix
davidstrahm Dec 15, 2015
a86b5e4
Temporary workaround for pester issue causing build to get stuck
KarolKaczmarek Dec 16, 2015
ee8dcb8
Fixing typo in the message
Jan 6, 2016
0ff8287
Merge pull request #59 from BrucePay/patch-1
KarolKaczmarek Jan 6, 2016
5989a1c
Merge pull request #55 from davidstrahm/xServiceDependenciesFix
KarolKaczmarek Jan 6, 2016
afa6468
Adding xRegistry resource
dlwyatt Jan 6, 2016
14e58e4
Whitespace cleanup
dlwyatt Jan 6, 2016
899a2da
Making Test-xDscResource pass
dlwyatt Jan 6, 2016
fd8e398
Whitespace cleanup in strings.psd1 file
dlwyatt Jan 6, 2016
043b7f2
Adding tests and README update
dlwyatt Jan 7, 2016
2fae38c
Triggering AppVeyor build
dlwyatt Jan 7, 2016
556f74f
Merge pull request #58 from dlwyatt/xRegistry
KarolKaczmarek Jan 7, 2016
6515e1e
Reverting temporary workaround for chocolatey issue
KarolKaczmarek Jan 7, 2016
37ebb20
Merge branch 'dev' of https://github.com/powershell/xpsdesiredstateco…
iainbrighton Jan 13, 2016
2c43d36
Fixes bug where Test-TargetResource always returns false
iainbrighton Jan 14, 2016
e47ea03
Adds Pester test coverage
iainbrighton Jan 14, 2016
ec88971
Updates readme.md and test build numbers
iainbrighton Jan 14, 2016
cfc6f03
Clarifies Server 2012 (and later) SKU requirement
iainbrighton Jan 15, 2016
51aef89
Implements DscResource. test template for MSFT_xWindowsOptionalFeature
iainbrighton Jan 19, 2016
4ddbce5
Merge pull request #61 from iainbrighton/Issue42
TravisEz13 Jan 19, 2016
4857fe7
Fix verbose message
TravisEz13 Jan 27, 2016
98ad39a
Merge pull request #63 from PowerShell/TravisEz13-patch-1
KarolKaczmarek Jan 27, 2016
4a5a370
Update xPSDesiredStateConfiguration.psd1
KarolKaczmarek Feb 2, 2016
b87f950
Update README.md
KarolKaczmarek Feb 2, 2016
926390d
Releasing version 3.7.0.0
KarolKaczmarek Feb 2, 2016
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
1,132 changes: 1,132 additions & 0 deletions DSCResources/MSFT_xRegistryResource/MSFT_xRegistryResource.psm1

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[ClassVersion("1.0.0"), FriendlyName("xRegistry")]
class MSFT_xRegistryResource : OMI_BaseResource
{
[Key] string Key;
[Key] string ValueName;
[Write] string ValueData[];
[Write,ValueMap{"String", "Binary", "Dword", "Qword", "MultiString", "ExpandString"},Values{"String", "Binary", "Dword", "Qword", "MultiString", "ExpandString"}] string ValueType;
[Write,ValueMap{"Present", "Absent"},Values{"Present", "Absent"}] string Ensure;
[Write] boolean Hex;
[Write] boolean Force;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma namespace("\\\\.\\root\\default")
instance of __namespace{ name="MS_409";};
#pragma namespace("\\\\.\\root\\default\\MS_409")

[Description("This resource is used to perform Get, Set and Test operations on Windows Registry.") : Amended,AMENDMENT, LOCALE(0x0409)]
class MSFT_xRegistryResource : OMI_BaseResource
{
[Key,Description("Path of the registry key.\n") : Amended] string Key;
[Key,Description("Name of the registry key value.\n") : Amended] string ValueName;
[Description("Data of the registry key value.\n") : Amended] string ValueData[];
[Description("Type of the registry key data.\n") : Amended] string ValueType;
[Description("Enumerated value describing if the environment variable should exist on target machine.\nPresent {default} \nAbsent \n") : Amended] string Ensure;
[Description("Flag to identify Hex or Decimal values.\n") : Amended] boolean Hex;
[Description("Flag to specify forced execution.\n") : Amended] boolean Force;
};

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Localized 10/30/2015 03:58 AM (GMT) 303:4.80.0411 MSFT_xRegistryResource.strings.psd1
# Localized resources for MSFT_xRegistryResource

ConvertFrom-StringData @'
###PSLOC
ParameterValueInvalid=(ERROR) Parameter '{0}' has an invalid value '{1}' for type '{2}'
InvalidPSDriveSpecified=(ERROR) Invalid PSDrive '{0}' specified in registry key '{1}'
InvalidRegistryHiveSpecified=(ERROR) Invalid registry hive was specified in registry key '{0}'
SetRegValueFailed=(ERROR) Failed to set registry key value '{0}' to value '{1}' of type '{2}'
SetRegValueUnchanged=(UNCHANGED) No change to registry key value '{0}' containing '{1}'
SetRegKeyUnchanged=(UNCHANGED) No change to registry key '{0}'
SetRegValueSucceeded=(SET) Set registry key value '{0}' to '{1}' of type '{2}'
SetRegKeySucceeded=(SET) Create registry key '{0}'
SetRegKeyFailed=(ERROR) Failed to created registry key '{0}'
RemoveRegKeyTreeFailed=(ERROR) Registry Key '{0}' has subkeys, cannot remove without Force flag
RemoveRegKeySucceeded=(REMOVAL) Registry key '{0}' removed
RemoveRegKeyFailed=(ERROR) Failed to remove registry key '{0}'
RemoveRegValueSucceeded=(REMOVAL) Registry key value '{0}' removed
RemoveRegValueFailed=(ERROR) Failed to remove registry key value '{0}'
RegKeyDoesNotExist=Registry key '{0}' does not exist
RegKeyExists=Registry key '{0}' exists
RegValueExists=Found registry key value '{0}' with type '{1}' and data '{2}'
RegValueDoesNotExist=Registry key value '{0}' does not exist
RegValueTypeMismatch=Registry key value '{0}' of type '{1}' does not exist
RegValueDataMismatch=Registry key value '{0}' of type '{1}' does not contain data '{2}'
DefaultValueDisplayName=(Default)
###PSLOC
'@
4 changes: 2 additions & 2 deletions DSCResources/MSFT_xRemoteFile/MSFT_xRemoteFile.schema.mof
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ class MSFT_xRemoteFile : OMI_BaseResource
[Write, Description("User agent for the web request.")] String UserAgent;
[Write, EmbeddedInstance("MSFT_KeyValuePair"), Description("Headers of the web request.")] String Headers[];
[Write, EmbeddedInstance("MSFT_Credential"), Description("Specifies a user account that has permission to send the request.")] String Credential;
[Write, Description("A boolean value to indicate whether the remote file should be re-downloaded if file in the DestinationPath was modified locally.")] Boolean MatchSource;
[Read, ValueMap{"Present", "Absent"}, Values{"Present", "Absent"}, Description("Says whether DestinationPath exists on the machine")] String Ensure;
[Write, Description("A boolean value to indicate whether the remote file should be re-downloaded if the file in the DestinationPath was modified locally.")] Boolean MatchSource;
[Read, ValueMap{"Present", "Absent"}, Values{"Present", "Absent"}, Description("Says whether DestinationPath exists on the machine")] String Ensure;
};


Expand Down
4 changes: 2 additions & 2 deletions DSCResources/MSFT_xServiceResource/MSFT_xServiceResource.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -282,15 +282,15 @@ function Set-TargetResource
}
if($PSBoundParameters.ContainsKey("Dependencies"))
{
$argumentsToNewService.Add("Dependencies", $Dependencies)
$argumentsToNewService.Add("DependsOn", $Dependencies)
}
try
{
New-Service @argumentsToNewService
}
catch
{
Write-Log -Message ("Error creating service `"$($argumentsToNewService["Name"])`"", $_.Exception.Message)
Write-Log -Message ("Error creating service `"$($argumentsToNewService["Name"])`"; Exception Message: $($_.Exception.Message)")
throw $_
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ DATA localizedData
# culture = "en-US"
ConvertFrom-StringData @'
DismNotAvailable = PowerShell module Dism could not be imported.
NotAClientSku = This Resource is only available for Windows Client.
NotSupportedSku = This Resource is only available for Windows Client or Server 2012 (or later).
ElevationRequired = This Resource requires to be run as an Administrator.
ValidatingPrerequisites = Validating prerequisites...
CouldNotCovertFeatureState = Could not convert feature state '{0}' into Absent/Present.
Expand Down Expand Up @@ -155,11 +155,11 @@ function Set-TargetResource
{
if ($NoWindowsUpdateCheck)
{
$feature = Dism\Enable-WindowsOptionalFeature -FeatureName $Name -Online -LogLevel $DismLogLevel @PSBoundParameters -LimitAccess
$feature = Dism\Enable-WindowsOptionalFeature -FeatureName $Name -Online -LogLevel $DismLogLevel @PSBoundParameters -LimitAccess -NoRestart
}
else
{
$feature = Dism\Enable-WindowsOptionalFeature -FeatureName $Name -Online -LogLevel $DismLogLevel @PSBoundParameters
$feature = Dism\Enable-WindowsOptionalFeature -FeatureName $Name -Online -LogLevel $DismLogLevel @PSBoundParameters -NoRestart
}

Write-Verbose ($LocalizedData.FeatureInstalled -f $Name)
Expand All @@ -168,11 +168,11 @@ function Set-TargetResource
{
if ($RemoveFilesOnDisable)
{
$feature = Dism\Disable-WindowsOptionalFeature -FeatureName $Name -Online -LogLevel $DismLogLevel @PSBoundParameters -Remove
$feature = Dism\Disable-WindowsOptionalFeature -FeatureName $Name -Online -LogLevel $DismLogLevel @PSBoundParameters -Remove -NoRestart
}
else
{
$feature = Dism\Disable-WindowsOptionalFeature -FeatureName $Name -Online -LogLevel $DismLogLevel @PSBoundParameters
$feature = Dism\Disable-WindowsOptionalFeature -FeatureName $Name -Online -LogLevel $DismLogLevel @PSBoundParameters -NoRestart
}

Write-Verbose ($LocalizedData.FeatureUninstalled -f $Name)
Expand All @@ -182,6 +182,7 @@ function Set-TargetResource
throw ($LocalizedData.EnsureNotSupported -f $Ensure)
}

## Indicate we need a restart as needed
if ($feature.RestartNeeded)
{
Write-Verbose $LocalizedData.RestartNeeded
Expand Down Expand Up @@ -234,12 +235,11 @@ function Test-TargetResource
{
$result = $Ensure -eq 'Absent'
}
if (($result.State -eq 'Disabled' -and $Ensure -eq 'Absent')`
-or ($result.State -eq 'Enabled' -and $Ensure -eq 'Present'))
if (($featureState.State -eq 'Disabled' -and $Ensure -eq 'Absent')`
-or ($featureState.State -eq 'Enabled' -and $Ensure -eq 'Present'))
{
$result = $true
}

Write-Debug ($LocalizedData.TestTargetResourceEndMessage -f $Name)
return $result
}
Expand All @@ -250,12 +250,12 @@ function ValidatePrerequisites
{
Write-Verbose $LocalizedData.ValidatingPrerequisites

# check that we're running on a client SKU
$os = Get-CimInstance -ClassName Win32_OperatingSystem
# check that we're running on Server 2012 (or later) or on a client SKU
$os = Get-CimInstance -ClassName Win32_OperatingSystem

if ($os.ProductType -ne 1)
if (($os.ProductType -ne 1) -and ([System.Int32] $os.BuildNumber -lt 9600))
{
throw $LocalizedData.NotAClientSku
throw $LocalizedData.NotSupportedSku
}

# check that we are running elevated
Expand Down
41 changes: 39 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# xPSDesiredStateConfiguration

The **xPSDesiredStateConfiguration** module is a more recent, experimental version of the PSDesiredStateConfiguration module that ships in Windows as part of PowerShell 4.0.
The module contains the **xDscWebService**, **xWindowsProcess**, **xService**, **xPackage**, **xRemoteFile**, and **xGroup** DSC resources, as well as the **xFileUpload** composite DSC resource.
The module contains the **xDscWebService**, **xWindowsProcess**, **xService**, **xPackage**, **xRemoteFile**, **xWindowsOptionalFeature** and **xGroup** DSC resources, as well as the **xFileUpload** composite DSC resource.

## Contributing
Please check out common DSC Resources [contributing guidelines](https://github.com/PowerShell/DscResource.Kit/blob/master/CONTRIBUTING.md).
Expand All @@ -18,7 +18,9 @@ Please check out common DSC Resources [contributing guidelines](https://github.c
* **xRemoteFile** ensures the presence of remote files on a local machine.
* **xPackage** manages the installation of .msi and .exe packages.
* **xGroup** configures and manages local Windows groups
* **xFileUpload** is a composite resource which ensures that local files exist on an SMB share.
* **xFileUpload** is a composite resource which ensures that local files exist on an SMB share.
* **xWindowsOptionalFeature** configures optional Windows features.
* **xRegistry** is a copy of the built-in Registry resource, with some small bug fixes.

### xArchive

Expand Down Expand Up @@ -131,11 +133,46 @@ Domain members may be specified using domain\name or Universal Principal Name (U
* **Credential**: PSCredential for the user with access to DestinationPath.
* **CertificateThumbprint**: Thumbprint of the certificate which should be used for encryption/decryption.

### xRegistry

This is a copy of the built-in Registry resource from the PSDesiredStateConfiguration module, with one small change: it now supports
registry keys whose names contain forward slashes.

### xWindowsOptionalFeature
Note: _the xWindowsOptionalFeature is only supported on Windows client or Windows Server 2012 (and later) SKUs._

* **Name**: Name of the optional Windows feature.
* **Source**: Specifies the location of the files that are required to restore a feature that has been removed from the image.
- You can specify the Windows directory of a mounted image or a running Windows installation that is shared on the network.
- If you specify multiple Source arguments, the files are gathered from the first location where they are found and the rest of the locations are ignored.
* **RemoveFilesOnDisable**: Removes the files for an optional feature without removing the feature's manifest from the image.
- Suported values: $true, $false.
- Default value: $false.
* **LogPath**: Specifies the full path and file name to log to.
- If not set, the default is %WINDIR%\Logs\Dism\dism.log.
* **Ensure**: Ensures that the feature is present or absent.
- Supported values: Present, Absent.
- Default Value: Present.
* **NoWindowsUpdateCheck**: Prevents DISM from contacting Windows Update (WU) when searching for the source files to restore a feature on an online image.
- Suported values: $true, $false.
- Default value: $false.
* **LogLevel**: Specifies the maximum output level shown in the logs.
- Suported values: ErrorsOnly, ErrorsAndWarning, ErrorsAndWarningAndInformation.
- Default value: ErrorsOnly.

## Versions

### Unreleased

### 3.7.0.0

* xService:
- Fixed a bug where 'Dependencies' property was not picked up and caused exception when set.
* xWindowsOptionalFeature:
- Fixed bug where Test-TargetResource method always failed.
- Added support for Windows Server 2012 (and later) SKUs.
* Added xRegistry resource

### 3.6.0.0
* Added CreateCheckRegValue parameter to xPackage resource
* Added MatchSource parameter to xRemoteFile resource
Expand Down
47 changes: 47 additions & 0 deletions Tests/MSFT_xRegistryResource.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
$ErrorActionPreference = 'Stop'

Get-Module MSFT_xRegistryResource | Remove-Module -Force
Import-Module $PSScriptRoot\..\DSCResources\MSFT_xRegistryResource\MSFT_xRegistryResource.psm1 -Prefix UnitTest

Describe 'MSFT_xRegistryResource' {
BeforeAll {
$rootPath = 'Software\__MSFT_xRegistryResource__'
$rootPathWithDrive = "HKCU:\$rootPath"
if (Test-Path -LiteralPath $rootPathWithDrive)
{
Remove-Item -LiteralPath $rootPathWithDrive -Recurse -Force
}

New-Item -Path $rootPathWithDrive
}

AfterAll {
if (Test-Path -LiteralPath $rootPathWithDrive)
{
Remove-Item -LiteralPath $rootPathWithDrive -Recurse -Force
}
}

It 'Supports keys containing forward slashes' {
$keyName = 'Test/Key'
$valueName = 'Testing'
$valueData = 'TestValue'

$scriptBlock = {
Set-UnitTestTargetResource -Key $rootPathWithDrive\$keyName `
-ValueName $valueName `
-ValueData $valueData `
-ValueType String `
-Force $true `
-ErrorAction Stop
}

$scriptBlock | Should Not Throw

$regKey = (Get-Item HKCU:\).OpenSubKey("$rootPath\$keyName")

$regKey | Should Not Be Null
$regKey.GetValue($valueName) | Should Be $valueData
}
}

Loading