Compare commits

...

13 Commits

Author SHA1 Message Date
DoLearnWhileAlive 8f5c724737 ConvertTo-MOFInstance: Include resource properties with empty array value (#127)
* ConvertTo-MOFInstance: Include resource properties with empty array value

* Add test for checking mof compilation with empty array value
2025-12-04 12:48:57 -08:00
Raimund Andrée e32eb0fe51 Fixed an issue with array parameters is key-value pairs (#128) (#129)
* Fixed an issue with array parameters is key-value pairs (#128)

* Add hashtable property to xTestClassResource

* Add support for Hashtable property in DSC resource tests
2025-12-04 12:47:16 -08:00
Andy Jordan c26e6b79d0 Update Code of Conduct and Security Policy (#124)
Updates the readme, code of conduct and security policy per OSPO request.
2024-07-03 15:29:29 -07:00
Michael Greene b711f75b46 Update ReadMe (#114)
* Update README.md

* Update README.md

* Update README.md

Co-authored-by: Mikey Lombardi (He/Him) <michael.t.lombardi@gmail.com>

---------

Co-authored-by: Mikey Lombardi (He/Him) <michael.t.lombardi@gmail.com>
2023-08-04 09:34:33 -07:00
Andrew d6e028d39c Updated changelog for v2.0.7 2023-05-13 12:11:56 -07:00
Andrew 8249681ba9 Fixed link in v2 changelog 2023-02-27 13:54:18 -08:00
Andrew 8daa912f90 Added v2 changelog 2023-02-27 13:49:07 -08:00
Steve Lee 025d75fa4b Change ErrorAction to Ignore so that the error doesn't show up in $Error (#93) 2023-02-14 12:28:13 -08:00
Mikey Lombardi (He/Him) 04830ef480 (AB#5129) Add issue templates and configuration (#92)
This change replaces the default issue templates with YAML issue
templates based on those used across the other PowerShell modules.

It introduces configuration for the issues, including links to filing
feedback for PowerShell, Windows PowerShell, documentation, and Azure
Policy (as **PSDesiredStateConfiguration** v2+ is users of Azure
Policy's machine configuration feature).
2022-08-31 14:12:43 -07:00
Jason Helmick 805041c8fe adding LICENSE (#71) 2022-04-21 14:10:44 -07:00
Jason Helmick 62d16f9563 updated readme (#70) 2022-04-21 11:34:19 -07:00
Andrew a201b69203 Added SBOM generation and changed image to PSMMS2019-Secure (#69) 2022-01-28 14:07:57 -08:00
Steve Lee 2eb60a3b42 Revert "add issue template (#64)" (#66)
This reverts commit 98b309a072.
2021-09-13 17:18:23 -07:00
13 changed files with 325 additions and 104 deletions
+10
View File
@@ -0,0 +1,10 @@
# Microsoft Open Source Code of Conduct
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
Resources:
- [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/)
- [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
- Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns
- Employees can reach out at [aka.ms/opensource/moderation-support](https://aka.ms/opensource/moderation-support)
+77 -71
View File
@@ -1,71 +1,77 @@
name: Bug report 🐛
description: Report errors or unexpected behavior 🤔
labels: Needs-Triage
body:
- type: markdown
attributes:
value: >
For Windows PowerShell 5.1 DSC issues, suggestions, or feature requests please use the
[Feedback Hub app](https://support.microsoft.com/windows/send-feedback-to-microsoft-with-the-feedback-hub-app-f59187f8-8739-22d6-ba93-f66612949332)
This repository is **ONLY** for PSDesiredStateConfiguration module available on PowerShellGallery.com
- type: checkboxes
attributes:
label: Prerequisites
options:
- label: Write a descriptive title.
required: true
- label: Make sure you are able to repro it on the [latest released version](https://www.powershellgallery.com/packages/PSDesiredStateConfiguration)
required: true
- label: Search the existing issues.
required: true
- type: textarea
attributes:
label: Steps to reproduce
description: >
List of steps, sample code, failing test or link to a project that reproduces the behavior.
Make sure you place a stack trace inside a code (```) block to avoid linking unrelated issues.
placeholder: >
I am experiencing a problem with X.
I think Y should be happening but Z is actually happening.
validations:
required: true
- type: textarea
attributes:
label: Expected behavior
render: console
placeholder: |
PS> 2 + 2
4
validations:
required: true
- type: textarea
attributes:
label: Actual behavior
render: console
placeholder: |
PS> 2 + 2
5
validations:
required: true
- type: textarea
attributes:
label: Error details
description: Paste verbatim output from `Get-Error` if PSDesiredStateConfiguration cmdlet return an error.
render: console
placeholder: PS> Get-Error
- type: textarea
attributes:
label: Environment data
description: Paste verbatim output from `$PSVersionTable` below as well as PSDesiredStateConfiguration module info
render: powershell
placeholder: PS> $PSVersionTable; Get-Module PSDesiredStateConfiguration
validations:
required: true
- type: textarea
attributes:
label: Visuals
description: >
Please upload images or animations that can be used to reproduce issues in the area below.
Try the [Steps Recorder](https://support.microsoft.com/en-us/windows/record-steps-to-reproduce-a-problem-46582a9b-620f-2e36-00c9-04e25d784e47)
on Windows or [Screenshot](https://support.apple.com/en-us/HT208721) on macOS.
name: Bug report 🐛
description: Report errors or unexpected behavior 🤔
labels:
- bug
- Needs-Triage
body:
- type: markdown
attributes:
value: >-
This repository is **ONLY** for issues related to DSC in the published
PSDesiredStateConfiguration module.
- type: checkboxes
attributes:
label: Prerequisites
options:
- label: Write a descriptive title.
required: true
- label: Make sure you are able to repro it on the [latest released version](https://www.powershellgallery.com/packages/PSDesiredStateConfiguration)
required: true
- label: Search the existing issues.
required: true
- type: textarea
attributes:
label: Steps to reproduce
description: >
List of steps, sample code, failing test or link to a project that reproduces the behavior.
Make sure you place a stack trace inside a code (```) block to avoid linking unrelated issues.
placeholder: >
I am experiencing a problem with X.
I think Y should be happening but Z is actually happening.
validations:
required: true
- type: textarea
attributes:
label: Expected behavior
render: console
placeholder: |
PS> 2 + 2
4
validations:
required: true
- type: textarea
attributes:
label: Actual behavior
render: console
placeholder: |
PS> 2 + 2
5
validations:
required: true
- type: textarea
attributes:
label: Error details
description: Paste verbatim output from `Get-Error` if PowerShell returns an error.
render: console
placeholder: PS> Get-Error
- type: textarea
attributes:
label: Environment data
description: Paste verbatim output from `$PSVersionTable` below.
render: PowerShell
placeholder: PS> $PSVersionTable
validations:
required: true
- type: input
validations:
required: true
attributes:
label: Version
description: Specify the version of Crescendo you are using.
- type: textarea
attributes:
label: Visuals
description: >
Please upload images or animations that can be used to reproduce issues in the area below.
Try the [Steps Recorder](https://support.microsoft.com/en-us/windows/record-steps-to-reproduce-a-problem-46582a9b-620f-2e36-00c9-04e25d784e47)
on Windows or [Screenshot](https://support.apple.com/en-us/HT208721) on macOS.
+23 -20
View File
@@ -1,20 +1,23 @@
name: Feature Request / Idea 🚀
description: Suggest a new feature or improvement (this does not mean you have to implement it)
labels: [Issue-Enhancement, Needs-Triage]
body:
- type: textarea
attributes:
label: Summary of the new feature / enhancement
description: >
A clear and concise description of what the problem is that the
new feature would solve. Try formulating it in user story style
(if applicable).
placeholder: "'As a user I want X so that Y...' with X being the being the action and Y being the value of the action."
validations:
required: true
- type: textarea
attributes:
label: Proposed technical implementation details (optional)
placeholder: >
A clear and concise description of what you want to happen.
Consider providing an example PowerShell script experience with expected result.
name: Feature Request / Idea 🚀
description: Suggest a new feature or improvement (this does not mean you have to implement it)
labels:
- enhancement
- Needs-Triage
body:
- type: textarea
attributes:
label: Summary of the new feature / enhancement
description: >
A clear and concise description of what the problem is that the new feature would solve. Try
formulating it in user story style (if applicable).
placeholder: >
'As a user I want X so that Y...' with X being the being the action and Y being the value of
the action.
validations:
required: true
- type: textarea
attributes:
label: Proposed technical implementation details (optional)
placeholder: >
A clear and concise description of what you want to happen. Consider providing an example
experience with expected result.
+17 -5
View File
@@ -1,5 +1,17 @@
blank_issues_enabled: false
contact_links:
- name: Documentation Issue
url: https://github.com/MicrosoftDocs/PowerShell-Docs-DSC
about: Please open issues on documentation for PSDesiredStateConfiguration here.
blank_issues_enabled: false
contact_links:
- name: PowerShell Issues
url: https://github.com/PowerShell/PowerShell/issues/new
about: PowerShell issues or suggestions.
- name: Windows PowerShell Issues
url: https://support.microsoft.com/windows/send-feedback-to-microsoft-with-the-feedback-hub-app-f59187f8-8739-22d6-ba93-f66612949332
about: Windows PowerShell issues or suggestions.
- name: Support
url: https://github.com/PowerShell/PowerShell/blob/master/.github/SUPPORT.md
about: PowerShell Support Questions/Help
- name: Documentation Issue
url: https://github.com/MicrosoftDocs/PowerShell-Docs-DSC/issues/new/choose
about: Please open issues on documentation for DSC here.
- name: Azure Policy Feedback
about: File feedback for Azure Policy's machine configuration feature
url: https://feedback.azure.com/d365community/forum/675ae472-f324-ec11-b6e6-000d3a4f0da0
+41
View File
@@ -0,0 +1,41 @@
<!-- BEGIN MICROSOFT SECURITY.MD V0.0.9 BLOCK -->
## Security
Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin) and [PowerShell](https://github.com/PowerShell).
If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/security.md/definition), please report it to us as described below.
## Reporting Security Issues
**Please do not report security vulnerabilities through public GitHub issues.**
Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/security.md/msrc/create-report).
If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/security.md/msrc/pgp).
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc).
Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
* Full paths of source file(s) related to the manifestation of the issue
* The location of the affected source code (tag/branch/commit or direct URL)
* Any special configuration required to reproduce the issue
* Step-by-step instructions to reproduce the issue
* Proof-of-concept or exploit code (if possible)
* Impact of the issue, including how an attacker might exploit the issue
This information will help us triage your report more quickly.
If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/security.md/msrc/bounty) page for more details about our active programs.
## Preferred Languages
We prefer all communications to be in English.
## Policy
Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/security.md/cvd).
<!-- END MICROSOFT SECURITY.MD BLOCK -->
+14 -1
View File
@@ -9,13 +9,19 @@ resources:
endpoint: ComplianceGHRepo
name: PowerShell/compliance
variables:
- name: PackageName
value: 'PSDesiredStateConfiguration'
- name: PackageVersion
value: '3.0.0'
stages:
- stage: Build
displayName: Build PSDesiredStateConfiguration module
pool:
name: 1ES
demands:
- ImageOverride -equals MMS2019
- ImageOverride -equals PSMMS2019-Secure
jobs:
- job: BuildPkg
displayName: Build Package
@@ -115,6 +121,13 @@ stages:
# the file pattern to use, comma separated
pattern: '*.psm1,*.psd1,Microsoft.PowerShell.DscSubsystem.dll'
- template: Sbom.yml@ComplianceRepo
parameters:
BuildDropPath: "$(Build.SourcesDirectory)/signed/PSDesiredStateConfiguration/PSDesiredStateConfiguration"
Build_Repository_Uri: 'https://github.com/PowerShell/PSDesiredStateConfiguration'
PackageName: $(PackageName)
PackageVersion: $(PackageVersion)
- pwsh: |
$repoName = [guid]::newGuid().ToString("N")
$packageRoot = "$(Build.SourcesDirectory)\signed\PSDesiredStateConfiguration"
+3
View File
@@ -0,0 +1,3 @@
# Changelogs
* [v2 changelog](v2.md)
+24
View File
@@ -0,0 +1,24 @@
# v2 Changelog
## [v2.0.7]
### Main changes
- Fixed Invoke-DscResource error when a class-based resource module path contains a space.
- Fixed an issue with array parameters is key-value pairs (#128).
[v2.0.7]: https://www.powershellgallery.com/packages/PSDesiredStateConfiguration/2.0.7
## [v2.0.6]
### Main changes
- Fixed `PathSeparator` bug in Get-DSCResourceModules.
- Changed `PSDesiredStateConfiguration.InvokeDscResource` from experimental to permanently enabled feature.
- Changed `ErrorAction` to `Ignore` so that the error doesn't show up in `$Error`.
- Removed duplicate result resources from `Get-DSCResourcesModules`.
- Add `ImplementationDetail` member to results only when the member does not already exist.
- Updated v2 Release pipeline with latest Compliance requirements.
- Added SBOM generation that is now released with v2 module.
[v2.0.6]: https://www.powershellgallery.com/packages/PSDesiredStateConfiguration/2.0.6
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2022 PowerShell Team
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+50
View File
@@ -1,5 +1,47 @@
# PSDesiredStateConfiguration module
> [!NOTE]
> The next generation of this platform is in development. Please submit your feedback on [DSC v3](https://github.com/powershell/dsc).
**PSDesiredStateConfiguration** (DSC) is the PowerShell module that enables writing configuration as code.
The DSC platform was originally built on top of WMI for Windows. Starting in PowerShell 7.1 and working
with internal partner teams
[Azure Guest Configuration](https://docs.microsoft.com/azure/governance/policy/concepts/guest-configuration)
and [Automanage](https://azure.microsoft.com/services/azure-automanage), we started making
DSC cross-platform by enabling `Invoke-DSCResource` to directly use resources without going through
the Local Configuration Manager (LCM).
Our initial cross-platform work to enable partner teams:
- Separated out the DSC parts in the PowerShell engine and moved them as a subsystem into the
PSDesiredStateConfiguration module
- Remove PSDesiredStateConfiguration module from the PowerShell 7 package. This allows the
PSDesiredStateConfiguration module to be developed independently of PowerShell and users can mix
and match versions of PowerShell and PSDesiredStateConfiguration for their environment.
- This is now available on the PowerShell Gallery: [PSDesiredStateConfiguration 2.x](https://www.powershellgallery.com/packages/PSDesiredStateConfiguration)
- Removing the dependency on MOF: Initially, only support DSC Resources written as PowerShell
classes. This includes tooling to convert existing script based DSC Resources to be wrapped as
PowerShell classes.
## Documentation and resources
The documentation for **PSDesiredStateConfiguration** 3.0.0-beta1 is a work-in-progress. We invite the
community to review the documentation and assist us as we work on new documentation during the platform
development.
For more information about DSC v3, see [PowerShell Desired State Configuration Overview](https://docs.microsoft.com/powershell/dsc/overview?view=dsc-3.0)
To download the latest release from the PowerShell Gallery, see [PSDesiredStateConfiguration 3.0.0-beta1](https://www.powershellgallery.com/packages/PSDesiredStateConfiguration/3.0.0-beta1)
## Community Feedback
As we continue this journey to make DSC a cross-platform technology, we invite the community to
share your ideas and open
[issues](https://github.com/PowerShell/PSDesiredStateConfiguration/issues). During the PowerShell
7.3 timeframe, we remain focused on enabling partner teams and will not be accepting public pull
requests.
## Build
### Requirements
@@ -17,3 +59,11 @@ CI pipeline definition is in `.vsts-ci\azure-pipelines-ci.yml` and running Compl
## Publishing Releases
[The module is released on Powershell Gallery](https://www.powershellgallery.com/packages/PSDesiredStateConfiguration).
For a release the code of this repo is mirrored into an internal repo and `.vsts-ci\azure-pipelines-release.yml` pipeline is run. Release builds are signed.
## Code of Conduct
Please see our [Code of Conduct](.github/CODE_OF_CONDUCT.md) before participating in this project.
## Security Policy
For any security issues, please see our [Security Policy](.github/SECURITY.md).
@@ -71,7 +71,7 @@ data LocalizedData
Set-StrictMode -Off
# In case localized resource is not available we revert back to English as defined in LocalizedData section so ignore the error instead of showing it to user.
Import-LocalizedData -BindingVariable LocalizedData -FileName PSDesiredStateConfiguration.Resource.psd1 -ErrorAction SilentlyContinue
Import-LocalizedData -BindingVariable LocalizedData -FileName PSDesiredStateConfiguration.Resource.psd1 -ErrorAction Ignore
Import-Module $PSScriptRoot/helpers/DscResourceInfo.psm1
@@ -509,7 +509,7 @@ function ConvertTo-MOFInstance
$targetTypeName = $PropertyTypes[$p.Name].TypeConstraint
# see if the target type is an array
$asArray = $p.Name -eq 'DependsOn' -or $targetTypeName -match 'Array'
$asArray = $p.Name -eq 'DependsOn' -or $targetTypeName -match 'Array' -or ((-not [string]::IsNullOrEmpty($targetTypeName)) -and $targetTypeName.EndsWith('[]'))
# Convert the CIM typename to the appropriate .NET type to use
# to convert the input object into an appropriately encoded string
@@ -671,10 +671,7 @@ function ConvertTo-MOFInstance
}
else
{
if ($targetTypeName -notmatch 'Array' -or $p.Value.Count)
{
$p.Name + ' = ' + (stringify -value $p.Value -asArray $asArray -targetType $targetType ) + ";`n"
}
$p.Name + ' = ' + (stringify -value $p.Value -asArray $asArray -targetType $targetType ) + ";`n"
}
}
}
@@ -3481,7 +3478,7 @@ function New-DscChecksum
}
# If the Force parameter was not specified and the hash file already exists for the current file, log this, and skip this file
if (!$Force -and (Get-Item -Path $fileOutpath -ErrorAction SilentlyContinue))
if (!$Force -and (Get-Item -Path $fileOutpath -ErrorAction Ignore))
{
Write-Log -Message ($LocalizedData.CheckSumFileExists -f $fileOutpath)
continue
@@ -302,6 +302,8 @@ Describe "All types DSC resource tests" {
"uInt32ValueArray" {$dscResourcePropertyInfo.PropertyType | Should -Be '[UInt32[]]'}
"uInt64Value" {$dscResourcePropertyInfo.PropertyType | Should -Be '[UInt64]'}
"uInt64ValueArray" {$dscResourcePropertyInfo.PropertyType | Should -Be '[UInt64[]]'}
"HashTableValue" {$dscResourcePropertyInfo.PropertyType | Should -Be '[Hashtable]'}
}
}
}
@@ -350,6 +352,8 @@ Describe "All types DSC resource tests" {
$resource.uInt64Value.GetType().Name | Should -Be "UInt64"
$resource.uInt64ValueArray.GetType().Name | Should -Be "UInt64[]"
$resource.HashTableValue.GetType().Name | Should -Be "Hashtable"
# extra check for embedded objects
$resource.EmbClassObj.EmbClassStr1 | Should -Be "TestEmbObjValue"
$resource.EmbClassObjArray[0].EmbClassStr1 | Should -Be "TestEmbClassStr1Value"
@@ -400,6 +404,11 @@ configuration DSCAllTypesConfig
sInt32ValueArray = @(-2147483648)
uInt64ValueArray = @(18446744073709551615)
sInt64ValueArray = @(-9223372036854775808)
HashTableValue = @{
Key1 = 'Value1'
Key2 = 'Value2'
}
}
}
}
@@ -439,4 +448,31 @@ MultiResourceConfig -OutputPath TestDrive:\MultiResourceConfig
"TestDrive:\MultiResourceConfig\localhost.mof" | Should -Exist
Get-Content -Raw -Path "TestDrive:\MultiResourceConfig\localhost.mof" | Write-Verbose -Verbose
}
It "Check empty array compilation" {
[Scriptblock]::Create(@"
configuration DSCEmptyArrayConfig
{
Import-DscResource -ModuleName xTestClassResource
Node "localhost" {
xTestClassResource f2
{
Name = 'TestName'
Value = 'TestValue'
sArray = @()
}
}
}
DSCEmptyArrayConfig -OutputPath TestDrive:\DSCEmptyArrayConfig
"@) | Should -Not -Throw
"TestDrive:\DSCEmptyArrayConfig\localhost.mof" | Should -Exist
$mofContent = Get-Content -Raw -Path "TestDrive:\DSCEmptyArrayConfig\localhost.mof"
$mofContent | Write-Verbose -Verbose
$mofContent -match '\ssArray\s=\s{\r\n};' | Should -BeTrue
}
}
@@ -109,6 +109,9 @@ class xTestClassResource
[DscProperty()]
[Char[]] $char16ValueArray;
[DscProperty()]
[hashtable] $HashTableValue;
[void] Set()
{
@@ -257,6 +260,8 @@ class xTestClassResource
$this.Real32ValueArray = [single[]]::new(0)
$this.Real64ValueArray = [double[]]::new(0)
$this.HashTableValue = @{}
return $this
}
}