mirror of
https://github.com/PowerShell/PSDesiredStateConfiguration
synced 2026-06-21 13:45:25 +00:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8f5c724737 | |||
| e32eb0fe51 | |||
| c26e6b79d0 | |||
| b711f75b46 | |||
| d6e028d39c | |||
| 8249681ba9 | |||
| 8daa912f90 | |||
| 025d75fa4b | |||
| 04830ef480 | |||
| 805041c8fe | |||
| 62d16f9563 | |||
| a201b69203 | |||
| 2eb60a3b42 |
@@ -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)
|
||||||
@@ -1,71 +1,77 @@
|
|||||||
name: Bug report 🐛
|
name: Bug report 🐛
|
||||||
description: Report errors or unexpected behavior 🤔
|
description: Report errors or unexpected behavior 🤔
|
||||||
labels: Needs-Triage
|
labels:
|
||||||
body:
|
- bug
|
||||||
- type: markdown
|
- Needs-Triage
|
||||||
attributes:
|
body:
|
||||||
value: >
|
- type: markdown
|
||||||
For Windows PowerShell 5.1 DSC issues, suggestions, or feature requests please use the
|
attributes:
|
||||||
[Feedback Hub app](https://support.microsoft.com/windows/send-feedback-to-microsoft-with-the-feedback-hub-app-f59187f8-8739-22d6-ba93-f66612949332)
|
value: >-
|
||||||
|
This repository is **ONLY** for issues related to DSC in the published
|
||||||
This repository is **ONLY** for PSDesiredStateConfiguration module available on PowerShellGallery.com
|
PSDesiredStateConfiguration module.
|
||||||
- type: checkboxes
|
- type: checkboxes
|
||||||
attributes:
|
attributes:
|
||||||
label: Prerequisites
|
label: Prerequisites
|
||||||
options:
|
options:
|
||||||
- label: Write a descriptive title.
|
- label: Write a descriptive title.
|
||||||
required: true
|
required: true
|
||||||
- label: Make sure you are able to repro it on the [latest released version](https://www.powershellgallery.com/packages/PSDesiredStateConfiguration)
|
- label: Make sure you are able to repro it on the [latest released version](https://www.powershellgallery.com/packages/PSDesiredStateConfiguration)
|
||||||
required: true
|
required: true
|
||||||
- label: Search the existing issues.
|
- label: Search the existing issues.
|
||||||
required: true
|
required: true
|
||||||
- type: textarea
|
- type: textarea
|
||||||
attributes:
|
attributes:
|
||||||
label: Steps to reproduce
|
label: Steps to reproduce
|
||||||
description: >
|
description: >
|
||||||
List of steps, sample code, failing test or link to a project that reproduces the behavior.
|
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.
|
Make sure you place a stack trace inside a code (```) block to avoid linking unrelated issues.
|
||||||
placeholder: >
|
placeholder: >
|
||||||
I am experiencing a problem with X.
|
I am experiencing a problem with X.
|
||||||
I think Y should be happening but Z is actually happening.
|
I think Y should be happening but Z is actually happening.
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
- type: textarea
|
- type: textarea
|
||||||
attributes:
|
attributes:
|
||||||
label: Expected behavior
|
label: Expected behavior
|
||||||
render: console
|
render: console
|
||||||
placeholder: |
|
placeholder: |
|
||||||
PS> 2 + 2
|
PS> 2 + 2
|
||||||
4
|
4
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
- type: textarea
|
- type: textarea
|
||||||
attributes:
|
attributes:
|
||||||
label: Actual behavior
|
label: Actual behavior
|
||||||
render: console
|
render: console
|
||||||
placeholder: |
|
placeholder: |
|
||||||
PS> 2 + 2
|
PS> 2 + 2
|
||||||
5
|
5
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
- type: textarea
|
- type: textarea
|
||||||
attributes:
|
attributes:
|
||||||
label: Error details
|
label: Error details
|
||||||
description: Paste verbatim output from `Get-Error` if PSDesiredStateConfiguration cmdlet return an error.
|
description: Paste verbatim output from `Get-Error` if PowerShell returns an error.
|
||||||
render: console
|
render: console
|
||||||
placeholder: PS> Get-Error
|
placeholder: PS> Get-Error
|
||||||
- type: textarea
|
- type: textarea
|
||||||
attributes:
|
attributes:
|
||||||
label: Environment data
|
label: Environment data
|
||||||
description: Paste verbatim output from `$PSVersionTable` below as well as PSDesiredStateConfiguration module info
|
description: Paste verbatim output from `$PSVersionTable` below.
|
||||||
render: powershell
|
render: PowerShell
|
||||||
placeholder: PS> $PSVersionTable; Get-Module PSDesiredStateConfiguration
|
placeholder: PS> $PSVersionTable
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
- type: textarea
|
- type: input
|
||||||
attributes:
|
validations:
|
||||||
label: Visuals
|
required: true
|
||||||
description: >
|
attributes:
|
||||||
Please upload images or animations that can be used to reproduce issues in the area below.
|
label: Version
|
||||||
Try the [Steps Recorder](https://support.microsoft.com/en-us/windows/record-steps-to-reproduce-a-problem-46582a9b-620f-2e36-00c9-04e25d784e47)
|
description: Specify the version of Crescendo you are using.
|
||||||
on Windows or [Screenshot](https://support.apple.com/en-us/HT208721) on macOS.
|
- 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.
|
||||||
|
|||||||
@@ -1,20 +1,23 @@
|
|||||||
name: Feature Request / Idea 🚀
|
name: Feature Request / Idea 🚀
|
||||||
description: Suggest a new feature or improvement (this does not mean you have to implement it)
|
description: Suggest a new feature or improvement (this does not mean you have to implement it)
|
||||||
labels: [Issue-Enhancement, Needs-Triage]
|
labels:
|
||||||
body:
|
- enhancement
|
||||||
- type: textarea
|
- Needs-Triage
|
||||||
attributes:
|
body:
|
||||||
label: Summary of the new feature / enhancement
|
- type: textarea
|
||||||
description: >
|
attributes:
|
||||||
A clear and concise description of what the problem is that the
|
label: Summary of the new feature / enhancement
|
||||||
new feature would solve. Try formulating it in user story style
|
description: >
|
||||||
(if applicable).
|
A clear and concise description of what the problem is that the new feature would solve. Try
|
||||||
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."
|
formulating it in user story style (if applicable).
|
||||||
validations:
|
placeholder: >
|
||||||
required: true
|
'As a user I want X so that Y...' with X being the being the action and Y being the value of
|
||||||
- type: textarea
|
the action.
|
||||||
attributes:
|
validations:
|
||||||
label: Proposed technical implementation details (optional)
|
required: true
|
||||||
placeholder: >
|
- type: textarea
|
||||||
A clear and concise description of what you want to happen.
|
attributes:
|
||||||
Consider providing an example PowerShell script experience with expected result.
|
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.
|
||||||
|
|||||||
@@ -1,5 +1,17 @@
|
|||||||
blank_issues_enabled: false
|
blank_issues_enabled: false
|
||||||
contact_links:
|
contact_links:
|
||||||
- name: Documentation Issue
|
- name: PowerShell Issues
|
||||||
url: https://github.com/MicrosoftDocs/PowerShell-Docs-DSC
|
url: https://github.com/PowerShell/PowerShell/issues/new
|
||||||
about: Please open issues on documentation for PSDesiredStateConfiguration here.
|
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
|
||||||
|
|||||||
@@ -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 -->
|
||||||
@@ -9,13 +9,19 @@ resources:
|
|||||||
endpoint: ComplianceGHRepo
|
endpoint: ComplianceGHRepo
|
||||||
name: PowerShell/compliance
|
name: PowerShell/compliance
|
||||||
|
|
||||||
|
variables:
|
||||||
|
- name: PackageName
|
||||||
|
value: 'PSDesiredStateConfiguration'
|
||||||
|
- name: PackageVersion
|
||||||
|
value: '3.0.0'
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- stage: Build
|
- stage: Build
|
||||||
displayName: Build PSDesiredStateConfiguration module
|
displayName: Build PSDesiredStateConfiguration module
|
||||||
pool:
|
pool:
|
||||||
name: 1ES
|
name: 1ES
|
||||||
demands:
|
demands:
|
||||||
- ImageOverride -equals MMS2019
|
- ImageOverride -equals PSMMS2019-Secure
|
||||||
jobs:
|
jobs:
|
||||||
- job: BuildPkg
|
- job: BuildPkg
|
||||||
displayName: Build Package
|
displayName: Build Package
|
||||||
@@ -115,6 +121,13 @@ stages:
|
|||||||
# the file pattern to use, comma separated
|
# the file pattern to use, comma separated
|
||||||
pattern: '*.psm1,*.psd1,Microsoft.PowerShell.DscSubsystem.dll'
|
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: |
|
- pwsh: |
|
||||||
$repoName = [guid]::newGuid().ToString("N")
|
$repoName = [guid]::newGuid().ToString("N")
|
||||||
$packageRoot = "$(Build.SourcesDirectory)\signed\PSDesiredStateConfiguration"
|
$packageRoot = "$(Build.SourcesDirectory)\signed\PSDesiredStateConfiguration"
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# Changelogs
|
||||||
|
|
||||||
|
* [v2 changelog](v2.md)
|
||||||
@@ -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
|
||||||
@@ -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.
|
||||||
@@ -1,5 +1,47 @@
|
|||||||
# PSDesiredStateConfiguration module
|
# 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
|
## Build
|
||||||
|
|
||||||
### Requirements
|
### Requirements
|
||||||
@@ -17,3 +59,11 @@ CI pipeline definition is in `.vsts-ci\azure-pipelines-ci.yml` and running Compl
|
|||||||
## Publishing Releases
|
## Publishing Releases
|
||||||
[The module is released on Powershell Gallery](https://www.powershellgallery.com/packages/PSDesiredStateConfiguration).
|
[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.
|
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
|
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.
|
# 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
|
Import-Module $PSScriptRoot/helpers/DscResourceInfo.psm1
|
||||||
|
|
||||||
@@ -509,7 +509,7 @@ function ConvertTo-MOFInstance
|
|||||||
$targetTypeName = $PropertyTypes[$p.Name].TypeConstraint
|
$targetTypeName = $PropertyTypes[$p.Name].TypeConstraint
|
||||||
|
|
||||||
# see if the target type is an array
|
# 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
|
# Convert the CIM typename to the appropriate .NET type to use
|
||||||
# to convert the input object into an appropriately encoded string
|
# to convert the input object into an appropriately encoded string
|
||||||
@@ -671,10 +671,7 @@ function ConvertTo-MOFInstance
|
|||||||
}
|
}
|
||||||
else
|
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 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)
|
Write-Log -Message ($LocalizedData.CheckSumFileExists -f $fileOutpath)
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -302,6 +302,8 @@ Describe "All types DSC resource tests" {
|
|||||||
"uInt32ValueArray" {$dscResourcePropertyInfo.PropertyType | Should -Be '[UInt32[]]'}
|
"uInt32ValueArray" {$dscResourcePropertyInfo.PropertyType | Should -Be '[UInt32[]]'}
|
||||||
"uInt64Value" {$dscResourcePropertyInfo.PropertyType | Should -Be '[UInt64]'}
|
"uInt64Value" {$dscResourcePropertyInfo.PropertyType | Should -Be '[UInt64]'}
|
||||||
"uInt64ValueArray" {$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.uInt64Value.GetType().Name | Should -Be "UInt64"
|
||||||
$resource.uInt64ValueArray.GetType().Name | Should -Be "UInt64[]"
|
$resource.uInt64ValueArray.GetType().Name | Should -Be "UInt64[]"
|
||||||
|
|
||||||
|
$resource.HashTableValue.GetType().Name | Should -Be "Hashtable"
|
||||||
|
|
||||||
# extra check for embedded objects
|
# extra check for embedded objects
|
||||||
$resource.EmbClassObj.EmbClassStr1 | Should -Be "TestEmbObjValue"
|
$resource.EmbClassObj.EmbClassStr1 | Should -Be "TestEmbObjValue"
|
||||||
$resource.EmbClassObjArray[0].EmbClassStr1 | Should -Be "TestEmbClassStr1Value"
|
$resource.EmbClassObjArray[0].EmbClassStr1 | Should -Be "TestEmbClassStr1Value"
|
||||||
@@ -400,6 +404,11 @@ configuration DSCAllTypesConfig
|
|||||||
sInt32ValueArray = @(-2147483648)
|
sInt32ValueArray = @(-2147483648)
|
||||||
uInt64ValueArray = @(18446744073709551615)
|
uInt64ValueArray = @(18446744073709551615)
|
||||||
sInt64ValueArray = @(-9223372036854775808)
|
sInt64ValueArray = @(-9223372036854775808)
|
||||||
|
|
||||||
|
HashTableValue = @{
|
||||||
|
Key1 = 'Value1'
|
||||||
|
Key2 = 'Value2'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -439,4 +448,31 @@ MultiResourceConfig -OutputPath TestDrive:\MultiResourceConfig
|
|||||||
"TestDrive:\MultiResourceConfig\localhost.mof" | Should -Exist
|
"TestDrive:\MultiResourceConfig\localhost.mof" | Should -Exist
|
||||||
Get-Content -Raw -Path "TestDrive:\MultiResourceConfig\localhost.mof" | Write-Verbose -Verbose
|
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()]
|
[DscProperty()]
|
||||||
[Char[]] $char16ValueArray;
|
[Char[]] $char16ValueArray;
|
||||||
|
|
||||||
|
[DscProperty()]
|
||||||
|
[hashtable] $HashTableValue;
|
||||||
|
|
||||||
[void] Set()
|
[void] Set()
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -257,6 +260,8 @@ class xTestClassResource
|
|||||||
$this.Real32ValueArray = [single[]]::new(0)
|
$this.Real32ValueArray = [single[]]::new(0)
|
||||||
$this.Real64ValueArray = [double[]]::new(0)
|
$this.Real64ValueArray = [double[]]::new(0)
|
||||||
|
|
||||||
|
$this.HashTableValue = @{}
|
||||||
|
|
||||||
return $this
|
return $this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user