├── .github
├── CODE_OF_CONDUCT.md
├── ISSUE_TEMPLATE
│ ├── Bug_Report.yaml
│ ├── Feature_Request.yaml
│ └── config.yml
└── SECURITY.md
├── .gitignore
├── .vsts-ci
├── azure-pipelines-ci.yml
├── azure-pipelines-release.yml
└── templates
│ └── ci-test.yml
├── CHANGELOG
├── README.md
└── v2.md
├── LICENSE
├── README.md
├── build.ps1
├── dobuild.ps1
├── global.json
├── help
└── en-US
│ └── about_PSDesiredStateConfiguration.md
├── nuget.config
├── pspackageproject.json
├── src
├── DscSubsystem
│ ├── CrossPlatformDsc.cs
│ ├── JsonCimDSCParser.cs
│ ├── JsonDeserializer.cs
│ ├── JsonDscClassCache.cs
│ ├── Microsoft.PowerShell.DscSubsystem.csproj
│ └── visualstudiopublic.snk
└── PSDesiredStateConfiguration
│ ├── Configuration
│ └── BaseRegistration
│ │ ├── BaseResource.schema.json
│ │ ├── BaseResource.schema.mof
│ │ ├── MSFT_DSCMetaConfiguration.json
│ │ ├── MSFT_DSCMetaConfiguration.mof
│ │ ├── MSFT_MetaConfigurationExtensionClasses.schema.json
│ │ ├── MSFT_MetaConfigurationExtensionClasses.schema.mof
│ │ └── en-US
│ │ ├── BaseResource.Schema.mfl
│ │ ├── MSFT_DSCMetaConfiguration.mfl
│ │ └── MSFT_MetaConfigurationExtensionClasses.Schema.mfl
│ ├── PSDesiredStateConfiguration.psd1
│ ├── PSDesiredStateConfiguration.psm1
│ └── helpers
│ └── DscResourceInfo.psm1
├── test
├── PSDesiredStateConfiguration.Tests.ps1
└── TestModules
│ └── xTestClassResource
│ ├── xTestClassResource.psd1
│ └── xTestClassResource.psm1
└── tools
├── releaseBuild
├── FileCatalogSigning.xml
├── generatePackgeSigning.ps1
├── packagesigning.xml
└── signing.xml
└── terms
└── FileTypeSet.xml
/.github/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Microsoft Open Source Code of Conduct
2 |
3 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
4 |
5 | Resources:
6 |
7 | - [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/)
8 | - [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
9 | - Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns
10 | - Employees can reach out at [aka.ms/opensource/moderation-support](https://aka.ms/opensource/moderation-support)
11 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/Bug_Report.yaml:
--------------------------------------------------------------------------------
1 | name: Bug report 🐛
2 | description: Report errors or unexpected behavior 🤔
3 | labels:
4 | - bug
5 | - Needs-Triage
6 | body:
7 | - type: markdown
8 | attributes:
9 | value: >-
10 | This repository is **ONLY** for issues related to DSC in the published
11 | PSDesiredStateConfiguration module.
12 | - type: checkboxes
13 | attributes:
14 | label: Prerequisites
15 | options:
16 | - label: Write a descriptive title.
17 | required: true
18 | - label: Make sure you are able to repro it on the [latest released version](https://www.powershellgallery.com/packages/PSDesiredStateConfiguration)
19 | required: true
20 | - label: Search the existing issues.
21 | required: true
22 | - type: textarea
23 | attributes:
24 | label: Steps to reproduce
25 | description: >
26 | List of steps, sample code, failing test or link to a project that reproduces the behavior.
27 | Make sure you place a stack trace inside a code (```) block to avoid linking unrelated issues.
28 | placeholder: >
29 | I am experiencing a problem with X.
30 | I think Y should be happening but Z is actually happening.
31 | validations:
32 | required: true
33 | - type: textarea
34 | attributes:
35 | label: Expected behavior
36 | render: console
37 | placeholder: |
38 | PS> 2 + 2
39 | 4
40 | validations:
41 | required: true
42 | - type: textarea
43 | attributes:
44 | label: Actual behavior
45 | render: console
46 | placeholder: |
47 | PS> 2 + 2
48 | 5
49 | validations:
50 | required: true
51 | - type: textarea
52 | attributes:
53 | label: Error details
54 | description: Paste verbatim output from `Get-Error` if PowerShell returns an error.
55 | render: console
56 | placeholder: PS> Get-Error
57 | - type: textarea
58 | attributes:
59 | label: Environment data
60 | description: Paste verbatim output from `$PSVersionTable` below.
61 | render: PowerShell
62 | placeholder: PS> $PSVersionTable
63 | validations:
64 | required: true
65 | - type: input
66 | validations:
67 | required: true
68 | attributes:
69 | label: Version
70 | description: Specify the version of Crescendo you are using.
71 | - type: textarea
72 | attributes:
73 | label: Visuals
74 | description: >
75 | Please upload images or animations that can be used to reproduce issues in the area below.
76 | Try the [Steps Recorder](https://support.microsoft.com/en-us/windows/record-steps-to-reproduce-a-problem-46582a9b-620f-2e36-00c9-04e25d784e47)
77 | on Windows or [Screenshot](https://support.apple.com/en-us/HT208721) on macOS.
78 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/Feature_Request.yaml:
--------------------------------------------------------------------------------
1 | name: Feature Request / Idea 🚀
2 | description: Suggest a new feature or improvement (this does not mean you have to implement it)
3 | labels:
4 | - enhancement
5 | - Needs-Triage
6 | body:
7 | - type: textarea
8 | attributes:
9 | label: Summary of the new feature / enhancement
10 | description: >
11 | A clear and concise description of what the problem is that the new feature would solve. Try
12 | formulating it in user story style (if applicable).
13 | placeholder: >
14 | 'As a user I want X so that Y...' with X being the being the action and Y being the value of
15 | the action.
16 | validations:
17 | required: true
18 | - type: textarea
19 | attributes:
20 | label: Proposed technical implementation details (optional)
21 | placeholder: >
22 | A clear and concise description of what you want to happen. Consider providing an example
23 | experience with expected result.
24 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/config.yml:
--------------------------------------------------------------------------------
1 | blank_issues_enabled: false
2 | contact_links:
3 | - name: PowerShell Issues
4 | url: https://github.com/PowerShell/PowerShell/issues/new
5 | about: PowerShell issues or suggestions.
6 | - name: Windows PowerShell Issues
7 | url: https://support.microsoft.com/windows/send-feedback-to-microsoft-with-the-feedback-hub-app-f59187f8-8739-22d6-ba93-f66612949332
8 | about: Windows PowerShell issues or suggestions.
9 | - name: Support
10 | url: https://github.com/PowerShell/PowerShell/blob/master/.github/SUPPORT.md
11 | about: PowerShell Support Questions/Help
12 | - name: Documentation Issue
13 | url: https://github.com/MicrosoftDocs/PowerShell-Docs-DSC/issues/new/choose
14 | about: Please open issues on documentation for DSC here.
15 | - name: Azure Policy Feedback
16 | about: File feedback for Azure Policy's machine configuration feature
17 | url: https://feedback.azure.com/d365community/forum/675ae472-f324-ec11-b6e6-000d3a4f0da0
18 |
--------------------------------------------------------------------------------
/.github/SECURITY.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## Security
4 |
5 | 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).
6 |
7 | 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.
8 |
9 | ## Reporting Security Issues
10 |
11 | **Please do not report security vulnerabilities through public GitHub issues.**
12 |
13 | 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).
14 |
15 | 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).
16 |
17 | 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).
18 |
19 | 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:
20 |
21 | * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
22 | * Full paths of source file(s) related to the manifestation of the issue
23 | * The location of the affected source code (tag/branch/commit or direct URL)
24 | * Any special configuration required to reproduce the issue
25 | * Step-by-step instructions to reproduce the issue
26 | * Proof-of-concept or exploit code (if possible)
27 | * Impact of the issue, including how an attacker might exploit the issue
28 |
29 | This information will help us triage your report more quickly.
30 |
31 | 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.
32 |
33 | ## Preferred Languages
34 |
35 | We prefer all communications to be in English.
36 |
37 | ## Policy
38 |
39 | Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/security.md/cvd).
40 |
41 |
42 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /out
2 | *.pester.xml
3 | *.DS_Store
4 |
--------------------------------------------------------------------------------
/.vsts-ci/azure-pipelines-ci.yml:
--------------------------------------------------------------------------------
1 | name: Build-$(System.PullRequest.PullRequestNumber)-$(Date:yyyyMMdd)$(Rev:.rr)
2 | trigger:
3 | # Batch merge builds together while a merge build is running
4 | batch: true
5 | branches:
6 | include:
7 | - master
8 | pr:
9 | branches:
10 | include:
11 | - master
12 |
13 | resources:
14 | repositories:
15 | - repository: ComplianceRepo
16 | type: github
17 | endpoint: ComplianceGHRepo
18 | name: PowerShell/compliance
19 |
20 | stages:
21 | - stage: Build
22 | displayName: Build PSDesiredStateConfiguration module
23 | pool:
24 | vmImage: windows-latest
25 | jobs:
26 | - job: BuildPkg
27 | displayName: Build Package
28 | steps:
29 | - powershell: |
30 | $powerShellPath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'powershell'
31 | Invoke-WebRequest -Uri https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.ps1 -outfile ./install-powershell.ps1
32 | ./install-powershell.ps1 -Destination $powerShellPath
33 | $vstsCommandString = "vso[task.setvariable variable=PATH]$powerShellPath;$env:PATH"
34 | Write-Host "sending " + $vstsCommandString
35 | Write-Host "##$vstsCommandString"
36 | displayName: Install PowerShell Core
37 |
38 | - task: NuGetToolInstaller@1
39 | displayName: 'Install NuGet 5.9.1'
40 | inputs:
41 | checkLatest: false
42 | version: 5.9.1
43 |
44 | - task: UseDotNet@2
45 | displayName: 'Install .NET Core SDK'
46 | inputs:
47 | packageType: sdk
48 | useGlobalJson: true
49 | includePreviewVersions: true
50 | workingDirectory: '$(Build.SourcesDirectory)'
51 |
52 | - pwsh: |
53 | Get-ChildItem -Path env:
54 | displayName: Capture environment for build
55 | condition: succeededOrFailed()
56 |
57 | - pwsh: |
58 | $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules'
59 | if (Test-Path -Path $modulePath) {
60 | Write-Verbose -Verbose "Deleting existing temp module path: $modulePath"
61 | Remove-Item -Path $modulePath -Recurse -Force -ErrorAction Ignore
62 | }
63 | if (! (Test-Path -Path $modulePath)) {
64 | Write-Verbose -Verbose "Creating new temp module path: $modulePath"
65 | $null = New-Item -Path $modulePath -ItemType Directory
66 | }
67 | displayName: Create temporary module path
68 |
69 | - pwsh: |
70 | $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules'
71 | Write-Verbose -Verbose "Install PowerShellGet V3 to temp module path"
72 | Save-Module -Name PowerShellGet -Path $modulePath -MinimumVersion 3.0.0-beta10 -AllowPrerelease -Force
73 | Write-Verbose -Verbose "Install PlatyPS to temp module path"
74 | Save-Module -Name "platyPS" -Path $modulePath -Force
75 | Write-Verbose -Verbose "Install PSScriptAnalyzer to temp module path"
76 | Save-Module -Name "PSScriptAnalyzer" -Path $modulePath -RequiredVersion 1.18.0 -Force
77 | Write-Verbose -Verbose "Install Pester 4.X to temp module path"
78 | Save-Module -Name "Pester" -MaximumVersion 4.99 -Path $modulePath -Force
79 | Write-Verbose -Verbose "Install PSPackageProject to temp module path"
80 | Save-Module -Name PSPackageProject -Path $modulePath -Force
81 | displayName: Install PSPackageProject and dependencies
82 |
83 | - pwsh: |
84 | $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules'
85 | $env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath
86 | $modPath = Join-Path -Path $modulePath -ChildPath PSPackageProject
87 | Write-Verbose -Verbose "Importing PSPackageProject from: $modPath"
88 | Import-Module -Name $modPath -Force
89 | #
90 | $(Build.SourcesDirectory)/build.ps1 -Build -Clean
91 | $outBinPath = "$(Build.SourcesDirectory)\out\PSDesiredStateConfiguration"
92 | $vstsCommandString = "vso[task.setvariable variable=outBinPath]${outBinPath}"
93 | Write-Host "sending " + $vstsCommandString
94 | Write-Host "##$vstsCommandString"
95 | displayName: Execute build
96 |
97 | - publish: "$(outBinPath)"
98 | artifact: Build
99 | displayName: Publish build
100 |
101 | - stage: Compliance
102 | displayName: Compliance
103 | dependsOn: Build
104 | jobs:
105 | - job: Compliance_Job
106 | pool:
107 | vmImage: windows-latest
108 | steps:
109 | - checkout: self
110 | - checkout: ComplianceRepo
111 | - download: current
112 | artifact: Build
113 |
114 | - pwsh: |
115 | Get-ChildItem -Path "$(Pipeline.Workspace)\Build" -Recurse
116 | displayName: Capture downloaded artifacts
117 | - template: ci-compliance.yml@ComplianceRepo
118 | parameters:
119 | # component-governance
120 | sourceScanPath: '$(Pipeline.Workspace)\Build'
121 | # credscan
122 | suppressionsFile: ''
123 | # TermCheck
124 | optionsRulesDBPath: ''
125 | optionsFTPath: ''
126 | # tsa-upload
127 | codeBaseName: 'PSDesiredStateConfiguration_20210423'
128 | # selections
129 | APIScan: false # set to false when not using Windows APIs.
130 |
131 | - stage: Test
132 | displayName: Test Package
133 | dependsOn: Build
134 | jobs:
135 | - template: templates/ci-test.yml
136 | parameters:
137 | jobName: TestPkgWin
138 | displayName: PowerShell Core on Windows
139 | imageName: windows-latest
140 |
141 | - template: templates/ci-test.yml
142 | parameters:
143 | jobName: TestPkgUbuntu
144 | displayName: PowerShell Core on Ubuntu
145 | imageName: ubuntu-latest
146 |
147 | - template: templates/ci-test.yml
148 | parameters:
149 | jobName: TestPkgWinMacOS
150 | displayName: PowerShell Core on macOS
151 | imageName: macOS-latest
152 |
--------------------------------------------------------------------------------
/.vsts-ci/azure-pipelines-release.yml:
--------------------------------------------------------------------------------
1 | name: $(BuildDefinitionName)_$(date:yyMM).$(date:dd)$(rev:rrr)
2 |
3 | trigger: none
4 |
5 | resources:
6 | repositories:
7 | - repository: ComplianceRepo
8 | type: github
9 | endpoint: ComplianceGHRepo
10 | name: PowerShell/compliance
11 |
12 | variables:
13 | - name: PackageName
14 | value: 'PSDesiredStateConfiguration'
15 | - name: PackageVersion
16 | value: '3.0.0'
17 |
18 | stages:
19 | - stage: Build
20 | displayName: Build PSDesiredStateConfiguration module
21 | pool:
22 | name: 1ES
23 | demands:
24 | - ImageOverride -equals PSMMS2019-Secure
25 | jobs:
26 | - job: BuildPkg
27 | displayName: Build Package
28 | variables:
29 | - group: ESRP
30 | steps:
31 | - powershell: |
32 | $powerShellPath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'powershell'
33 | Invoke-WebRequest -Uri https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.ps1 -outfile ./install-powershell.ps1
34 | ./install-powershell.ps1 -Preview -Destination $powerShellPath
35 | $vstsCommandString = "vso[task.setvariable variable=PATH]$powerShellPath;$env:PATH"
36 | Write-Host "sending " + $vstsCommandString
37 | Write-Host "##$vstsCommandString"
38 | displayName: Install PowerShell Core
39 |
40 | - task: NuGetToolInstaller@1
41 | displayName: 'Install NuGet'
42 | inputs:
43 | checkLatest: false
44 | version: 5.9.1
45 |
46 | - task: UseDotNet@2
47 | displayName: 'Install .NET Core SDK'
48 | inputs:
49 | packageType: sdk
50 | useGlobalJson: true
51 | includePreviewVersions: true
52 | workingDirectory: '$(Build.SourcesDirectory)'
53 |
54 | - pwsh: |
55 | Get-ChildItem -Path env:
56 | displayName: Capture environment for build
57 | condition: succeededOrFailed()
58 |
59 | - pwsh: |
60 | $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules'
61 | if (Test-Path -Path $modulePath) {
62 | Write-Verbose -Verbose "Deleting existing temp module path: $modulePath"
63 | Remove-Item -Path $modulePath -Recurse -Force -ErrorAction Ignore
64 | }
65 | if (! (Test-Path -Path $modulePath)) {
66 | Write-Verbose -Verbose "Creating new temp module path: $modulePath"
67 | $null = New-Item -Path $modulePath -ItemType Directory
68 | }
69 | displayName: Create temporary module path
70 |
71 | - pwsh: |
72 | $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules'
73 | Write-Verbose -Verbose "Install PowerShellGet V3 to temp module path"
74 | Save-Module -Name PowerShellGet -Path $modulePath -MinimumVersion 3.0.0-beta10 -AllowPrerelease -Force
75 | Write-Verbose -Verbose "Install PlatyPS to temp module path"
76 | Save-Module -Name "platyPS" -Path $modulePath -Force
77 | Write-Verbose -Verbose "Install PSScriptAnalyzer to temp module path"
78 | Save-Module -Name "PSScriptAnalyzer" -Path $modulePath -RequiredVersion 1.18.0 -Force
79 | Write-Verbose -Verbose "Install Pester 4.X to temp module path"
80 | Save-Module -Name "Pester" -MaximumVersion 4.99 -Path $modulePath -Force
81 | Write-Verbose -Verbose "Install PSPackageProject to temp module path"
82 | Save-Module -Name PSPackageProject -Path $modulePath -Force
83 | displayName: Install PSPackageProject and dependencies
84 |
85 | - pwsh: |
86 | $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules'
87 | $env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath
88 | $modPath = Join-Path -Path $modulePath -ChildPath PSPackageProject
89 | Write-Verbose -Verbose "Importing PSPackageProject from: $modPath"
90 | Import-Module -Name $modPath -Force
91 | #
92 | $(Build.SourcesDirectory)/build.ps1 -Build -Clean
93 | displayName: Execute build
94 |
95 | - pwsh: |
96 | $signSrcPath = "$(Build.SourcesDirectory)\out\PSDesiredStateConfiguration"
97 | # Set signing src path variable
98 | $vstsCommandString = "vso[task.setvariable variable=signSrcPath]${signSrcPath}"
99 | Write-Host "sending " + $vstsCommandString
100 | Write-Host "##$vstsCommandString"
101 | $signOutPath = "$(Build.SourcesDirectory)\signed\PSDesiredStateConfiguration"
102 | $null = New-Item -ItemType Directory -Path $signOutPath
103 | # Set signing out path variable
104 | $vstsCommandString = "vso[task.setvariable variable=signOutPath]${signOutPath}"
105 | Write-Host "sending " + $vstsCommandString
106 | Write-Host "##$vstsCommandString"
107 | # Set path variable for guardian codesign validation
108 | $vstsCommandString = "vso[task.setvariable variable=GDN_CODESIGN_TARGETDIRECTORY]${signOutPath}"
109 | Write-Host "sending " + $vstsCommandString
110 | Write-Host "##$vstsCommandString"
111 | displayName: Setup variables for signing
112 |
113 | - template: EsrpSign.yml@ComplianceRepo
114 | parameters:
115 | # the folder which contains the binaries to sign
116 | buildOutputPath: $(signSrcPath)
117 | # the location to put the signed output
118 | signOutputPath: $(signOutPath)
119 | # the certificate ID to use
120 | certificateId: "CP-230012"
121 | # the file pattern to use, comma separated
122 | pattern: '*.psm1,*.psd1,Microsoft.PowerShell.DscSubsystem.dll'
123 |
124 | - template: Sbom.yml@ComplianceRepo
125 | parameters:
126 | BuildDropPath: "$(Build.SourcesDirectory)/signed/PSDesiredStateConfiguration/PSDesiredStateConfiguration"
127 | Build_Repository_Uri: 'https://github.com/PowerShell/PSDesiredStateConfiguration'
128 | PackageName: $(PackageName)
129 | PackageVersion: $(PackageVersion)
130 |
131 | - pwsh: |
132 | $repoName = [guid]::newGuid().ToString("N")
133 | $packageRoot = "$(Build.SourcesDirectory)\signed\PSDesiredStateConfiguration"
134 | Register-PSRepository -Name $repoName -SourceLocation $packageRoot -InstallationPolicy Trusted
135 | Publish-Module -Path $packageRoot -Repository $repoName
136 | Unregister-PSRepository -Name $repoName
137 | Get-ChildItem -Recurse -Path $packageRoot | Write-Verbose -Verbose
138 | $nupkgPath = (Get-ChildItem -Recurse -Path $packageRoot -Filter "PSDesiredStateConfiguration*.nupkg" | select -First 1).FullName
139 | Write-Host "##vso[artifact.upload containerfolder=nupkg;artifactname=nupkg]$nupkgPath"
140 | displayName: Package and publish nupkg
141 | name: ProduceNupkg
142 |
143 | - publish: "$(signSrcPath)"
144 | artifact: Build
145 | displayName: Publish build
146 |
147 | - publish: "$(signOutPath)"
148 | artifact: SignedBuild
149 | displayName: Publish signed build
150 |
151 | - stage: Compliance
152 | displayName: Compliance
153 | dependsOn: Build
154 | jobs:
155 | - job: Compliance_Job
156 | pool:
157 | name: 1ES
158 | demands:
159 | - ImageOverride -equals MMS2019
160 | steps:
161 | - checkout: self
162 | - checkout: ComplianceRepo
163 | - download: current
164 | artifact: SignedBuild
165 |
166 | - pwsh: |
167 | Get-ChildItem -Path "$(Pipeline.Workspace)\SignedBuild" -Recurse
168 | displayName: Capture downloaded artifacts
169 | - template: script-module-compliance.yml@ComplianceRepo
170 | parameters:
171 | # component-governance
172 | sourceScanPath: '$(Pipeline.Workspace)\SignedBuild'
173 | # credscan
174 | suppressionsFile: ''
175 | # TermCheck
176 | optionsRulesDBPath: ''
177 | optionsFTPath: ''
178 | # tsa-upload
179 | codeBaseName: 'PSDesiredStateConfiguration_20210423'
180 | # selections
181 | APIScan: false # set to false when not using Windows APIs.
182 |
183 | - stage: Deploy
184 | displayName: Publish to PowerShell gallery
185 | dependsOn:
186 | - Build
187 | - Compliance
188 | jobs:
189 | - deployment: DeployPowerShellGallery
190 | displayName: Deploy nupkg to PowerShell Gallery
191 | pool:
192 | name: 1ES
193 | demands:
194 | - ImageOverride -equals MMS2019
195 | environment: 'PSDesiredStateConfiguration-ReleaseApproval'
196 | strategy:
197 | runOnce:
198 | deploy:
199 | steps:
200 | - download: current
201 | artifact: 'nupkg'
202 | - task: NuGetToolInstaller@1
203 | displayName: 'Install NuGet'
204 | inputs:
205 | checkLatest: false
206 | version: 5.9.1
207 | - task: NuGetCommand@2
208 | displayName: 'NuGet push'
209 | inputs:
210 | command: push
211 | packagesToPush: '$(Pipeline.Workspace)\nupkg\PSDesiredStateConfiguration.*.nupkg'
212 | nuGetFeedType: external
213 | publishFeedCredentials: 'PowerShellGallery'
214 |
--------------------------------------------------------------------------------
/.vsts-ci/templates/ci-test.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | jobName: TestPkgWin
3 | imageName: windows-2019
4 | displayName: PowerShell Core on Windows
5 | powershellExecutable: pwsh
6 |
7 | jobs:
8 | - job: ${{ parameters.jobName }}
9 | pool:
10 | vmImage: ${{ parameters.imageName }}
11 | displayName: ${{ parameters.displayName }}
12 | steps:
13 | - powershell: |
14 | $powerShellPath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'powershell'
15 | Invoke-WebRequest -Uri https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.ps1 -outfile ./install-powershell.ps1
16 | ./install-powershell.ps1 -Preview -Destination $powerShellPath
17 | $newPath = $powerShellPath + [System.IO.Path]::PathSeparator + $env:PATH
18 | $vstsCommandString = "vso[task.setvariable variable=PATH]$newPath"
19 | Write-Host "sending " + $vstsCommandString
20 | Write-Host "##$vstsCommandString"
21 | displayName: Install PowerShell Core
22 |
23 | - pwsh: |
24 | $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules'
25 | if (Test-Path -Path $modulePath) {
26 | Write-Verbose -Verbose "Deleting existing temp module path: $modulePath"
27 | Remove-Item -Path $modulePath -Recurse -Force -ErrorAction Ignore
28 | }
29 | if (! (Test-Path -Path $modulePath)) {
30 | Write-Verbose -Verbose "Creating new temp module path: $modulePath"
31 | $null = New-Item -Path $modulePath -ItemType Directory
32 | }
33 | displayName: Create temporary module path
34 |
35 | - pwsh: |
36 | $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules'
37 | Write-Verbose -Verbose "Install PowerShellGet V3 to temp module path"
38 | Save-Module -Name PowerShellGet -Path $modulePath -MinimumVersion 3.0.0-beta10 -AllowPrerelease -Force
39 | Write-Verbose -Verbose "Install PlatyPS to temp module path"
40 | Save-Module -Name "platyPS" -Path $modulePath -Force
41 | Write-Verbose -Verbose "Install PSScriptAnalyzer to temp module path"
42 | Save-Module -Name "PSScriptAnalyzer" -Path $modulePath -RequiredVersion 1.18.0 -Force
43 | Write-Verbose -Verbose "Install Pester 4.X to temp module path"
44 | Save-Module -Name "Pester" -MaximumVersion 4.99 -Path $modulePath -Force
45 | Write-Verbose -Verbose "Install PSPackageProject to temp module path"
46 | Save-Module -Name PSPackageProject -Path $modulePath -Force
47 | #
48 | $vstsCommandString = "vso[task.setvariable variable=modulePath]${modulePath}"
49 | Write-Host "sending " + $vstsCommandString
50 | Write-Host "##$vstsCommandString"
51 | displayName: Install PSPackageProject and dependencies
52 |
53 | - download: current
54 | artifact: Build
55 |
56 | - pwsh: |
57 | "PSVersionTable is"| Write-Verbose -Verbose
58 | $PSVersionTable | Out-String | Write-Verbose -Verbose
59 | #
60 | $targetModuleLocation = Join-Path -Path $(modulePath) -ChildPath 'PSDesiredStateConfiguration'
61 | Move-Item -Path "$(Pipeline.Workspace)\Build" -Destination $targetModuleLocation -Force
62 | #
63 | $env:PSModulePath = '$(modulePath)' + [System.IO.Path]::PathSeparator + $env:PSModulePath
64 | "PSModulePath is"| Write-Verbose -Verbose
65 | $env:PSModulePath | Write-Verbose -Verbose
66 | #
67 | Get-Module -ListAvailable -Name PSDesiredStateConfiguration | select Name,Version,PreRelease,Path | Write-Verbose -Verbose
68 | #
69 | "Listing contents of $targetModuleLocation"| Write-Verbose -Verbose
70 | Get-ChildItem -Recurse -Path $targetModuleLocation | Write-Verbose -Verbose
71 | #
72 | Invoke-PSPackageProjectTest -Type Functional
73 | displayName: Execute functional tests
74 | errorActionPreference: continue
75 |
--------------------------------------------------------------------------------
/CHANGELOG/README.md:
--------------------------------------------------------------------------------
1 | # Changelogs
2 |
3 | * [v2 changelog](v2.md)
4 |
--------------------------------------------------------------------------------
/CHANGELOG/v2.md:
--------------------------------------------------------------------------------
1 | # v2 Changelog
2 |
3 | ## [v2.0.7]
4 |
5 | ### Main changes
6 |
7 | - Fixed Invoke-DscResource error when a class-based resource module path contains a space.
8 |
9 | [v2.0.7]: https://www.powershellgallery.com/packages/PSDesiredStateConfiguration/2.0.7
10 |
11 | ## [v2.0.6]
12 |
13 | ### Main changes
14 |
15 | - Fixed `PathSeparator` bug in Get-DSCResourceModules.
16 | - Changed `PSDesiredStateConfiguration.InvokeDscResource` from experimental to permanently enabled feature.
17 | - Changed `ErrorAction` to `Ignore` so that the error doesn't show up in `$Error`.
18 | - Removed duplicate result resources from `Get-DSCResourcesModules`.
19 | - Add `ImplementationDetail` member to results only when the member does not already exist.
20 | - Updated v2 Release pipeline with latest Compliance requirements.
21 | - Added SBOM generation that is now released with v2 module.
22 |
23 | [v2.0.6]: https://www.powershellgallery.com/packages/PSDesiredStateConfiguration/2.0.6
24 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 PowerShell Team
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # PSDesiredStateConfiguration module
2 |
3 | > [!NOTE]
4 | > The next generation of this platform is in development. Please submit your feedback on [DSC v3](https://github.com/powershell/dsc).
5 |
6 | **PSDesiredStateConfiguration** (DSC) is the PowerShell module that enables writing configuration as code.
7 |
8 | The DSC platform was originally built on top of WMI for Windows. Starting in PowerShell 7.1 and working
9 | with internal partner teams
10 | [Azure Guest Configuration](https://docs.microsoft.com/azure/governance/policy/concepts/guest-configuration)
11 | and [Automanage](https://azure.microsoft.com/services/azure-automanage), we started making
12 | DSC cross-platform by enabling `Invoke-DSCResource` to directly use resources without going through
13 | the Local Configuration Manager (LCM).
14 |
15 | Our initial cross-platform work to enable partner teams:
16 |
17 | - Separated out the DSC parts in the PowerShell engine and moved them as a subsystem into the
18 | PSDesiredStateConfiguration module
19 | - Remove PSDesiredStateConfiguration module from the PowerShell 7 package. This allows the
20 | PSDesiredStateConfiguration module to be developed independently of PowerShell and users can mix
21 | and match versions of PowerShell and PSDesiredStateConfiguration for their environment.
22 | - This is now available on the PowerShell Gallery: [PSDesiredStateConfiguration 2.x](https://www.powershellgallery.com/packages/PSDesiredStateConfiguration)
23 | - Removing the dependency on MOF: Initially, only support DSC Resources written as PowerShell
24 | classes. This includes tooling to convert existing script based DSC Resources to be wrapped as
25 | PowerShell classes.
26 |
27 | ## Documentation and resources
28 |
29 | The documentation for **PSDesiredStateConfiguration** 3.0.0-beta1 is a work-in-progress. We invite the
30 | community to review the documentation and assist us as we work on new documentation during the platform
31 | development.
32 |
33 | For more information about DSC v3, see [PowerShell Desired State Configuration Overview](https://docs.microsoft.com/powershell/dsc/overview?view=dsc-3.0)
34 |
35 | 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)
36 |
37 | ## Community Feedback
38 |
39 | As we continue this journey to make DSC a cross-platform technology, we invite the community to
40 | share your ideas and open
41 | [issues](https://github.com/PowerShell/PSDesiredStateConfiguration/issues). During the PowerShell
42 | 7.3 timeframe, we remain focused on enabling partner teams and will not be accepting public pull
43 | requests.
44 |
45 | ## Build
46 |
47 | ### Requirements
48 | - [Any recent PowerShell Core release](https://github.com/PowerShell/powershell/releases) to run the build script
49 | - [.NET Core SDK](https://dotnet.microsoft.com/download/dotnet/thank-you/sdk-6.0.100-preview.4-windows-x64-binaries) of the version specified in `global.json` (`dotnet` should be visible through PATH env var)
50 | - [`PSPackageProject` module](https://www.powershellgallery.com/packages/PSPackageProject) installed from PS Gallery
51 |
52 | ### Build Process
53 | - Run `build.ps1 -Build -Clean`
54 | - Compiled module will be in `./out/PSDesiredStateConfiguration`
55 |
56 | ## CI - Continuous Integration
57 | CI pipeline definition is in `.vsts-ci\azure-pipelines-ci.yml` and running Compliance and Pester tests in `test\PSDesiredStateConfiguration.Tests.ps1` on Windows, Linux and Mac. CI builds are not signed.
58 |
59 | ## Publishing Releases
60 | [The module is released on Powershell Gallery](https://www.powershellgallery.com/packages/PSDesiredStateConfiguration).
61 | 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.
62 |
63 | ## Code of Conduct
64 |
65 | Please see our [Code of Conduct](.github/CODE_OF_CONDUCT.md) before participating in this project.
66 |
67 | ## Security Policy
68 |
69 | For any security issues, please see our [Security Policy](.github/SECURITY.md).
70 |
--------------------------------------------------------------------------------
/build.ps1:
--------------------------------------------------------------------------------
1 | # Copyright (c) Microsoft Corporation. All rights reserved.
2 | # Licensed under the MIT License.
3 |
4 | # Do NOT edit this file. Edit dobuild.ps1
5 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingWriteHost", "")]
6 | param (
7 | [Parameter(ParameterSetName="build")]
8 | [switch]
9 | $Clean,
10 |
11 | [Parameter(ParameterSetName="build")]
12 | [switch]
13 | $Build,
14 |
15 | [Parameter(ParameterSetName="publish")]
16 | [switch]
17 | $Publish,
18 | [Parameter(ParameterSetName="publish")]
19 | [switch]
20 | $Signed,
21 |
22 | [Parameter(ParameterSetName="build")]
23 | [switch]
24 | $Test,
25 |
26 | [Parameter(ParameterSetName="build")]
27 | [string[]]
28 | [ValidateSet("Functional","StaticAnalysis")]
29 | $TestType = @("Functional"),
30 |
31 | [Parameter(ParameterSetName="help")]
32 | [switch]
33 | $UpdateHelp,
34 |
35 | [Parameter(ParameterSetName="build")]
36 | [switch]
37 | $TestInvokeDscResource
38 | )
39 |
40 | $config = Get-PSPackageProjectConfiguration -ConfigPath $PSScriptRoot
41 |
42 | $script:ModuleName = $config.ModuleName
43 | $script:SrcPath = $config.SourcePath
44 | $script:OutDirectory = $config.BuildOutputPath
45 | $script:SignedDirectory = $config.SignedOutputPath
46 | $script:TestPath = $config.TestPath
47 |
48 | $script:ModuleRoot = $PSScriptRoot
49 | $script:Culture = $config.Culture
50 | $script:HelpPath = $config.HelpPath
51 |
52 | if ($env:TF_BUILD) {
53 | $vstsCommandString = "vso[task.setvariable variable=BUILD_OUTPUT_PATH]$OutDirectory"
54 | Write-Host ("sending " + $vstsCommandString)
55 | Write-Host "##$vstsCommandString"
56 |
57 | $vstsCommandString = "vso[task.setvariable variable=SIGNED_OUTPUT_PATH]$SignedDirectory"
58 | Write-Host ("sending " + $vstsCommandString)
59 | Write-Host "##$vstsCommandString"
60 | }
61 |
62 | . $PSScriptRoot\dobuild.ps1
63 |
64 | if ( ! ( Get-Module -ErrorAction SilentlyContinue PSPackageProject) ) {
65 | Install-Module PSPackageProject
66 | }
67 |
68 | if ($Clean -and (Test-Path $OutDirectory))
69 | {
70 | Remove-Item -Force -Recurse $OutDirectory -ErrorAction Stop -Verbose
71 | }
72 |
73 | if (-not (Test-Path $OutDirectory))
74 | {
75 | $script:OutModule = New-Item -ItemType Directory -Path (Join-Path $OutDirectory $ModuleName)
76 | }
77 | else
78 | {
79 | $script:OutModule = Join-Path $OutDirectory $ModuleName
80 | }
81 |
82 | if ($Build.IsPresent)
83 | {
84 | $sb = (Get-Item Function:DoBuild).ScriptBlock
85 | Invoke-PSPackageProjectBuild -BuildScript $sb -SkipPublish
86 | }
87 |
88 | if ($Publish.IsPresent)
89 | {
90 | Invoke-PSPackageProjectPublish -Signed:$Signed.IsPresent
91 | }
92 |
93 | if ( $TestInvokeDscResource.IsPresent ) {
94 | $backupName = $null
95 | try {
96 | $configFolder = split-path $PROFILE
97 | $configPath = Join-Path $configFolder -ChildPath powershell.config.json
98 | if(Test-Path ~/.config/powershell/powershell.config.json)
99 | {
100 | $backupName = Join-Path $configFolder -ChildPath "powershell.config-((Get-Date).ToString('yyyyMMddHHmm')).json"
101 | Copy-Item $configPath $backupName -force
102 | }
103 |
104 | copy-Item $PSScriptRoot/assets/powershell.config.json $configPath
105 | Invoke-PSPackageProjectTest -Type $TestType
106 | }
107 | finally {
108 | remove-item $configPath
109 | if($backupName)
110 | {
111 | Copy-Item $backupName $configPath -force
112 | }
113 | }
114 | }
115 |
116 | if ( $Test.IsPresent ) {
117 | Invoke-PSPackageProjectTest -Type $TestType
118 | }
119 |
120 | if ($UpdateHelp.IsPresent) {
121 | Add-PSPackageProjectCmdletHelp -ProjectRoot $ModuleRoot -ModuleName $ModuleName -Culture $Culture
122 | }
123 |
--------------------------------------------------------------------------------
/dobuild.ps1:
--------------------------------------------------------------------------------
1 | # Copyright (c) Microsoft Corporation. All rights reserved.
2 | # Licensed under the MIT License.
3 |
4 | #####################################################
5 | # Do NOT edit anything outside the DoBuild function.
6 | # You can define functions inside the scope of DoBuild.
7 | #####################################################
8 |
9 | <#
10 | .DESCRIPTION
11 | Implement build and packaging of the package and place the output $OutDirectory/$ModuleName
12 | #>
13 | function DoBuild
14 | {
15 | Write-Verbose -Verbose -Message "Starting DoBuild"
16 | Write-Verbose -Verbose -Message "Make sure that 'nuget' and 'dotnet' are visible through PATH"
17 |
18 | Write-Verbose -Verbose -Message "Copying module files to '${OutDirectory}/${ModuleName}'"
19 | # copy psm1 and psd1 files
20 | copy-item "${SrcPath}/*" "${OutDirectory}/${ModuleName}" -Recurse
21 |
22 | $smaPackageVersionToUse = "7.2.0-preview.6" # 7.2.0-preview.6 - is the first SMA version that has DSC subsystem changes
23 | $subsystemCodePath = Resolve-Path "${SrcPath}/../DscSubsystem"
24 | Write-Verbose -Verbose -Message "Subsystem code path ${subsystemCodePath}"
25 |
26 | if ( Test-Path $subsystemCodePath )
27 | {
28 | Write-Verbose -Verbose -Message "Building assembly and copying to '${OutDirectory}/${ModuleName}'"
29 |
30 | Push-Location $subsystemCodePath
31 |
32 | $PackageReferencesPath = Join-Path $subsystemCodePath "PackageReferences"
33 |
34 | nuget install System.Management.Automation -OutputDirectory ./PackageReferences -PreRelease -Version $smaPackageVersionToUse -DependencyVersion Ignore -ExcludeVersion
35 | dotnet publish
36 |
37 | $subsystemBinPath = Join-Path (Get-ChildItem -Recurse "publish" -Directory) "Microsoft.PowerShell.DscSubsystem.dll"
38 | if (Test-Path $subsystemBinPath)
39 | {
40 | Copy-Item $subsystemBinPath "${OutDirectory}/${ModuleName}"
41 | }
42 | else
43 | {
44 | Write-Error -Message "dotnet build failed - $subsystemBinPath not found"
45 | }
46 |
47 | Pop-Location
48 | }
49 | else {
50 | Write-Error -Message "No code to build in '$subsystemCodePath'"
51 | }
52 |
53 | Write-Verbose -Verbose -Message "Ending DoBuild"
54 | }
55 |
--------------------------------------------------------------------------------
/global.json:
--------------------------------------------------------------------------------
1 | {
2 | "sdk": {
3 | "version": "6.0.100-preview.4.21255.9"
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/help/en-US/about_PSDesiredStateConfiguration.md:
--------------------------------------------------------------------------------
1 | # PSDesiredStateConfiguration
2 | ## about_PSDesiredStateConfiguration
3 |
4 | ```
5 | ABOUT TOPIC NOTE:
6 | The first header of the about topic should be the topic name.
7 | The second header contains the lookup name used by the help system.
8 |
9 | IE:
10 | # Some Help Topic Name
11 | ## SomeHelpTopicFileName
12 |
13 | This will be transformed into the text file
14 | as `about_SomeHelpTopicFileName`.
15 | Do not include file extensions.
16 | The second header should have no spaces.
17 | ```
18 |
19 | # SHORT DESCRIPTION
20 | {{ Short Description Placeholder }}
21 |
22 | ```
23 | ABOUT TOPIC NOTE:
24 | About topics can be no longer than 80 characters wide when rendered to text.
25 | Any topics greater than 80 characters will be automatically wrapped.
26 | The generated about topic will be encoded UTF-8.
27 | ```
28 |
29 | # LONG DESCRIPTION
30 | {{ Long Description Placeholder }}
31 |
32 | ## Optional Subtopics
33 | {{ Optional Subtopic Placeholder }}
34 |
35 | # EXAMPLES
36 | {{ Code or descriptive examples of how to leverage the functions described. }}
37 |
38 | # NOTE
39 | {{ Note Placeholder - Additional information that a user needs to know.}}
40 |
41 | # TROUBLESHOOTING NOTE
42 | {{ Troubleshooting Placeholder - Warns users of bugs}}
43 |
44 | {{ Explains behavior that is likely to change with fixes }}
45 |
46 | # SEE ALSO
47 | {{ See also placeholder }}
48 |
49 | {{ You can also list related articles, blogs, and video URLs. }}
50 |
51 | # KEYWORDS
52 | {{List alternate names or titles for this topic that readers might use.}}
53 |
54 | - {{ Keyword Placeholder }}
55 | - {{ Keyword Placeholder }}
56 | - {{ Keyword Placeholder }}
57 | - {{ Keyword Placeholder }}
58 |
--------------------------------------------------------------------------------
/nuget.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/pspackageproject.json:
--------------------------------------------------------------------------------
1 | {
2 | "HelpPath": "help",
3 | "ModuleName": "PSDesiredStateConfiguration",
4 | "BuildOutputPath": "out",
5 | "SignedOutputPath": "signed",
6 | "SourcePath": "src/PSDesiredStateConfiguration",
7 | "TestPath": "test",
8 | "Culture": "en-US"
9 | }
10 |
--------------------------------------------------------------------------------
/src/DscSubsystem/CrossPlatformDsc.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | #nullable enable
5 |
6 | using System;
7 | using System.Collections.ObjectModel;
8 | using System.Collections.Generic;
9 | using System.Management.Automation;
10 | using System.Management.Automation.Internal;
11 | using System.Management.Automation.Language;
12 |
13 | namespace System.Management.Automation.Subsystem.DSC
14 | {
15 | ///
16 | /// Interface for implementing a cross platform desired state configuration component.
17 | ///
18 | public class CrossPlatformDsc : ICrossPlatformDsc, IModuleAssemblyInitializer
19 | {
20 | ///
21 | /// Gets the unique identifier for a subsystem implementation.
22 | ///
23 | public Guid Id { get {return Guid.NewGuid();} }
24 |
25 | ///
26 | /// Gets the name of a subsystem implementation.
27 | ///
28 | public string Name { get {return "Cross platform desired state configuration";} }
29 |
30 | ///
31 | /// Gets the description of a subsystem implementation.
32 | ///
33 | public string Description { get {return "Cross platform desired state configuration";} }
34 |
35 | ///
36 | /// Gets a dictionary that contains the functions to be defined at the global scope of a PowerShell session.
37 | /// Key: function name; Value: function script.
38 | ///
39 | Dictionary? ISubsystem.FunctionsToDefine => null;
40 |
41 | ///
42 | /// Test.
43 | ///
44 | public void LoadDefaultKeywords(Collection errors)
45 | {
46 | Microsoft.PowerShell.DesiredStateConfiguration.Internal.CrossPlatform.DscClassCache.LoadDefaultCimKeywords(errors);
47 | }
48 |
49 | ///
50 | /// Default summary.
51 | ///
52 | public void ClearCache()
53 | {
54 | Microsoft.PowerShell.DesiredStateConfiguration.Internal.CrossPlatform.DscClassCache.ClearCache();
55 | }
56 |
57 | ///
58 | /// Default summary.
59 | ///
60 | public string GetDSCResourceUsageString(DynamicKeyword keyword)
61 | {
62 | return Microsoft.PowerShell.DesiredStateConfiguration.Internal.CrossPlatform.DscClassCache.GetDSCResourceUsageString(keyword);
63 | }
64 |
65 | ///
66 | /// Checks if a string is one of dynamic keywords that can be used in both configuration and meta configuration.
67 | ///
68 | public bool IsSystemResourceName(string name)
69 | {
70 | return Microsoft.PowerShell.DesiredStateConfiguration.Internal.CrossPlatform.DscClassCache.SystemResourceNames.Contains(name);
71 | }
72 |
73 | ///
74 | /// Checks if a string matches default module name used for meta configuration resources.
75 | ///
76 | public bool IsDefaultModuleNameForMetaConfigResource(string name)
77 | {
78 | return name.Equals(Microsoft.PowerShell.DesiredStateConfiguration.Internal.CrossPlatform.DscClassCache.DefaultModuleInfoForMetaConfigResource.Item1, StringComparison.OrdinalIgnoreCase);
79 | }
80 |
81 | public void OnImport()
82 | {
83 | if (SubsystemManager.GetSubsystem() == null)
84 | {
85 | SubsystemManager.RegisterSubsystem(SubsystemKind.CrossPlatformDsc, this);
86 | }
87 | }
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/src/DscSubsystem/JsonCimDSCParser.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using System;
5 | using System.Collections;
6 | using System.Collections.Generic;
7 | using System.Diagnostics.CodeAnalysis;
8 | using System.Globalization;
9 | using System.IO;
10 | using System.Management.Automation;
11 | using System.Security;
12 |
13 | namespace Microsoft.PowerShell.DesiredStateConfiguration.Internal.CrossPlatform
14 | {
15 | ///
16 | /// Class that does high level Cim schema parsing.
17 | ///
18 | internal class CimDSCParser
19 | {
20 | private readonly JsonDeserializer _jsonDeserializer;
21 |
22 | internal CimDSCParser()
23 | {
24 | _jsonDeserializer = JsonDeserializer.Create();
25 | }
26 |
27 | internal IEnumerable ParseSchemaJson(string filePath, bool useNewRunspace = false)
28 | {
29 | try
30 | {
31 | string json = File.ReadAllText(filePath);
32 | string fileNameDefiningClass = Path.GetFileNameWithoutExtension(filePath);
33 | int dotIndex = fileNameDefiningClass.IndexOf(".schema", StringComparison.InvariantCultureIgnoreCase);
34 | if (dotIndex != -1)
35 | {
36 | fileNameDefiningClass = fileNameDefiningClass.Substring(0, dotIndex);
37 | }
38 |
39 | IEnumerable result = _jsonDeserializer.DeserializeClasses(json, useNewRunspace);
40 | foreach (dynamic classObject in result)
41 | {
42 | string superClassName = classObject.SuperClassName;
43 | string className = classObject.ClassName;
44 | if (string.Equals(superClassName, "OMI_BaseResource", StringComparison.OrdinalIgnoreCase))
45 | {
46 | // Get the name of the file without schema.mof/json extension
47 | if (!className.Equals(fileNameDefiningClass, StringComparison.OrdinalIgnoreCase))
48 | {
49 | PSInvalidOperationException e = PSTraceSource.NewInvalidOperationException(
50 | ParserStrings.ClassNameNotSameAsDefiningFile, className, fileNameDefiningClass);
51 | throw e;
52 | }
53 | }
54 | }
55 |
56 | return result;
57 | }
58 | catch (Exception exception)
59 | {
60 | PSInvalidOperationException e = PSTraceSource.NewInvalidOperationException(
61 | exception, ParserStrings.CimDeserializationError, filePath);
62 |
63 | e.SetErrorId("CimDeserializationError");
64 | throw e;
65 | }
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/DscSubsystem/JsonDeserializer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | using System;
5 | using System.Collections;
6 | using System.Collections.Generic;
7 | using System.Management.Automation;
8 | using System.Management.Automation.Runspaces;
9 |
10 | namespace Microsoft.PowerShell.DesiredStateConfiguration.Internal.CrossPlatform
11 | {
12 | internal class JsonDeserializer
13 | {
14 | #region Constructors
15 |
16 | ///
17 | /// Instantiates a default deserializer.
18 | ///
19 | /// Default deserializer.
20 | public static JsonDeserializer Create()
21 | {
22 | return new JsonDeserializer();
23 | }
24 |
25 | #endregion Constructors
26 |
27 | #region Methods
28 |
29 | ///
30 | /// Returns schema of Cim classes from specified json file.
31 | ///
32 | /// Json text to deserialize.
33 | /// If a new runspace should be used.
34 | /// Deserialized PSObjects.
35 | public IEnumerable DeserializeClasses(string json, bool useNewRunspace = false)
36 | {
37 | if (string.IsNullOrEmpty(json))
38 | {
39 | throw new ArgumentNullException(nameof(json));
40 | }
41 |
42 | System.Management.Automation.PowerShell powerShell = null;
43 |
44 | if (useNewRunspace)
45 | {
46 | // currently using RunspaceMode.NewRunspace will reset PSModulePath env var for the entire process
47 | // this is something we want to avoid in DSC GuestConfigAgent scenario, so we use following workaround
48 | var s_iss = InitialSessionState.CreateDefault();
49 | s_iss.EnvironmentVariables.Add(
50 | new SessionStateVariableEntry(
51 | "PSModulePath",
52 | Environment.GetEnvironmentVariable("PSModulePath"),
53 | description: null));
54 | powerShell = System.Management.Automation.PowerShell.Create(s_iss);
55 | }
56 | else
57 | {
58 | powerShell = System.Management.Automation.PowerShell.Create(RunspaceMode.CurrentRunspace);
59 | }
60 |
61 | using (powerShell)
62 | {
63 | return powerShell.AddCommand("Microsoft.PowerShell.Utility\\ConvertFrom-Json")
64 | .AddParameter("InputObject", json)
65 | .AddParameter("Depth", 100) // maximum supported by cmdlet
66 | .Invoke();
67 | }
68 | }
69 |
70 | #endregion Methods
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/src/DscSubsystem/Microsoft.PowerShell.DscSubsystem.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | net6.0
6 | AnyCPU
7 | Microsoft.PowerShell.DscSubsystem
8 |
9 | true
10 | visualstudiopublic.snk
11 | true
12 |
13 |
14 |
15 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/DscSubsystem/visualstudiopublic.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerShell/PSDesiredStateConfiguration/c26e6b79d07c5c18184d248b5bf935471fac929d/src/DscSubsystem/visualstudiopublic.snk
--------------------------------------------------------------------------------
/src/PSDesiredStateConfiguration/Configuration/BaseRegistration/BaseResource.schema.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "ClassName": "MSFT_Credential",
4 | "ClassVersion": "1.0.0",
5 | "ClassProperties": [
6 | {
7 | "Name": "UserName",
8 | "CimType": "String",
9 | "Qualifiers": {
10 | "MaxLen": 256
11 | }
12 | },
13 | {
14 | "Name": "Password",
15 | "CimType": "String"
16 | }
17 | ]
18 | },
19 | {
20 | "ClassName": "OMI_BaseResource",
21 | "ClassVersion": "1.0.0",
22 | "ClassProperties": [
23 | {
24 | "Name": "ResourceId",
25 | "CimType": "String",
26 | "Qualifiers": {
27 | "Required": true
28 | }
29 | },
30 | {
31 | "Name": "SourceInfo",
32 | "CimType": "String",
33 | "Qualifiers": {
34 | "Write": true
35 | }
36 | },
37 | {
38 | "Name": "DependsOn",
39 | "CimType": "StringArray",
40 | "Qualifiers": {
41 | "Write": true
42 | }
43 | },
44 | {
45 | "Name": "ModuleName",
46 | "CimType": "String",
47 | "Qualifiers": {
48 | "Required": true
49 | }
50 | },
51 | {
52 | "Name": "ModuleVersion",
53 | "CimType": "String",
54 | "Qualifiers": {
55 | "Required": true
56 | }
57 | },
58 | {
59 | "Name": "ConfigurationName",
60 | "CimType": "String",
61 | "Qualifiers": {
62 | "Write": true
63 | }
64 | },
65 | {
66 | "Name": "PsDscRunAsCredential",
67 | "CimType": "Instance",
68 | "ReferenceClassName": "MSFT_Credential",
69 | "Qualifiers": {
70 | "Write": true,
71 | "EmbeddedInstance": "MSFT_Credential"
72 | }
73 | }
74 | ]
75 | },
76 | {
77 | "ClassName": "MSFT_KeyValuePair",
78 | "ClassVersion": "1.0.0",
79 | "ClassProperties": [
80 | {
81 | "Name": "Key",
82 | "CimType": "String",
83 | "Qualifiers": {
84 | "Key": true
85 | }
86 | },
87 | {
88 | "Name": "Value",
89 | "CimType": "String",
90 | "Qualifiers": {
91 | "Write": true
92 | }
93 | }
94 | ]
95 | },
96 | {
97 | "ClassName": "MSFT_BaseConfigurationProviderRegistration",
98 | "ClassVersion": "1.0.0",
99 | "ClassProperties": [
100 | {
101 | "Name": "ClassName",
102 | "CimType": "String",
103 | "Qualifiers": {
104 | "Key": true
105 | }
106 | },
107 | {
108 | "Name": "DSCEngineCompatVersion",
109 | "CimType": "String"
110 | },
111 | {
112 | "Name": "DSCModuleVersion",
113 | "CimType": "String"
114 | }
115 | ]
116 | },
117 | {
118 | "ClassName": "MSFT_CimConfigurationProviderRegistration",
119 | "ClassVersion": "1.0.0",
120 | "SuperClassName": "MSFT_BaseConfigurationProviderRegistration",
121 | "ClassProperties": [
122 | {
123 | "Name": "Namespace",
124 | "CimType": "String"
125 | }
126 | ]
127 | },
128 | {
129 | "ClassName": "MSFT_PSConfigurationProviderRegistration",
130 | "ClassVersion": "1.0.0",
131 | "SuperClassName": "MSFT_BaseConfigurationProviderRegistration",
132 | "ClassProperties": [
133 | {
134 | "Name": "ModuleName",
135 | "CimType": "String"
136 | },
137 | {
138 | "Name": "ProviderPath",
139 | "CimType": "String"
140 | },
141 | {
142 | "Name": "ModulePath",
143 | "CimType": "String"
144 | }
145 | ]
146 | },
147 | {
148 | "ClassName": "OMI_ConfigurationDocument",
149 | "ClassVersion": "1.0.0",
150 | "ClassProperties": [
151 | {
152 | "Name": "Version",
153 | "CimType": "String"
154 | },
155 | {
156 | "Name": "Author",
157 | "CimType": "String"
158 | },
159 | {
160 | "Name": "Copyright",
161 | "CimType": "String"
162 | },
163 | {
164 | "Name": "HelpInfoUri",
165 | "CimType": "String"
166 | },
167 | {
168 | "Name": "ContentType",
169 | "CimType": "String"
170 | },
171 | {
172 | "Name": "GenerationDate",
173 | "CimType": "String"
174 | },
175 | {
176 | "Name": "GenerationHost",
177 | "CimType": "String"
178 | },
179 | {
180 | "Name": "Name",
181 | "CimType": "String"
182 | },
183 | {
184 | "Name": "MinimumCompatibleVersion",
185 | "CimType": "String"
186 | },
187 | {
188 | "Name": "CompatibleVersionAdditionalProperties",
189 | "CimType": "StringArray"
190 | },
191 | {
192 | "Name": "UseCms",
193 | "CimType": "Boolean"
194 | }
195 | ]
196 | },
197 | {
198 | "ClassName": "OMI_MetaConfigurationResource",
199 | "ClassVersion": "1.0.0",
200 | "ClassProperties": [
201 | {
202 | "Name": "ResourceId",
203 | "CimType": "String",
204 | "Qualifiers": {
205 | "Required": true
206 | }
207 | },
208 | {
209 | "Name": "SourceInfo",
210 | "CimType": "String",
211 | "Qualifiers": {
212 | "Write": true
213 | }
214 | }
215 | ]
216 | },
217 | {
218 | "ClassName": "OMI_ResourceModuleManager",
219 | "ClassVersion": "1.0.0",
220 | "SuperClassName": "OMI_MetaConfigurationResource"
221 | },
222 | {
223 | "ClassName": "OMI_ConfigurationDownloadManager",
224 | "ClassVersion": "1.0.0",
225 | "SuperClassName": "OMI_MetaConfigurationResource"
226 | },
227 | {
228 | "ClassName": "OMI_ReportManager",
229 | "ClassVersion": "1.0.0",
230 | "SuperClassName": "OMI_MetaConfigurationResource"
231 | }
232 | ]
233 |
--------------------------------------------------------------------------------
/src/PSDesiredStateConfiguration/Configuration/BaseRegistration/BaseResource.schema.mof:
--------------------------------------------------------------------------------
1 | [ClassVersion("1.0.0")]
2 | class MSFT_Credential
3 | {
4 | [MaxLen ( 256 )]
5 | string UserName;
6 | string Password;
7 | };
8 |
9 | [Abstract, ClassVersion("1.0.0")]
10 | class OMI_BaseResource
11 | {
12 | [required] string ResourceId;
13 | [write] string SourceInfo;
14 | [write] string DependsOn[];
15 | [required] string ModuleName;
16 | [required] string ModuleVersion;
17 | [write] string ConfigurationName;
18 | [write, EmbeddedInstance("MSFT_Credential")] string PsDscRunAsCredential;
19 | };
20 |
21 | [Abstract, ClassVersion("1.0.0")]
22 | class MSFT_KeyValuePair
23 | {
24 | [Key]
25 | string Key;
26 |
27 | [write]
28 | string Value;
29 | };
30 |
31 | [Abstract, ClassVersion("1.0.0")]
32 | class MSFT_BaseConfigurationProviderRegistration
33 | {
34 | [key] String ClassName;
35 | String DSCEngineCompatVersion;
36 | String DSCModuleVersion;
37 | };
38 |
39 | [ClassVersion("1.0.0")]
40 | class MSFT_CimConfigurationProviderRegistration : MSFT_BaseConfigurationProviderRegistration
41 | {
42 | String Namespace;
43 | };
44 |
45 | [ClassVersion("1.0.0")]
46 | class MSFT_PSConfigurationProviderRegistration : MSFT_BaseConfigurationProviderRegistration
47 | {
48 | String ModuleName;
49 | String ProviderPath;
50 | String ModulePath;
51 | };
52 |
53 | [ClassVersion("1.0.0")]
54 | class OMI_ConfigurationDocument
55 | {
56 | String Version;
57 | String Author;
58 | String Copyright;
59 | String HelpInfoUri;
60 | String ContentType;
61 | String GenerationDate;
62 | String GenerationHost;
63 | String Name;
64 | String MinimumCompatibleVersion;
65 | String CompatibleVersionAdditionalProperties[];
66 | boolean UseCms;
67 | };
68 |
69 | [Abstract,ClassVersion("1.0.0")]
70 | class OMI_MetaConfigurationResource
71 | {
72 | [required] string ResourceId;
73 | [write] string SourceInfo;
74 | };
75 |
76 | [Abstract,ClassVersion("1.0.0")]
77 | class OMI_ResourceModuleManager : OMI_MetaConfigurationResource
78 | {
79 | };
80 |
81 | [Abstract,ClassVersion("1.0.0")]
82 | class OMI_ConfigurationDownloadManager : OMI_MetaConfigurationResource
83 | {
84 | };
85 |
86 |
87 | [Abstract,ClassVersion("1.0.0")]
88 | class OMI_ReportManager : OMI_MetaConfigurationResource
89 | {
90 | };
91 |
--------------------------------------------------------------------------------
/src/PSDesiredStateConfiguration/Configuration/BaseRegistration/MSFT_DSCMetaConfiguration.json:
--------------------------------------------------------------------------------
1 | {
2 | "ClassName": "MSFT_DSCMetaConfiguration",
3 | "FriendlyName": "LocalConfigurationManager",
4 | "ClassVersion": "1.0.0",
5 | "ClassProperties": [
6 | {
7 | "Name": "ConfigurationModeFrequencyMins",
8 | "CimType": "UInt32"
9 | },
10 | {
11 | "Name": "RebootNodeIfNeeded",
12 | "CimType": "Boolean"
13 | },
14 | {
15 | "Name": "ConfigurationMode",
16 | "CimType": "String",
17 | "Qualifiers": {
18 | "ValueMap": [
19 | "ApplyOnly",
20 | "ApplyAndMonitor",
21 | "ApplyAndAutoCorrect",
22 | "MonitorOnly"
23 | ],
24 | "Values": [
25 | "ApplyOnly",
26 | "ApplyAndMonitor",
27 | "ApplyAndAutoCorrect",
28 | "MonitorOnly"
29 | ]
30 | }
31 | },
32 | {
33 | "Name": "ActionAfterReboot",
34 | "CimType": "String",
35 | "Qualifiers": {
36 | "ValueMap": [
37 | "ContinueConfiguration",
38 | "StopConfiguration"
39 | ],
40 | "Values": [
41 | "ContinueConfiguration",
42 | "StopConfiguration"
43 | ]
44 | }
45 | },
46 | {
47 | "Name": "Credential",
48 | "CimType": "Instance",
49 | "ReferenceClassName": "MSFT_Credential",
50 | "Qualifiers": {
51 | "EmbeddedInstance": "MSFT_Credential"
52 | }
53 | },
54 | {
55 | "Name": "RefreshMode",
56 | "CimType": "String",
57 | "Qualifiers": {
58 | "ValueMap": [
59 | "Push",
60 | "Pull",
61 | "Disabled"
62 | ],
63 | "Values": [
64 | "Push",
65 | "Pull",
66 | "Disabled"
67 | ]
68 | }
69 | },
70 | {
71 | "Name": "CertificateID",
72 | "CimType": "String"
73 | },
74 | {
75 | "Name": "ConfigurationID",
76 | "CimType": "String"
77 | },
78 | {
79 | "Name": "DownloadManagerName",
80 | "CimType": "String"
81 | },
82 | {
83 | "Name": "DownloadManagerCustomData",
84 | "CimType": "InstanceArray",
85 | "ReferenceClassName": "MSFT_KeyValuePair",
86 | "Qualifiers": {
87 | "EmbeddedInstance": "MSFT_KeyValuePair"
88 | }
89 | },
90 | {
91 | "Name": "RefreshFrequencyMins",
92 | "CimType": "UInt32"
93 | },
94 | {
95 | "Name": "AllowModuleOverwrite",
96 | "CimType": "Boolean"
97 | },
98 | {
99 | "Name": "DebugMode",
100 | "CimType": "StringArray",
101 | "Qualifiers": {
102 | "ValueMap": [
103 | "None",
104 | "ForceModuleImport",
105 | "All",
106 | "ResourceScriptBreakAll",
107 | "ResourceScriptBreakpoint"
108 | ],
109 | "Values": [
110 | "None",
111 | "ForceModuleImport",
112 | "All",
113 | "ResourceScriptBreakAll",
114 | "ResourceScriptBreakpoint"
115 | ]
116 | }
117 | },
118 | {
119 | "Name": "LCMVersion",
120 | "CimType": "String",
121 | "Qualifiers": {
122 | "Read": true
123 | }
124 | },
125 | {
126 | "Name": "LCMCompatibleVersions",
127 | "CimType": "StringArray",
128 | "Qualifiers": {
129 | "Read": true
130 | }
131 | },
132 | {
133 | "Name": "LCMState",
134 | "CimType": "String",
135 | "Qualifiers": {
136 | "Read": true,
137 | "ValueMap": [
138 | "Idle",
139 | "Busy",
140 | "PendingReboot",
141 | "PendingConfiguration"
142 | ],
143 | "Values": [
144 | "Idle",
145 | "Busy",
146 | "PendingReboot",
147 | "PendingConfiguration"
148 | ]
149 | }
150 | },
151 | {
152 | "Name": "LCMStateDetail",
153 | "CimType": "String",
154 | "Qualifiers": {
155 | "Read": true
156 | }
157 | },
158 | {
159 | "Name": "ConfigurationDownloadManagers",
160 | "CimType": "InstanceArray",
161 | "ReferenceClassName": "OMI_ConfigurationDownloadManager",
162 | "Qualifiers": {
163 | "EmbeddedInstance": "OMI_ConfigurationDownloadManager"
164 | }
165 | },
166 | {
167 | "Name": "ResourceModuleManagers",
168 | "CimType": "InstanceArray",
169 | "ReferenceClassName": "OMI_ResourceModuleManager",
170 | "Qualifiers": {
171 | "EmbeddedInstance": "OMI_ResourceModuleManager"
172 | }
173 | },
174 | {
175 | "Name": "ReportManagers",
176 | "CimType": "InstanceArray",
177 | "ReferenceClassName": "OMI_ReportManager",
178 | "Qualifiers": {
179 | "EmbeddedInstance": "OMI_ReportManager"
180 | }
181 | },
182 | {
183 | "Name": "PartialConfigurations",
184 | "CimType": "InstanceArray",
185 | "ReferenceClassName": "MSFT_PartialConfiguration",
186 | "Qualifiers": {
187 | "EmbeddedInstance": "MSFT_PartialConfiguration"
188 | }
189 | },
190 | {
191 | "Name": "StatusRetentionTimeInDays",
192 | "CimType": "UInt32"
193 | },
194 | {
195 | "Name": "AgentId",
196 | "CimType": "String",
197 | "Qualifiers": {
198 | "Read": true
199 | }
200 | },
201 | {
202 | "Name": "SignatureValidationPolicy",
203 | "CimType": "String"
204 | },
205 | {
206 | "Name": "SignatureValidations",
207 | "CimType": "InstanceArray",
208 | "ReferenceClassName": "MSFT_SignatureValidation",
209 | "Qualifiers": {
210 | "EmbeddedInstance": "MSFT_SignatureValidation"
211 | }
212 | },
213 | {
214 | "Name": "MaximumDownloadSizeMB",
215 | "CimType": "UInt32"
216 | }
217 | ]
218 | }
219 |
--------------------------------------------------------------------------------
/src/PSDesiredStateConfiguration/Configuration/BaseRegistration/MSFT_DSCMetaConfiguration.mof:
--------------------------------------------------------------------------------
1 |
2 | [ClassVersion("1.0.0"),FriendlyName("LocalConfigurationManager")]
3 | class MSFT_DSCMetaConfiguration
4 | {
5 | uint32 ConfigurationModeFrequencyMins;
6 | boolean RebootNodeIfNeeded;
7 | [ValueMap{"ApplyOnly", "ApplyAndMonitor", "ApplyAndAutoCorrect", "MonitorOnly"},Values{"ApplyOnly", "ApplyAndMonitor", "ApplyAndAutoCorrect", "MonitorOnly"}] string ConfigurationMode;
8 | [ValueMap {"ContinueConfiguration","StopConfiguration"}, Values {"ContinueConfiguration","StopConfiguration"}]
9 | string ActionAfterReboot;
10 | [EmbeddedInstance("MSFT_Credential")] string Credential;
11 | [ValueMap{"Push", "Pull", "Disabled"},Values{"Push", "Pull", "Disabled"}] string RefreshMode;
12 | string CertificateID;
13 | string ConfigurationID;
14 | string DownloadManagerName;
15 | [EmbeddedInstance("MSFT_KeyValuePair")] string DownloadManagerCustomData[];
16 | uint32 RefreshFrequencyMins;
17 | boolean AllowModuleOverwrite;
18 | [ValueMap {"None","ForceModuleImport", "All", "ResourceScriptBreakAll", "ResourceScriptBreakpoint"}, Values {"None","ForceModuleImport", "All", "ResourceScriptBreakAll", "ResourceScriptBreakpoint"}]
19 | string DebugMode[];
20 | [Read] string LCMVersion;
21 | [Read] string LCMCompatibleVersions[];
22 | [Read,ValueMap{"Idle","Busy","PendingReboot","PendingConfiguration"},Values{"Idle","Busy","PendingReboot","PendingConfiguration"}] string LCMState;
23 | [Read] string LCMStateDetail;
24 | [EmbeddedInstance("OMI_ConfigurationDownloadManager")] string ConfigurationDownloadManagers[];
25 | [EmbeddedInstance("OMI_ResourceModuleManager")] string ResourceModuleManagers[];
26 | [EmbeddedInstance("OMI_ReportManager")] string ReportManagers[];
27 | [EmbeddedInstance("MSFT_PartialConfiguration")] string PartialConfigurations[];
28 | uint32 StatusRetentionTimeInDays;
29 | [Read] string AgentId;
30 | string SignatureValidationPolicy;
31 | [EmbeddedInstance("MSFT_SignatureValidation")]
32 | string SignatureValidations[];
33 | uint32 MaximumDownloadSizeMB;
34 | };
35 |
--------------------------------------------------------------------------------
/src/PSDesiredStateConfiguration/Configuration/BaseRegistration/MSFT_MetaConfigurationExtensionClasses.schema.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "ClassName": "MSFT_WebDownloadManager",
4 | "FriendlyName": "ConfigurationRepositoryWeb",
5 | "ClassVersion": "1.0.0",
6 | "SuperClassName": "OMI_ConfigurationDownloadManager",
7 | "ClassProperties": [
8 | {
9 | "Name": "ServerURL",
10 | "CimType": "String",
11 | "Qualifiers": {
12 | "Key": true
13 | }
14 | },
15 | {
16 | "Name": "CertificateID",
17 | "CimType": "String"
18 | },
19 | {
20 | "Name": "AllowUnsecureConnection",
21 | "CimType": "Boolean"
22 | },
23 | {
24 | "Name": "RegistrationKey",
25 | "CimType": "String"
26 | },
27 | {
28 | "Name": "ConfigurationNames",
29 | "CimType": "StringArray"
30 | },
31 | {
32 | "Name": "ProxyURL",
33 | "CimType": "String"
34 | },
35 | {
36 | "Name": "ProxyCredential",
37 | "CimType": "Instance",
38 | "ReferenceClassName": "MSFT_Credential",
39 | "Qualifiers": {
40 | "EmbeddedInstance": "MSFT_Credential"
41 | }
42 | }
43 | ]
44 | },
45 | {
46 | "ClassName": "MSFT_FileDownloadManager",
47 | "FriendlyName": "ConfigurationRepositoryShare",
48 | "ClassVersion": "1.0.0",
49 | "SuperClassName": "OMI_ConfigurationDownloadManager",
50 | "ClassProperties": [
51 | {
52 | "Name": "SourcePath",
53 | "CimType": "String",
54 | "Qualifiers": {
55 | "Key": true
56 | }
57 | },
58 | {
59 | "Name": "Credential",
60 | "CimType": "Instance",
61 | "ReferenceClassName": "MSFT_Credential",
62 | "Qualifiers": {
63 | "EmbeddedInstance": "MSFT_Credential"
64 | }
65 | }
66 | ]
67 | },
68 | {
69 | "ClassName": "MSFT_WebResourceManager",
70 | "FriendlyName": "ResourceRepositoryWeb",
71 | "ClassVersion": "1.0.0",
72 | "SuperClassName": "OMI_ResourceModuleManager",
73 | "ClassProperties": [
74 | {
75 | "Name": "ServerURL",
76 | "CimType": "String",
77 | "Qualifiers": {
78 | "Key": true
79 | }
80 | },
81 | {
82 | "Name": "CertificateID",
83 | "CimType": "String"
84 | },
85 | {
86 | "Name": "AllowUnsecureConnection",
87 | "CimType": "Boolean"
88 | },
89 | {
90 | "Name": "RegistrationKey",
91 | "CimType": "String"
92 | },
93 | {
94 | "Name": "ProxyURL",
95 | "CimType": "String"
96 | },
97 | {
98 | "Name": "ProxyCredential",
99 | "CimType": "Instance",
100 | "ReferenceClassName": "MSFT_Credential",
101 | "Qualifiers": {
102 | "EmbeddedInstance": "MSFT_Credential"
103 | }
104 | }
105 | ]
106 | },
107 | {
108 | "ClassName": "MSFT_FileResourceManager",
109 | "FriendlyName": "ResourceRepositoryShare",
110 | "ClassVersion": "1.0.0",
111 | "SuperClassName": "OMI_ResourceModuleManager",
112 | "ClassProperties": [
113 | {
114 | "Name": "SourcePath",
115 | "CimType": "String",
116 | "Qualifiers": {
117 | "Key": true
118 | }
119 | },
120 | {
121 | "Name": "Credential",
122 | "CimType": "Instance",
123 | "ReferenceClassName": "MSFT_Credential",
124 | "Qualifiers": {
125 | "EmbeddedInstance": "MSFT_Credential"
126 | }
127 | }
128 | ]
129 | },
130 | {
131 | "ClassName": "MSFT_WebReportManager",
132 | "FriendlyName": "ReportServerWeb",
133 | "ClassVersion": "1.0.0",
134 | "SuperClassName": "OMI_ReportManager",
135 | "ClassProperties": [
136 | {
137 | "Name": "ServerURL",
138 | "CimType": "String",
139 | "Qualifiers": {
140 | "Key": true
141 | }
142 | },
143 | {
144 | "Name": "CertificateID",
145 | "CimType": "String"
146 | },
147 | {
148 | "Name": "AllowUnsecureConnection",
149 | "CimType": "Boolean"
150 | },
151 | {
152 | "Name": "RegistrationKey",
153 | "CimType": "String"
154 | },
155 | {
156 | "Name": "ProxyURL",
157 | "CimType": "String"
158 | },
159 | {
160 | "Name": "ProxyCredential",
161 | "CimType": "Instance",
162 | "ReferenceClassName": "MSFT_Credential",
163 | "Qualifiers": {
164 | "EmbeddedInstance": "MSFT_Credential"
165 | }
166 | }
167 | ]
168 | },
169 | {
170 | "ClassName": "MSFT_PartialConfiguration",
171 | "FriendlyName": "PartialConfiguration",
172 | "ClassVersion": "1.0.0",
173 | "SuperClassName": "OMI_MetaConfigurationResource",
174 | "ClassProperties": [
175 | {
176 | "Name": "Description",
177 | "CimType": "String",
178 | "Qualifiers": {
179 | "Write": true
180 | }
181 | },
182 | {
183 | "Name": "ExclusiveResources",
184 | "CimType": "StringArray",
185 | "Qualifiers": {
186 | "Write": true
187 | }
188 | },
189 | {
190 | "Name": "ConfigurationSource",
191 | "CimType": "StringArray",
192 | "Qualifiers": {
193 | "Write": true
194 | }
195 | },
196 | {
197 | "Name": "ResourceModuleSource",
198 | "CimType": "StringArray",
199 | "Qualifiers": {
200 | "Write": true
201 | }
202 | },
203 | {
204 | "Name": "DependsOn",
205 | "CimType": "StringArray",
206 | "Qualifiers": {
207 | "Write": true
208 | }
209 | },
210 | {
211 | "Name": "RefreshMode",
212 | "CimType": "String",
213 | "Qualifiers": {
214 | "ValueMap": [
215 | "Push",
216 | "Pull",
217 | "Disabled"
218 | ],
219 | "Values": [
220 | "Push",
221 | "Pull",
222 | "Disabled"
223 | ]
224 | }
225 | }
226 | ]
227 | },
228 | {
229 | "ClassName": "MSFT_SignatureValidation",
230 | "FriendlyName": "SignatureValidation",
231 | "ClassVersion": "1.0.0",
232 | "SuperClassName": "OMI_MetaConfigurationResource",
233 | "ClassProperties": [
234 | {
235 | "Name": "TrustedStorePath",
236 | "CimType": "String",
237 | "Qualifiers": {
238 | "Write": true
239 | }
240 | },
241 | {
242 | "Name": "SignedItemType",
243 | "CimType": "StringArray",
244 | "Qualifiers": {
245 | "ValueMap": [
246 | "Configuration",
247 | "Module"
248 | ],
249 | "Values": [
250 | "Configuration",
251 | "Module"
252 | ]
253 | }
254 | }
255 | ]
256 | },
257 | {
258 | "ClassName": "MSFT_DSCMetaConfigurationV2",
259 | "FriendlyName": "Settings",
260 | "ClassVersion": "2.0.0",
261 | "ClassProperties": [
262 | {
263 | "Name": "ConfigurationModeFrequencyMins",
264 | "CimType": "UInt32"
265 | },
266 | {
267 | "Name": "RebootNodeIfNeeded",
268 | "CimType": "Boolean"
269 | },
270 | {
271 | "Name": "ConfigurationMode",
272 | "CimType": "String",
273 | "Qualifiers": {
274 | "ValueMap": [
275 | "ApplyOnly",
276 | "ApplyAndMonitor",
277 | "ApplyAndAutoCorrect",
278 | "MonitorOnly"
279 | ],
280 | "Values": [
281 | "ApplyOnly",
282 | "ApplyAndMonitor",
283 | "ApplyAndAutoCorrect",
284 | "MonitorOnly"
285 | ]
286 | }
287 | },
288 | {
289 | "Name": "ActionAfterReboot",
290 | "CimType": "String",
291 | "Qualifiers": {
292 | "ValueMap": [
293 | "ContinueConfiguration",
294 | "StopConfiguration"
295 | ],
296 | "Values": [
297 | "ContinueConfiguration",
298 | "StopConfiguration"
299 | ]
300 | }
301 | },
302 | {
303 | "Name": "RefreshMode",
304 | "CimType": "String",
305 | "Qualifiers": {
306 | "ValueMap": [
307 | "Push",
308 | "Pull",
309 | "Disabled"
310 | ],
311 | "Values": [
312 | "Push",
313 | "Pull",
314 | "Disabled"
315 | ]
316 | }
317 | },
318 | {
319 | "Name": "CertificateID",
320 | "CimType": "String"
321 | },
322 | {
323 | "Name": "ConfigurationID",
324 | "CimType": "String"
325 | },
326 | {
327 | "Name": "RefreshFrequencyMins",
328 | "CimType": "UInt32"
329 | },
330 | {
331 | "Name": "AllowModuleOverwrite",
332 | "CimType": "Boolean"
333 | },
334 | {
335 | "Name": "DebugMode",
336 | "CimType": "StringArray",
337 | "Qualifiers": {
338 | "ValueMap": [
339 | "None",
340 | "ForceModuleImport",
341 | "All",
342 | "ResourceScriptBreakAll",
343 | "ResourceScriptBreakpoint"
344 | ],
345 | "Values": [
346 | "None",
347 | "ForceModuleImport",
348 | "All",
349 | "ResourceScriptBreakAll",
350 | "ResourceScriptBreakpoint"
351 | ]
352 | }
353 | },
354 | {
355 | "Name": "LCMVersion",
356 | "CimType": "String",
357 | "Qualifiers": {
358 | "Read": true
359 | }
360 | },
361 | {
362 | "Name": "LCMCompatibleVersions",
363 | "CimType": "StringArray",
364 | "Qualifiers": {
365 | "Read": true
366 | }
367 | },
368 | {
369 | "Name": "LCMState",
370 | "CimType": "String",
371 | "Qualifiers": {
372 | "Read": true,
373 | "ValueMap": [
374 | "Idle",
375 | "Busy",
376 | "PendingReboot",
377 | "PendingConfiguration"
378 | ],
379 | "Values": [
380 | "Idle",
381 | "Busy",
382 | "PendingReboot",
383 | "PendingConfiguration"
384 | ]
385 | }
386 | },
387 | {
388 | "Name": "LCMStateDetail",
389 | "CimType": "String",
390 | "Qualifiers": {
391 | "Read": true
392 | }
393 | },
394 | {
395 | "Name": "ConfigurationDownloadManagers",
396 | "CimType": "InstanceArray",
397 | "ReferenceClassName": "OMI_ConfigurationDownloadManager",
398 | "Qualifiers": {
399 | "EmbeddedInstance": "OMI_ConfigurationDownloadManager"
400 | }
401 | },
402 | {
403 | "Name": "ResourceModuleManagers",
404 | "CimType": "InstanceArray",
405 | "ReferenceClassName": "OMI_ResourceModuleManager",
406 | "Qualifiers": {
407 | "EmbeddedInstance": "OMI_ResourceModuleManager"
408 | }
409 | },
410 | {
411 | "Name": "ReportManagers",
412 | "CimType": "InstanceArray",
413 | "ReferenceClassName": "OMI_ReportManager",
414 | "Qualifiers": {
415 | "EmbeddedInstance": "OMI_ReportManager"
416 | }
417 | },
418 | {
419 | "Name": "PartialConfigurations",
420 | "CimType": "InstanceArray",
421 | "ReferenceClassName": "MSFT_PartialConfiguration",
422 | "Qualifiers": {
423 | "EmbeddedInstance": "MSFT_PartialConfiguration"
424 | }
425 | },
426 | {
427 | "Name": "StatusRetentionTimeInDays",
428 | "CimType": "UInt32"
429 | },
430 | {
431 | "Name": "AgentId",
432 | "CimType": "String",
433 | "Qualifiers": {
434 | "Read": true
435 | }
436 | },
437 | {
438 | "Name": "SignatureValidationPolicy",
439 | "CimType": "String"
440 | },
441 | {
442 | "Name": "SignatureValidations",
443 | "CimType": "InstanceArray",
444 | "ReferenceClassName": "MSFT_SignatureValidation",
445 | "Qualifiers": {
446 | "EmbeddedInstance": "MSFT_SignatureValidation"
447 | }
448 | },
449 | {
450 | "Name": "MaximumDownloadSizeMB",
451 | "CimType": "UInt32"
452 | }
453 | ]
454 | }
455 | ]
456 |
--------------------------------------------------------------------------------
/src/PSDesiredStateConfiguration/Configuration/BaseRegistration/MSFT_MetaConfigurationExtensionClasses.schema.mof:
--------------------------------------------------------------------------------
1 |
2 | [ClassVersion("1.0.0"), FriendlyName("ConfigurationRepositoryWeb")]
3 | class MSFT_WebDownloadManager : OMI_ConfigurationDownloadManager
4 | {
5 | [Key] string ServerURL;
6 | string CertificateID;
7 | boolean AllowUnsecureConnection;
8 | string RegistrationKey;
9 | string ConfigurationNames[];
10 | string ProxyURL;
11 | [EmbeddedInstance("MSFT_Credential")] string ProxyCredential;
12 | };
13 |
14 | [ClassVersion("1.0.0"), FriendlyName("ConfigurationRepositoryShare")]
15 | class MSFT_FileDownloadManager : OMI_ConfigurationDownloadManager
16 | {
17 | [Key] string SourcePath;
18 | [EmbeddedInstance("MSFT_Credential")] string Credential;
19 | };
20 |
21 | [ClassVersion("1.0.0"), FriendlyName("ResourceRepositoryWeb")]
22 | class MSFT_WebResourceManager : OMI_ResourceModuleManager
23 | {
24 | [Key] string ServerURL;
25 | string CertificateID;
26 | boolean AllowUnsecureConnection;
27 | string RegistrationKey;
28 | string ProxyURL;
29 | [EmbeddedInstance("MSFT_Credential")] string ProxyCredential;
30 | };
31 |
32 | [ClassVersion("1.0.0"), FriendlyName("ResourceRepositoryShare")]
33 | class MSFT_FileResourceManager : OMI_ResourceModuleManager
34 | {
35 | [Key] string SourcePath;
36 | [EmbeddedInstance("MSFT_Credential")] string Credential;
37 | };
38 |
39 | [ClassVersion("1.0.0"), FriendlyName("ReportServerWeb")]
40 | class MSFT_WebReportManager : OMI_ReportManager
41 | {
42 | [Key] string ServerURL;
43 | string CertificateID;
44 | boolean AllowUnsecureConnection;
45 | string RegistrationKey;
46 | string ProxyURL;
47 | [EmbeddedInstance("MSFT_Credential")] string ProxyCredential;
48 | };
49 |
50 | [ClassVersion("1.0.0"), FriendlyName("PartialConfiguration")]
51 | class MSFT_PartialConfiguration : OMI_MetaConfigurationResource
52 | {
53 | [Write] String Description;
54 | [Write] String ExclusiveResources[];
55 | [Write] String ConfigurationSource[];
56 | [Write] String ResourceModuleSource[];
57 | [Write] String DependsOn[];
58 | [ValueMap{"Push", "Pull", "Disabled"},Values{"Push", "Pull", "Disabled"}] string RefreshMode;
59 | };
60 |
61 | [ClassVersion("1.0.0"), FriendlyName("SignatureValidation")]
62 | class MSFT_SignatureValidation : OMI_MetaConfigurationResource
63 | {
64 | [Write]string TrustedStorePath;
65 | [ValueMap{"Configuration","Module"},Values{"Configuration","Module"}]string SignedItemType[];
66 | };
67 |
68 | [ClassVersion("2.0.0"),FriendlyName("Settings")]
69 | class MSFT_DSCMetaConfigurationV2
70 | {
71 | uint32 ConfigurationModeFrequencyMins;
72 | boolean RebootNodeIfNeeded;
73 | [ValueMap{"ApplyOnly", "ApplyAndMonitor", "ApplyAndAutoCorrect", "MonitorOnly"},Values{"ApplyOnly", "ApplyAndMonitor", "ApplyAndAutoCorrect", "MonitorOnly"}] string ConfigurationMode;
74 | [ValueMap {"ContinueConfiguration","StopConfiguration"}, Values {"ContinueConfiguration","StopConfiguration"}]
75 | string ActionAfterReboot;
76 | [ValueMap{"Push", "Pull", "Disabled"},Values{"Push", "Pull", "Disabled"}] string RefreshMode;
77 | string CertificateID;
78 | string ConfigurationID;
79 | uint32 RefreshFrequencyMins;
80 | boolean AllowModuleOverwrite;
81 | [ValueMap {"None","ForceModuleImport", "All", "ResourceScriptBreakAll", "ResourceScriptBreakpoint"}, Values {"None","ForceModuleImport", "All", "ResourceScriptBreakAll", "ResourceScriptBreakpoint"}]
82 | string DebugMode[];
83 | [Read] string LCMVersion;
84 | [Read] string LCMCompatibleVersions[];
85 | [Read,ValueMap{"Idle", "Busy", "PendingReboot", "PendingConfiguration"},Values{"Idle", "Busy", "PendingReboot", "PendingConfiguration"}] string LCMState;
86 | [Read] string LCMStateDetail;
87 | [EmbeddedInstance("OMI_ConfigurationDownloadManager")] string ConfigurationDownloadManagers[];
88 | [EmbeddedInstance("OMI_ResourceModuleManager")] string ResourceModuleManagers[];
89 | [EmbeddedInstance("OMI_ReportManager")] string ReportManagers[];
90 | [EmbeddedInstance("MSFT_PartialConfiguration")] string PartialConfigurations[];
91 | uint32 StatusRetentionTimeInDays;
92 | [Read] string AgentId;
93 | string SignatureValidationPolicy;
94 | [EmbeddedInstance("MSFT_SignatureValidation")]
95 | string SignatureValidations[];
96 | uint32 MaximumDownloadSizeMB;
97 | };
98 |
--------------------------------------------------------------------------------
/src/PSDesiredStateConfiguration/Configuration/BaseRegistration/en-US/BaseResource.Schema.mfl:
--------------------------------------------------------------------------------
1 | #pragma namespace("\\\\.\\root\\default")
2 | instance of __namespace{ name="ms_409";};
3 | #pragma namespace("\\\\.\\root\\default\\ms_409")
4 |
5 | [Description("Base schema for all configuration providers that will be imported by powershell extension.") : Amended,AMENDMENT, LOCALE("ms_409")]
6 | class OMI_BaseResource
7 | {
8 | [Description("Unique Id for a resource instance.") : Amended] string ResourceId;
9 | [Description("Source Info to correlate it back to powershell configuration script.") : Amended] string SourceInfo;
10 | [Description("List of resources this resource depends on.") : Amended] string DependsOn[];
11 | [Description("Name of the module that supports this resource.")] string ModuleName;
12 | [Description("Version of the module that supports this resource.")] string ModuleVersion;
13 | [Description("Name of the Partial Configuration that this resource belongs to.")] string ConfiguratioName;
14 | [Description("Credentials under which the resource runs. ")] string PsDscRunAsCredential;
15 | };
16 |
17 | [Description("This class represents a key-value pair.") : Amended,AMENDMENT, LOCALE("ms_409")]
18 | class MSFT_KeyValuePair
19 | {
20 |
21 | };
22 |
23 | [Description("Base schema for configuration provider registration that maps a provider to some configuration engine related information.") : Amended,AMENDMENT, LOCALE("ms_409")]
24 | class MSFT_BaseConfigurationProviderRegistration
25 | {
26 | };
27 |
28 | [Description("Base schema for configuration provider registration that maps a cim provider to namespace.") : Amended,AMENDMENT, LOCALE("ms_409")]
29 | class MSFT_CimConfigurationProviderRegistration : MSFT_BaseConfigurationProviderRegistration
30 | {
31 | };
32 |
33 | [Description("Base schema for configuration provider registration that maps a powershell provider to its module.") : Amended,AMENDMENT, LOCALE("ms_409")]
34 | class MSFT_PSConfigurationProviderRegistration : MSFT_BaseConfigurationProviderRegistration
35 | {
36 | };
37 |
38 | [Description("Base schema for configuration document information.") : Amended,AMENDMENT, LOCALE("ms_409")]
39 | class OMI_ConfigurationDocument
40 | {
41 | [Description("Configuration document version information, configuration engine can use to log.") : Amended] String Version;
42 | [Description("Configuration document Author information.") : Amended] String Author;
43 | [Description("Configuration document Copyright information.") : Amended] String Copyright;
44 | [Description("Configuration document Help URI.") : Amended] String HelpInfoUri;
45 | [Description("Configuration document Content Type. Only PasswordEncrypted and NotEncrypted are supported. Default value is NotEncrypted.") : Amended] String ContentType;
46 | [Description("Configuration document generation date.") : Amended] String GenerationDate;
47 | [Description("Configuration document generation host.") : Amended] String GenerationHost;
48 | [Description("Configuration document name.") : Amended] String Name;
49 | [Description("Configuration document minimum version requirement for compatibility with the target DSC version.") : Amended] String MinimumCompatibleVersion;
50 | [Description("Additional properties (if any) that are required by the version of this document over 1.0.0 for version compatibility.") : Amended] String CompatibleVersionAdditionalProperties[];
51 | [Description("Configuration document is encrypted using Cryptographic Message Syntax format.") : Amended] boolean UseCms;
52 | };
53 |
54 |
55 | [Description ("Credential to use for DSC configuration providers." ) : Amended,AMENDMENT, LOCALE("ms_409")]
56 | class MSFT_Credential
57 | {
58 | [Description("UserName is the name of the user for an authorization service to map to an identity." ) : Amended] string UserName;
59 | [Description("UserPassword property may contain a password used to access resources." ) : Amended] string Password;
60 | };
61 |
62 |
63 | [Description("Base schema for all Metaconfiguration resources .") : Amended,AMENDMENT, LOCALE("ms_409")]
64 | class OMI_MetaConfigurationResource
65 | {
66 | };
67 |
68 | [Description("Class defining the structure of resource module managers") : Amended,AMENDMENT, LOCALE("MS_409")]
69 | class OMI_ResourceModuleManager : OMI_MetaConfigurationResource
70 | {
71 | [Description("Name of the resource module Manager.") : Amended] string Name;
72 | [Description("Priority of the resource module manager.") : Amended] uint32 Priority;
73 | };
74 |
75 | [Description("Class defining the configuration download manager") : Amended,AMENDMENT, LOCALE("MS_409")]
76 | class OMI_ConfigurationDownloadManager : OMI_MetaConfigurationResource
77 | {
78 | [Description("Name of the configuration download Manager.") : Amended] string Name;
79 | };
80 |
81 |
82 | [Description("Class defining a report manager") : Amended,AMENDMENT, LOCALE("MS_409")]
83 | class OMI_ReportManager : OMI_MetaConfigurationResource
84 | {
85 | [Description("Name of the report manager") : Amended] string Name;
86 | [Description("Custom data that is specific to Report Manager.") : Amended] string CustomData[];
87 | };
88 |
--------------------------------------------------------------------------------
/src/PSDesiredStateConfiguration/Configuration/BaseRegistration/en-US/MSFT_DSCMetaConfiguration.mfl:
--------------------------------------------------------------------------------
1 | #pragma namespace("\\\\.\\root\\default")
2 | instance of __namespace{ name="MS_409";};
3 | #pragma namespace("\\\\.\\root\\default\\MS_409")
4 |
5 | [Description("Local Configuration Manager settings.") : Amended,AMENDMENT, LOCALE("MS_409")]
6 | class MSFT_DSCMetaConfiguration
7 | {
8 | [Description("The time interval between consecutive runs for reapplying the configuration to get to the desired state.") : Amended] uint32 ConfigurationModeFrequencyMins;
9 | [Description("Reboot node if needed.") : Amended] boolean RebootNodeIfNeeded;
10 | [Description("The configuration apply mode for the server.") : Amended] string ConfigurationMode;
11 | [Description("The configuration action after reboot for the server.") : Amended] string ActionAfterReboot;
12 | [Description("Default credential to access resources.") : Amended] string Credential;
13 | [Description("The refresh mode for the server. Valid values are Pull, Push and Disabled.") : Amended] string RefreshMode;
14 | [Description("The certificate ID used to locate the certificate.") : Amended] string CertificateID;
15 | [Description("The configuration ID used to get the configuration from the pull server.") : Amended] string ConfigurationID;
16 | [Description("Name of the configuration and module Download Manager.") : Amended] string DownloadManagerName;
17 | [Description("Custom data that is specific to Download Manager.") : Amended] string DownloadManagerCustomData[];
18 | [Description("The time interval between consecutive runs to get the action from the server.") : Amended] uint32 RefreshFrequencyMins;
19 | [Description("Overwrite modules when downloading from Pull Server.") : Amended] boolean AllowModuleOverwrite;
20 | [Description("The enumeration for DebugMode.") : Amended ToSubclass,Values{"None", "ForceModuleImport", "All", "ResourceScriptBreakAll", "ResourceScriptBreakpoint"} : Amended ToSubclass] string DebugMode[];
21 | [Description("Current version of local configuration manager.") : Amended] string LCMVersion;
22 | [Description("Compatible versions of current local configuration manager.") : Amended] string LCMCompatibleVersions[];
23 | [Description("Current state of local configuration manager.") : Amended] string LCMState;
24 | [Description("State detail of local configuration manager.") : Amended] string LCMStateDetail;
25 | [Description("Array of configuration download manager objects that contain location information to download configurations") : Amended] string ConfigurationDownloadManagers[];
26 | [Description("Array of resource module managers pointing to a location to download missing DSCResources") : Amended] string ResourceModuleManagers[];
27 | [Description("Array of report managers pointing to a location that would help generate reports for DSC") : Amended] string ReportManagers[];
28 | [Description("Array of partial configurations that are specified to be applied") : Amended] string PartialConfigurations[];
29 | [Description("Number of days to retain configuration status history.") : Amended] uint32 StatusRetentionTimeInDays;
30 | [Description("AgentId of the current Dsc Agent.") : Amended ToSubclass] string AgentId;
31 | [Description("Current signature validation policy.") : Amended] string SignatureValidationPolicy;
32 | [Description ("The signature validation options of the node.") : Amended] string SignatureValidations[];
33 | [Description ("The maximum module size in MB that can be downloaded.") : Amended] uint32 MaximumDownloadSizeMB;
34 | };
35 |
--------------------------------------------------------------------------------
/src/PSDesiredStateConfiguration/Configuration/BaseRegistration/en-US/MSFT_MetaConfigurationExtensionClasses.Schema.mfl:
--------------------------------------------------------------------------------
1 | #pragma namespace("\\\\.\\root\\default")
2 | instance of __namespace{ name="ms_409";};
3 | #pragma namespace("\\\\.\\root\\default\\ms_409")
4 |
5 | [Description("Web download manager class inheriting from OMI_ConfigurationDownloadManager") : Amended,AMENDMENT, LOCALE("ms_409")]
6 | class MSFT_WebDownloadManager : OMI_ConfigurationDownloadManager
7 | {
8 | [Description("String URL of the download manager location") : Amended] string ServerURL;
9 | [Description("The certificate ID used to locate the certificate.") : Amended] string CertificateID;
10 | [Description("Specifies whether report manager can use unsecure connection over http.") : Amended] boolean AllowUnsecureConnection;
11 | [Description("Registration Key with which to register with the Pull Server") : Amended ToSubclass] string RegistrationKey;
12 | [Description("The set of configuration names with which to register with the Pull Server.") : Amended] string ConfigurationNames[];
13 | [Description("String URL of the proxy server") : Amended] string ProxyURL;
14 | [Description("Credential to access the proxy server") : Amended] MSFT_Credential ProxyCredential;
15 | };
16 |
17 | [Description("File configuration download manager class inheriting from OMI_ConfigurationDownloadManager") : Amended,AMENDMENT, LOCALE("ms_409")]
18 | class MSFT_FileDownloadManager : OMI_ConfigurationDownloadManager
19 | {
20 | [Description("String UNC path of the download manager location") : Amended] string SourcePath;
21 | [Description("Default credential to access the file location") : Amended] string Credential;
22 | };
23 |
24 |
25 | [Description("Web resource module manager class inheriting from OMI_ResourceModuleManager") : Amended,AMENDMENT, LOCALE("ms_409")]
26 | class MSFT_WebResourceManager : OMI_ResourceModuleManager
27 | {
28 | [Description("String URL of the resource module manager location") : Amended] string ServerURL;
29 | [Description("The certificate ID used to locate the certificate.") : Amended] string CertificateID;
30 | [Description ("Boolean variable to allow unsecure connections" ) : Amended] boolean AllowUnsecureConnection;
31 | [Description("Registration Key with which to register with the Resource Repository Web") : Amended ToSubclass] string RegistrationKey;
32 | [Description("String URL of the proxy server") : Amended] string ProxyURL;
33 | [Description("Credential to access the proxy server") : Amended] MSFT_Credential ProxyCredential;
34 | };
35 |
36 | [Description("File resource module manager class inheriting from OMI_ResourceModuleManager class") : Amended,AMENDMENT, LOCALE("ms_409")]
37 | class MSFT_FileResourceManager : OMI_ResourceModuleManager
38 | {
39 | [Description("String UNC path of the File resource manager") : Amended] string SourcePath;
40 | [Description("Default credential to access resources.") : Amended] string Credential;
41 | };
42 |
43 | [Description("Web report manager class inheriting from OMI_ReportManager class") : Amended,AMENDMENT, LOCALE("ms_409")]
44 | class MSFT_WebReportManager : OMI_ReportManager
45 | {
46 | [Description("String URL of the report manager location") : Amended] string ServerURL;
47 | [Description ("The certificate ID used to locate the certificate for secure connections." ) : Amended] string CertificateID;
48 | [Description("Specifies whether report manager can use unsecure connection over http.") : Amended] boolean AllowUnsecureConnection;
49 | [Description("Registration Key with which to register with the Reporting Server") : Amended ToSubclass] string RegistrationKey;
50 | [Description("String URL of the proxy server") : Amended] string ProxyURL;
51 | [Description("Credential to access the proxy server") : Amended] MSFT_Credential ProxyCredential;
52 | };
53 |
54 | [Description("This represents a Partial Configuration class.") : Amended,AMENDMENT, LOCALE("ms_409")]
55 | class MSFT_PartialConfiguration : OMI_MetaConfigurationResource
56 | {
57 | [Description("Description of the partial configuration") : Amended] String Description;
58 | [Description("Defines the resources that are exclusive to this particular partial configuration") : Amended] String ExclusiveResources[];
59 | [Description("The configuration repository source that this partial configuration will use") : Amended] String ConfigurationSource;
60 | [Description("A dependency variable indicating which partial configuration must be applied prior to this") : Amended] String DependsOn[];
61 | [Description("The refresh mode for the server. Valid values are Pull, Push and Disabled.") : Amended] string RefreshMode;
62 | };
63 |
64 | [Description("Local Configuration Manager settings.") : Amended,AMENDMENT, LOCALE("MS_409")]
65 | class MSFT_DSCMetaConfigurationV2
66 | {
67 | [Description("The time interval between consecutive runs for reapplying the configuration to get to the desired state.") : Amended] uint32 ConfigurationModeFrequencyMins;
68 | [Description("Reboot node if needed.") : Amended] boolean RebootNodeIfNeeded;
69 | [Description("The configuration apply mode for the server.") : Amended] string ConfigurationMode;
70 | [Description("The refresh mode for the server. Valid values are Pull, Push and Disabled.") : Amended] string RefreshMode;
71 | [Description("The action after reboot of the server. Valid values are ContinueConfiguration andStopConfiguration.") : Amended] string ActionAfterReboot;
72 | [Description("The configuration ID used to get the configuration from the pull server.") : Amended] string ConfigurationID;
73 | [Description("The time interval between consecutive runs to get the action from the server.") : Amended] uint32 RefreshFrequencyMins;
74 | [Description("Overwrite modules when downloading from Pull Server.") : Amended] boolean AllowModuleOverwrite;
75 | [Description("Debug mode. Valid values are None, ForceModuleImport, ResourceScriptBreakAll, ResourceScriptBreakpoint or All") : Amended] string DebugMode[];
76 | [Description("Current version of local configuration manager.") : Amended] string LCMVersion;
77 | [Description("Compatible versions of current local configuration manager.") : Amended] string LCMCompatibleVersions[];
78 | [Description("Current state of local configuration manager.") : Amended] string LCMState;
79 | [Description("State detail of local configuration manager.") : Amended] string LCMStateDetail;
80 | [Description("Array of configuration download manager objects that contain location information to download configurations") : Amended] string ConfigurationDownloadManagers[];
81 | [Description("Array of resource module managers pointing to a location to download missing DSCResources") : Amended] string ResourceModuleManagers[];
82 | [Description("Array of report managers pointing to a location that would help generate reports for DSC") : Amended] string ReportManagers[];
83 | [Description("Array of partial configurations that are specified to be applied") : Amended] string PartialConfigurations[];
84 | [Description("Number of days to retain configuration status history.") : Amended] uint32 StatusRetentionTimeInDays;
85 | [Description("AgentId of the current Dsc Agent.") : Amended] string AgentId;
86 | [Description("Current signature validation policy.") : Amended] string SignatureValidationPolicy;
87 | [Description ("The signature validation options of the node.") : Amended] string SignatureValidations[];
88 | [Description ("The maximum module size in MB that can be downloaded.") : Amended] uint32 MaximumDownloadSizeMB;
89 | };
90 |
--------------------------------------------------------------------------------
/src/PSDesiredStateConfiguration/PSDesiredStateConfiguration.psd1:
--------------------------------------------------------------------------------
1 | #
2 | # Module manifest for module 'PowerShellDSC'
3 | #
4 | # Copyright="(c) Microsoft Corporation. All rights reserved."
5 | #
6 | @{
7 |
8 | # Script module or binary module file associated with this manifest.
9 | RootModule = 'PSDesiredStateConfiguration.psm1'
10 |
11 | # Version number of this module.
12 | moduleVersion = '3.0.0'
13 |
14 | # Supported PSEditions
15 | CompatiblePSEditions = @('Core')
16 |
17 | # ID used to uniquely identify this module
18 | GUID = '779e0998-8c72-4567-89b5-49313fc15351'
19 |
20 | # Author of this module
21 | Author = 'Microsoft Corporation'
22 |
23 | # Company or vendor of this module
24 | CompanyName = 'Microsoft Corporation'
25 |
26 | # Copyright statement for this module
27 | Copyright = '(c) Microsoft Corporation. All rights reserved.'
28 |
29 | # Description of the functionality provided by this module
30 | Description = 'PowerShell Desired State Configuration'
31 |
32 | # Minimum version of the Windows PowerShell engine required by this module
33 | PowerShellVersion = '7.2'
34 |
35 | # Name of the Windows PowerShell host required by this module
36 | # PowerShellHostName = ''
37 |
38 | # Minimum version of the Windows PowerShell host required by this module
39 | # PowerShellHostVersion = ''
40 |
41 | # Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
42 | # DotNetFrameworkVersion = ''
43 |
44 | # Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
45 | # CLRVersion = ''
46 |
47 | # Processor architecture (None, X86, Amd64) required by this module
48 | # ProcessorArchitecture = ''
49 |
50 | # Modules that must be imported into the global environment prior to importing this module
51 | #RequiredModules = @()
52 |
53 | # Assemblies that must be loaded prior to importing this module
54 | # RequiredAssemblies = @()
55 |
56 | # Script files (.ps1) that are run in the caller's environment prior to importing this module.
57 | # ScriptsToProcess = @()
58 |
59 | # Type files (.ps1xml) to be loaded when importing this module
60 | # TypesToProcess = @()
61 |
62 | # Format files (.ps1xml) to be loaded when importing this module
63 | # FormatsToProcess = @()
64 |
65 | # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
66 | NestedModules = @('Microsoft.PowerShell.DscSubsystem.dll')
67 |
68 | # 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.
69 | FunctionsToExport = @(
70 | 'Configuration'
71 | 'New-DscChecksum'
72 | 'Get-DscResource'
73 | 'Invoke-DscResource'
74 | 'ConvertTo-DscJsonSchema'
75 | )
76 |
77 |
78 | # 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.
79 | CmdletsToExport = @()
80 |
81 | # Variables to export from this module
82 | VariablesToExport = '*'
83 |
84 | # 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.
85 | AliasesToExport = @()
86 |
87 | # DSC resources to export from this module
88 | # DscResourcesToExport = @()
89 |
90 | # List of all modules packaged with this module
91 | # ModuleList = @()
92 |
93 | # List of all files packaged with this module
94 | # FileList = @()
95 |
96 | # HelpInfo URI of this module
97 | HelpInfoURI = 'https://go.microsoft.com/fwlink/?linkid=2113535'
98 |
99 | # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
100 | # DefaultCommandPrefix = ''
101 |
102 | PrivateData = @{
103 | PSData = @{
104 | Prerelease = 'beta1'
105 | Tags = @('PSDesiredStateConfiguration',
106 | 'PSEdition_Core',
107 | 'Linux',
108 | 'Mac',
109 | 'Windows')
110 | ProjectUri = 'https://github.com/PowerShell/PSDesiredStateConfiguration'
111 | }
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/src/PSDesiredStateConfiguration/helpers/DscResourceInfo.psm1:
--------------------------------------------------------------------------------
1 | Set-StrictMode -Version latest
2 | $ErrorActionPreference = 'Stop'
3 |
4 | $AddDscResourceInfoTypeScript = @"
5 | //-----------------------------------------------------------------------
6 | //
7 | // Copyright (C) 2013 Microsoft Corporation
8 | //
9 | //-----------------------------------------------------------------------
10 |
11 | using System.Collections.Generic;
12 | using System;
13 | using System.Management.Automation;
14 | using System.IO;
15 |
16 | namespace Microsoft.PowerShell.DesiredStateConfiguration
17 | {
18 | ///
19 | /// Enumerated values for DSC resource implementation type
20 | ///
21 | public enum ImplementedAsType
22 | {
23 | ///
24 | /// DSC resource implementation type not known
25 | ///
26 | None = 0,
27 |
28 | ///
29 | /// DSC resource is implemented using PowerShell module
30 | ///
31 | PowerShell = 1,
32 |
33 | ///
34 | /// DSC resource is implemented using a CIM provider
35 | ///
36 | Binary = 2,
37 |
38 | ///
39 | /// DSC resource is a composite and implemented using configuration keyword
40 | ///
41 | Composite = 3
42 | }
43 |
44 | ///
45 | /// Contains a DSC resource information
46 | ///
47 | public sealed class DscResourceInfo
48 | {
49 | ///
50 | /// Initializes a new instance of the DscResourceInfo class
51 | ///
52 | public DscResourceInfo()
53 | {
54 | this.Properties = new List();
55 | }
56 |
57 | ///
58 | /// Gets or sets resource type name
59 | ///
60 | public string ResourceType { get; set; }
61 |
62 | ///
63 | /// Gets or sets Name of the resource. This name is used to access the resource
64 | ///
65 | public string Name { get; set; }
66 |
67 | ///
68 | /// Gets or sets friendly name defined for the resource
69 | ///
70 | public string FriendlyName { get; set; }
71 |
72 | ///
73 | /// Gets or sets module which implements the resource. This could point to parent module, if the DSC resource is implemented
74 | /// by one of nested modules.
75 | ///
76 | public PSModuleInfo Module { get; set; }
77 |
78 | ///
79 | /// Gets name of the module which implements the resource.
80 | ///
81 | public string ModuleName
82 | {
83 | get
84 | {
85 | if (this.Module == null) return null;
86 | return this.Module.Name;
87 | }
88 | }
89 |
90 | ///
91 | /// Gets version of the module which implements the resource.
92 | ///
93 | public Version Version
94 | {
95 | get
96 | {
97 | if (this.Module == null) return null;
98 | return this.Module.Version;
99 | }
100 | }
101 |
102 | ///
103 | /// Gets or sets of the file which implements the resource. For the reosurces which are defined using
104 | /// MOF file, this will be path to a module which resides in the same folder where schema.mof file is present.
105 | /// For composite resources, this will be the module which implements the resource
106 | ///
107 | public string Path { get; set; }
108 |
109 | ///
110 | /// Gets or sets parent folder, where the resource is defined
111 | /// It is the folder containing either the implementing module(=Path) or folder containing ".schema.mof".
112 | /// For native providers, Path will be null and only ParentPath will be present.
113 | ///
114 | public string ParentPath { get; set; }
115 |
116 | ///
117 | /// Gets or sets a value which indicate how DSC resource is implemented
118 | ///
119 | public ImplementedAsType ImplementedAs { get; set; }
120 |
121 | ///
122 | /// Gets or sets company which owns this resource
123 | ///
124 | public string CompanyName { get; set; }
125 |
126 | ///
127 | /// Gets or sets properties of the resource
128 | ///
129 | public List Properties { get; private set; }
130 |
131 | ///
132 | /// Updates properties of the resource
133 | ///
134 | /// Updated properties
135 | public void UpdateProperties(List properties)
136 | {
137 | this.Properties = properties;
138 | }
139 | }
140 |
141 | ///
142 | /// Contains a DSC resource property information
143 | ///
144 | public sealed class DscResourcePropertyInfo
145 | {
146 | ///
147 | /// Initializes a new instance of the DscResourcePropertyInfo class
148 | ///
149 | public DscResourcePropertyInfo()
150 | {
151 | this.Values = new List();
152 | }
153 |
154 | ///
155 | /// Gets or sets name of the property
156 | ///
157 | public string Name { get; set; }
158 |
159 | ///
160 | /// Gets or sets type of the property
161 | ///
162 | public string PropertyType { get; set; }
163 |
164 | ///
165 | /// Gets or sets a value indicating whether the property is mandatory or not
166 | ///
167 | public bool IsMandatory { get; set; }
168 |
169 | ///
170 | /// Gets Values for a resource property
171 | ///
172 | public List Values { get; private set; }
173 | }
174 | }
175 | "@
176 |
177 | if(-not ([System.Management.Automation.PSTypeName]'Microsoft.PowerShell.DesiredStateConfiguration.DscResourceInfo').Type) {
178 | Add-Type -TypeDefinition $AddDscResourceInfoTypeScript
179 | }
180 |
--------------------------------------------------------------------------------
/test/PSDesiredStateConfiguration.Tests.ps1:
--------------------------------------------------------------------------------
1 | # Copyright (c) Microsoft Corporation. All rights reserved.
2 | # Licensed under the MIT License.
3 | Function Install-ModuleIfMissing {
4 | param(
5 | [parameter(Mandatory)]
6 | [String]
7 | $Name,
8 | [version]
9 | $MinimumVersion,
10 | [switch]
11 | $SkipPublisherCheck,
12 | [switch]
13 | $Force
14 | )
15 |
16 | $module = Get-Module -Name $Name -ListAvailable -ErrorAction Ignore | Sort-Object -Property Version -Descending | Select-Object -First 1
17 |
18 | if (!$module -or $module.Version -lt $MinimumVersion) {
19 | Write-Verbose "Installing module '$Name' ..." -Verbose
20 | Install-Module -Name $Name -Force -SkipPublisherCheck:$SkipPublisherCheck.IsPresent
21 | }
22 | }
23 |
24 | Describe "Test PSDesiredStateConfiguration" {
25 | Context "Module loading" {
26 | BeforeAll {
27 | Function BeCommand {
28 | [CmdletBinding()]
29 | Param(
30 | [object[]] $ActualValue,
31 | [string] $CommandName,
32 | [string] $ModuleName,
33 | [switch]$Negate
34 | )
35 |
36 | $failure = if ($Negate) {
37 | "Expected: Command $CommandName should not exist in module $ModuleName"
38 | }
39 | else {
40 | "Expected: Command $CommandName should exist in module $ModuleName"
41 | }
42 |
43 | $succeeded = if ($Negate) {
44 | ($ActualValue | Where-Object { $_.Name -eq $CommandName }).count -eq 0
45 | }
46 | else {
47 | ($ActualValue | Where-Object { $_.Name -eq $CommandName }).count -gt 0
48 | }
49 |
50 | return [PSCustomObject]@{
51 | Succeeded = $succeeded
52 | FailureMessage = $failure
53 | }
54 | }
55 |
56 | Add-AssertionOperator -Name 'HaveCommand' -Test $Function:BeCommand -SupportsArrayInput
57 |
58 | $commands = Get-Command -Module PSDesiredStateConfiguration
59 | }
60 |
61 | It "The module should have the Configuration Command" {
62 | $commands | Should -HaveCommand -CommandName 'Configuration' -ModuleName PSDesiredStateConfiguration
63 | }
64 |
65 | It "The module should have the New-DscChecksum Command" {
66 | $commands | Should -HaveCommand -CommandName 'New-DscChecksum' -ModuleName PSDesiredStateConfiguration
67 | }
68 |
69 | It "The module should have the Get-DscResource Command" {
70 | $commands | Should -HaveCommand -CommandName 'Get-DscResource' -ModuleName PSDesiredStateConfiguration
71 | }
72 |
73 | It "The module should have the Invoke-DscResource Command" {
74 | $commands | Should -HaveCommand -CommandName 'Invoke-DscResource' -ModuleName PSDesiredStateConfiguration
75 | }
76 |
77 | It "The module should have the ConvertTo-DscJsonSchema Command" {
78 | $commands | Should -HaveCommand -CommandName 'ConvertTo-DscJsonSchema' -ModuleName PSDesiredStateConfiguration
79 | }
80 | }
81 |
82 | Context "Get-DscResource - Class base Resources" {
83 |
84 | BeforeAll {
85 | $origProgress = $global:ProgressPreference
86 | $global:ProgressPreference = 'SilentlyContinue'
87 | Install-ModuleIfMissing -Name XmlContentDsc -Force
88 | $classTestCases = @(
89 | @{
90 | TestCaseName = 'Good case'
91 | Name = 'XmlFileContentResource'
92 | ModuleName = 'XmlContentDsc'
93 | }
94 | @{
95 | TestCaseName = 'Module Name case mismatch'
96 | Name = 'XmlFileContentResource'
97 | ModuleName = 'xmlcontentdsc'
98 | }
99 | @{
100 | TestCaseName = 'Resource name case mismatch'
101 | Name = 'xmlfilecontentresource'
102 | ModuleName = 'XmlContentDsc'
103 | }
104 | )
105 | }
106 |
107 | AfterAll {
108 | $global:ProgressPreference = $origProgress
109 | }
110 |
111 | it "should be able to get class resource - from - " -TestCases $classTestCases {
112 | param($Name, $ModuleName, $PendingBecause)
113 |
114 | if ($PendingBecause) {
115 | Set-ItResult -Pending -Because $PendingBecause
116 | }
117 |
118 | $resource = Get-DscResource -Name $Name -Module $ModuleName
119 | $resource | Should -Not -BeNullOrEmpty
120 | $resource.Name | Should -Be $Name
121 | $resource.ImplementationDetail | Should -Be 'ClassBased'
122 | }
123 |
124 | it "should be able to get class resource - - " -TestCases $classTestCases {
125 | param($Name, $ModuleName, $PendingBecause)
126 |
127 | if ($PendingBecause) {
128 | Set-ItResult -Pending -Because $PendingBecause
129 | }
130 |
131 | $resource = Get-DscResource -Name $Name
132 | $resource | Should -Not -BeNullOrEmpty
133 | $resource.Name | Should -Be $Name
134 | $resource.ImplementationDetail | Should -Be 'ClassBased'
135 | }
136 | }
137 |
138 | Context "Invoke-DscResource" {
139 | BeforeAll {
140 | $origProgress = $global:ProgressPreference
141 | $global:ProgressPreference = 'SilentlyContinue'
142 | $module = Get-InstalledModule -Name PsDscResources -ErrorAction Ignore
143 | if ($module) {
144 | Write-Verbose "removing PSDscResources, tests will re-install..." -Verbose
145 | Uninstall-Module -Name PsDscResources -AllVersions -Force
146 | }
147 | }
148 |
149 | AfterAll {
150 | $Global:ProgressPreference = $origProgress
151 | }
152 |
153 | Context "Class Based Resources" {
154 | BeforeAll {
155 | Install-ModuleIfMissing -Name XmlContentDsc -Force
156 | }
157 |
158 | AfterAll {
159 | $Global:ProgressPreference = $origProgress
160 | }
161 |
162 | BeforeEach {
163 | $testXmlPath = 'TestDrive:\test.xml'
164 | @'
165 |
166 |
167 |
168 |
169 |
170 | '@ | Out-File -FilePath $testXmlPath -Encoding utf8NoBOM
171 | $resolvedXmlPath = (Resolve-Path -Path $testXmlPath).ProviderPath
172 | }
173 |
174 | it 'Set method should work' {
175 | param(
176 | $value,
177 | $ExpectedResult
178 | )
179 |
180 | $testString = '890574209347509120348'
181 | $result = Invoke-DscResource -Name XmlFileContentResource -ModuleName XmlContentDsc -Property @{Path = $resolvedXmlPath; XPath = '/configuration/appSetting/Test1'; Ensure = 'Present'; Attributes = @{ TestValue2 = $testString; Name = $testString } } -Method Set
182 | $result | Should -Not -BeNullOrEmpty
183 | $result.GetType() | Should -Be 'InvokeDscResourceSetResult'
184 | $result.RebootRequired | Should -BeFalse
185 | $testXmlPath | Should -FileContentMatch $testString
186 | }
187 |
188 | it 'Get method should work' {
189 | param(
190 | $value,
191 | $ExpectedResult
192 | )
193 |
194 | $result = Invoke-DscResource -Name XmlFileContentResource -ModuleName XmlContentDsc -Property @{Path = $resolvedXmlPath; XPath = '/configuration/appSetting/Test1'} -Method Get
195 | $result.GetType() | Should -Be 'XmlFileContentResource'
196 | }
197 |
198 | it 'Test method should work' {
199 | param(
200 | $value,
201 | $ExpectedResult
202 | )
203 |
204 | $result = Invoke-DscResource -Name XmlFileContentResource -ModuleName XmlContentDsc -Property @{Path = $resolvedXmlPath; XPath = '/configuration/appSetting/Test1'} -Method Test
205 | $result | Should -Not -BeNullOrEmpty
206 | $result.GetType() | Should -Be 'InvokeDscResourceTestResult'
207 | $result.InDesiredState | Should -Not -BeNullOrEmpty
208 | }
209 | }
210 | }
211 | }
212 |
213 | Describe "DSC MOF Compilation" {
214 | BeforeAll {
215 | # ensure that module is imported
216 | Import-Module -Name PSDesiredStateConfiguration -MinimumVersion 3.0.0
217 | Install-ModuleIfMissing -Name XmlContentDsc -Force
218 | }
219 |
220 | It "Should be able to compile a MOF using configuration keyword" {
221 |
222 | Write-Verbose "DSC_HOME: ${env:DSC_HOME}" -Verbose
223 | [Scriptblock]::Create(@"
224 | configuration DSCTestConfig
225 | {
226 | Import-DscResource -ModuleName XmlContentDsc
227 | Node "localhost" {
228 | XmlFileContentResource f1
229 | {
230 | Path = 'testpath'
231 | XPath = '/configuration/appSetting/Test1'
232 | Ensure = 'Absent'
233 | }
234 | }
235 | }
236 |
237 | DSCTestConfig -OutputPath TestDrive:\DscTestConfig2
238 | "@) | Should -Not -Throw
239 |
240 | "TestDrive:\DscTestConfig2\localhost.mof" | Should -Exist
241 | }
242 | }
243 |
244 | Describe "All types DSC resource tests" {
245 | BeforeAll {
246 |
247 | Import-Module -Name PSDesiredStateConfiguration -MinimumVersion 3.0.0
248 |
249 | $SavedPSModulePath = $env:PSModulePath
250 |
251 | $testModulesPath = Join-Path $PSScriptRoot "TestModules"
252 | "TestModulesPath is " + $testModulesPath | Write-Verbose -Verbose
253 | $env:PSModulePath = $testModulesPath + [System.IO.Path]::PathSeparator + $env:PSModulePath
254 | "PSModulePath is " + $env:PSModulePath | Write-Verbose -Verbose
255 | }
256 |
257 | AfterAll {
258 | $env:PSModulePath = $SavedPSModulePath
259 | }
260 |
261 | It "Check all property types in Get-DscResource" {
262 |
263 | $resource = Get-DscResource | ? {$_.Name -eq "xTestClassResource"}
264 | $resource | Should -Not -BeNullOrEmpty
265 | $resource.Properties.Count | Should -Be 34
266 |
267 | foreach($dscResourcePropertyInfo in $resource.Properties)
268 | {
269 | switch ($dscResourcePropertyInfo.Name)
270 | {
271 | "Name" {$dscResourcePropertyInfo.PropertyType | Should -Be '[string]'}
272 | "Value" {$dscResourcePropertyInfo.PropertyType | Should -Be '[string]'}
273 | "bValue" {$dscResourcePropertyInfo.PropertyType | Should -Be '[bool]'}
274 | "sArray" {$dscResourcePropertyInfo.PropertyType | Should -Be '[string[]]'}
275 | "bValueArray" {$dscResourcePropertyInfo.PropertyType | Should -Be '[bool[]]'}
276 | "char16Value" {$dscResourcePropertyInfo.PropertyType | Should -Be '[char]'}
277 | "char16ValueArray" {$dscResourcePropertyInfo.PropertyType | Should -Be '[char[]]'}
278 | "dateTimeVal" {$dscResourcePropertyInfo.PropertyType | Should -Be '[DateTime]'}
279 | "dateTimeArrayVal" {$dscResourcePropertyInfo.PropertyType | Should -Be '[DateTime[]]'}
280 | "EmbClassObj" {$dscResourcePropertyInfo.PropertyType | Should -Be '[EmbClass]'}
281 | "EmbClassObjArray" {$dscResourcePropertyInfo.PropertyType | Should -Be '[EmbClass[]]'}
282 | "Ensure" {$dscResourcePropertyInfo.PropertyType | Should -Be '[string]'}
283 | "Real32Value" {$dscResourcePropertyInfo.PropertyType | Should -Be '[Single]'}
284 | "Real32ValueArray" {$dscResourcePropertyInfo.PropertyType | Should -Be '[Single[]]'}
285 | "Real64Value" {$dscResourcePropertyInfo.PropertyType | Should -Be '[double]'}
286 | "Real64ValueArray" {$dscResourcePropertyInfo.PropertyType | Should -Be '[double[]]'}
287 |
288 | "sInt8Value" {$dscResourcePropertyInfo.PropertyType | Should -Be '[SByte]'}
289 | "sInt8ValueArray" {$dscResourcePropertyInfo.PropertyType | Should -Be '[SByte[]]'}
290 | "sInt16Value" {$dscResourcePropertyInfo.PropertyType | Should -Be '[Int16]'}
291 | "sInt16ValueArray" {$dscResourcePropertyInfo.PropertyType | Should -Be '[Int16[]]'}
292 | "sInt32Value" {$dscResourcePropertyInfo.PropertyType | Should -Be '[Int32]'}
293 | "sInt32ValueArray" {$dscResourcePropertyInfo.PropertyType | Should -Be '[Int32[]]'}
294 | "sInt64Value" {$dscResourcePropertyInfo.PropertyType | Should -Be '[Int64]'}
295 | "sInt64ValueArray" {$dscResourcePropertyInfo.PropertyType | Should -Be '[Int64[]]'}
296 |
297 | "uInt8Value" {$dscResourcePropertyInfo.PropertyType | Should -Be '[Byte]'}
298 | "uInt8ValueArray" {$dscResourcePropertyInfo.PropertyType | Should -Be '[Byte[]]'}
299 | "uInt16Value" {$dscResourcePropertyInfo.PropertyType | Should -Be '[UInt16]'}
300 | "uInt16ValueArray" {$dscResourcePropertyInfo.PropertyType | Should -Be '[UInt16[]]'}
301 | "uInt32Value" {$dscResourcePropertyInfo.PropertyType | Should -Be '[UInt32]'}
302 | "uInt32ValueArray" {$dscResourcePropertyInfo.PropertyType | Should -Be '[UInt32[]]'}
303 | "uInt64Value" {$dscResourcePropertyInfo.PropertyType | Should -Be '[UInt64]'}
304 | "uInt64ValueArray" {$dscResourcePropertyInfo.PropertyType | Should -Be '[UInt64[]]'}
305 | }
306 | }
307 | }
308 |
309 | It "Check all property types in Invoke-DscResource" {
310 |
311 | $resource = Invoke-DscResource -Name xTestClassResource -ModuleName xTestClassResource -Method Get -Property @{Name="Test"}
312 | $resource | Should -Not -BeNullOrEmpty
313 | $resource.GetType().Name | Should -Be "xTestClassResource"
314 | $resource.Name | Should -Be "Test"
315 | $resource.Value | Should -Be "Inside if"
316 |
317 | $resource.Name.GetType().Name | Should -Be "String"
318 | $resource.Value.GetType().Name | Should -Be "String"
319 | $resource.sArray.GetType().Name | Should -Be "String[]"
320 |
321 | $resource.bValue.GetType().Name | Should -Be "Boolean"
322 | $resource.bValueArray.GetType().Name | Should -Be "Boolean[]"
323 | $resource.char16Value.GetType().Name | Should -Be "Char"
324 | $resource.char16ValueArray.GetType().Name | Should -Be "Char[]"
325 | $resource.dateTimeVal.GetType().Name | Should -Be "DateTime"
326 | $resource.dateTimeArrayVal.GetType().Name | Should -Be "DateTime[]"
327 | $resource.EmbClassObj.GetType().Name | Should -Be "EmbClass"
328 | $resource.EmbClassObjArray.GetType().Name | Should -Be "EmbClass[]"
329 | $resource.Ensure.GetType().Name | Should -Be "Ensure"
330 | $resource.Real32Value.GetType().Name | Should -Be "Single"
331 | $resource.Real32ValueArray.GetType().Name | Should -Be "Single[]"
332 | $resource.Real64Value.GetType().Name | Should -Be "Double"
333 | $resource.Real64ValueArray.GetType().Name | Should -Be "Double[]"
334 |
335 | $resource.sInt8Value.GetType().Name | Should -Be "SByte"
336 | $resource.sInt8ValueArray.GetType().Name | Should -Be "SByte[]"
337 | $resource.sInt16Value.GetType().Name | Should -Be "Int16"
338 | $resource.sInt16ValueArray.GetType().Name | Should -Be "Int16[]"
339 | $resource.sInt32Value.GetType().Name | Should -Be "Int32"
340 | $resource.sInt32ValueArray.GetType().Name | Should -Be "Int32[]"
341 | $resource.sInt64Value.GetType().Name | Should -Be "Int64"
342 | $resource.sInt64ValueArray.GetType().Name | Should -Be "Int64[]"
343 |
344 | $resource.uInt8Value.GetType().Name | Should -Be "Byte"
345 | $resource.uInt8ValueArray.GetType().Name | Should -Be "Byte[]"
346 | $resource.uInt16Value.GetType().Name | Should -Be "UInt16"
347 | $resource.uInt16ValueArray.GetType().Name | Should -Be "UInt16[]"
348 | $resource.uInt32Value.GetType().Name | Should -Be "UInt32"
349 | $resource.uInt32ValueArray.GetType().Name | Should -Be "UInt32[]"
350 | $resource.uInt64Value.GetType().Name | Should -Be "UInt64"
351 | $resource.uInt64ValueArray.GetType().Name | Should -Be "UInt64[]"
352 |
353 | # extra check for embedded objects
354 | $resource.EmbClassObj.EmbClassStr1 | Should -Be "TestEmbObjValue"
355 | $resource.EmbClassObjArray[0].EmbClassStr1 | Should -Be "TestEmbClassStr1Value"
356 | }
357 |
358 | It "Check all property types in configuration compilation" {
359 |
360 | [Scriptblock]::Create(@"
361 | configuration DSCAllTypesConfig
362 | {
363 | Import-DscResource -ModuleName xTestClassResource
364 | Node "localhost" {
365 | xTestClassResource f1
366 | {
367 | Name = 'TestName'
368 | Value = 'TestValue'
369 |
370 | char16Value = 'A'
371 | char16ValueArray = @('A','B')
372 |
373 | sArray = @('Test1','Test2')
374 |
375 | bValue = `$true
376 | bValueArray = @(`$true,`$false)
377 |
378 | dateTimeVal = Get-Date
379 | dateTimeArrayVal = @(`$(Get-Date), `$(Get-Date))
380 |
381 | Ensure = 'Present'
382 |
383 | uInt8Value = 255
384 | sInt8Value = -128
385 | uInt16Value = 65535
386 | sInt16Value = -32768
387 | uInt32Value = 4294967295
388 | sInt32Value = -2147483648
389 | uInt64Value = 18446744073709551615
390 | sInt64Value = -9223372036854775808
391 |
392 | Real32Value = [Single]-1.234
393 | Real64Value = [Double]-1.234
394 |
395 | uInt8ValueArray = @(255)
396 | sInt8ValueArray = @(-128)
397 | uInt16ValueArray = @(65535)
398 | sInt16ValueArray = @(-32768)
399 | uInt32ValueArray = @(4294967295)
400 | sInt32ValueArray = @(-2147483648)
401 | uInt64ValueArray = @(18446744073709551615)
402 | sInt64ValueArray = @(-9223372036854775808)
403 | }
404 | }
405 | }
406 |
407 | DSCAllTypesConfig -OutputPath TestDrive:\DSCAllTypesConfig
408 | "@) | Should -Not -Throw
409 |
410 | "TestDrive:\DSCAllTypesConfig\localhost.mof" | Should -Exist
411 | Get-Content -Raw -Path "TestDrive:\DSCAllTypesConfig\localhost.mof" | Write-Verbose -Verbose
412 | }
413 |
414 | It "Check multi-resource configuration compilation with dependencies" {
415 |
416 | [Scriptblock]::Create(@"
417 | configuration MultiResourceConfig
418 | {
419 | Import-DscResource -ModuleName xTestClassResource
420 | ResourceForTests1 r1
421 | {
422 | Prop1 = 'Test'
423 | }
424 | ResourceForTests2 r2
425 | {
426 | Prop1 = 'Test'
427 | DependsOn = '[ResourceForTests1]r1'
428 | }
429 | ResourceForTests3 r3
430 | {
431 | Prop1 = 'Test'
432 | DependsOn = '[ResourceForTests1]r1','[ResourceForTests2]r2'
433 | }
434 | }
435 |
436 | MultiResourceConfig -OutputPath TestDrive:\MultiResourceConfig
437 | "@) | Should -Not -Throw
438 |
439 | "TestDrive:\MultiResourceConfig\localhost.mof" | Should -Exist
440 | Get-Content -Raw -Path "TestDrive:\MultiResourceConfig\localhost.mof" | Write-Verbose -Verbose
441 | }
442 | }
443 |
--------------------------------------------------------------------------------
/test/TestModules/xTestClassResource/xTestClassResource.psd1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerShell/PSDesiredStateConfiguration/c26e6b79d07c5c18184d248b5bf935471fac929d/test/TestModules/xTestClassResource/xTestClassResource.psd1
--------------------------------------------------------------------------------
/test/TestModules/xTestClassResource/xTestClassResource.psm1:
--------------------------------------------------------------------------------
1 | enum Ensure
2 | {
3 | Absent
4 | Present
5 | }
6 |
7 | class EmbClass
8 | {
9 | [DscProperty()]
10 | [string] $EmbClassStr1
11 | }
12 |
13 | [DscResource()]
14 | class xTestClassResource
15 | {
16 | [DscProperty(Key)]
17 | [string]$Name
18 |
19 | [DscProperty(Mandatory)]
20 | [string] $Value
21 |
22 | [DscProperty()]
23 | [Ensure] $Ensure
24 |
25 | [DscProperty()]
26 | [string[]] $sArray
27 |
28 | [DscProperty()]
29 | [EmbClass] $EmbClassObj
30 |
31 | [DscProperty()]
32 | [EmbClass[]] $EmbClassObjArray
33 |
34 | [DscProperty()]
35 | [DateTime] $dateTimeVal;
36 |
37 | [DscProperty()]
38 | [DateTime[]] $dateTimeArrayVal;
39 |
40 | [DscProperty()]
41 | [Boolean] $bValue;
42 |
43 | [DscProperty()]
44 | [Byte] $uInt8Value;
45 |
46 | [DscProperty()]
47 | [SByte] $sInt8Value;
48 |
49 | [DscProperty()]
50 | [UInt16] $uInt16Value;
51 |
52 | [DscProperty()]
53 | [Int16] $sInt16Value;
54 |
55 | [DscProperty()]
56 | [UInt32] $uInt32Value;
57 |
58 | [DscProperty()]
59 | [Int32] $sInt32Value;
60 |
61 | [DscProperty()]
62 | [UInt64] $uInt64Value;
63 |
64 | [DscProperty()]
65 | [Int64] $sInt64Value;
66 |
67 | [DscProperty()]
68 | [Single] $Real32Value;
69 |
70 | [DscProperty()]
71 | [Double] $Real64Value;
72 |
73 | [DscProperty()]
74 | [Char] $char16Value;
75 |
76 | [DscProperty()]
77 | [Boolean[]] $bValueArray;
78 |
79 | [DscProperty()]
80 | [Byte[]] $uInt8ValueArray;
81 |
82 | [DscProperty()]
83 | [SByte[]] $sInt8ValueArray;
84 |
85 | [DscProperty()]
86 | [UInt16[]] $uInt16ValueArray;
87 |
88 | [DscProperty()]
89 | [Int16[]] $sInt16ValueArray;
90 |
91 | [DscProperty()]
92 | [UInt32[]] $uInt32ValueArray;
93 |
94 | [DscProperty()]
95 | [Int32[]] $sInt32ValueArray;
96 |
97 | [DscProperty()]
98 | [UInt64[]] $uInt64ValueArray;
99 |
100 | [DscProperty()]
101 | [Int64[]] $sInt64ValueArray;
102 |
103 | [DscProperty()]
104 | [single[]] $Real32ValueArray;
105 |
106 | [DscProperty()]
107 | [double[]] $Real64ValueArray;
108 |
109 | [DscProperty()]
110 | [Char[]] $char16ValueArray;
111 |
112 | [void] Set()
113 | {
114 |
115 | Set-StrictMode -Version Latest
116 |
117 | if ($this.Ensure -eq [Ensure]::Present)
118 | {
119 | if ($this.Value -eq "fail")
120 | {
121 | Write-Error "Ensure=Present failed for $($this.Name) due to value $($this.Value)"
122 | }
123 | }
124 | elseif ($this.Ensure -eq [Ensure]::Absent)
125 | {
126 | if ($this.Value -eq "fail")
127 | {
128 | Write-Error "Ensure=Absent failed for $($this.Name) due to value $($this.Value)"
129 | }
130 | }
131 | }
132 |
133 | [bool] Test()
134 | {
135 | Write-Debug "Inside Test()"
136 | Set-StrictMode -Version Latest
137 |
138 | [bool] $result = $false
139 |
140 | if ($this.value -eq "fail")
141 | {
142 | Write-Error "Failing Test-TargetResource because Value is set to 'fail'"
143 | }
144 | else
145 | {
146 | Write-Verbose "Start of EmbClassObjArray" -Verbose
147 | foreach ($classObj in $this.EmbClassObjArray)
148 | {
149 | $classObj.EmbClassStr1 | write-Verbose -verbose
150 | }
151 | Write-Verbose "End of EmbClassObjArray" -Verbose
152 |
153 | Write-Verbose "Ensure: $($this.Ensure)" -verbose
154 | Write-Verbose "sArray: $($this.sArray)" -verbose
155 | Write-Verbose "dateTimeVal: $($this.dateTimeVal)" -verbose
156 | Write-Verbose "dateTimeArrayVal: $($this.dateTimeArrayVal)" -verbose
157 | Write-Verbose "bValue: $($this.bValue)" -verbose
158 | Write-Verbose "uInt8Value: $($this.uInt8Value)" -verbose
159 | Write-Verbose "sInt8Value: $($this.sInt8Value)" -verbose
160 | Write-Verbose "uInt16Value: $($this.uInt16Value)" -verbose
161 | Write-Verbose "sInt16Value: $($this.sInt16Value)" -verbose
162 | Write-Verbose "uInt32Value: $($this.uInt32Value)" -verbose
163 | Write-Verbose "sInt32Value: $($this.sInt32Value)" -verbose
164 | Write-Verbose "uInt64Value: $($this.uInt64Value)" -verbose
165 | Write-Verbose "sInt64Value: $($this.sInt64Value)" -verbose
166 | Write-Verbose "Real32Value: $($this.Real32Value)" -verbose
167 | Write-Verbose "Real64Value: $($this.Real64Value)" -verbose
168 | Write-Verbose "bValueArray: $($this.bValueArray)" -verbose
169 | Write-Verbose "char16Value: $($this.char16Value)" -verbose
170 | Write-Verbose "uInt8ValueArray: $($this.uInt8ValueArray)" -verbose
171 | Write-Verbose "sInt8ValueArray: $($this.sInt8ValueArray)" -verbose
172 | Write-Verbose "uInt16ValueArray: $($this.uInt16ValueArray)" -verbose
173 | Write-Verbose "sInt16ValueArray: $($this.sInt16ValueArray)" -verbose
174 | Write-Verbose "uInt32ValueArray: $($this.uInt32ValueArray)" -verbose
175 | Write-Verbose "sInt32ValueArray: $($this.sInt32ValueArray)" -verbose
176 | Write-Verbose "uInt64ValueArray: $($this.uInt64ValueArray)" -verbose
177 | Write-Verbose "sInt64ValueArray: $($this.sInt64ValueArray)" -verbose
178 | Write-Verbose "Real32ValueArray: $($this.Real32ValueArray)" -verbose
179 | Write-Verbose "Real64ValueArray: $($this.Real64ValueArray)" -verbose
180 | Write-Verbose "char16ValueArray: $($this.char16ValueArray)" -verbose
181 |
182 | [Single]$f = -1.000003
183 | [double]$d = -1.234
184 |
185 | $result = ($this.EmbClassObjArray[1].EmbClassStr1 -eq $this.Ensure) -and `
186 | ($this.sArray[1] -eq "s2") -and `
187 | ($this.dateTimeVal -lt (get-date 2020-12-12)) -and `
188 | ($this.dateTimeArrayVal[1] -gt (get-date 2020-08-20)) -and `
189 | ($this.bValue -eq $true) -and `
190 | ($this.uInt8Value -eq 255) -and `
191 | ($this.sInt8Value -eq -128) -and `
192 | ($this.uInt16Value -eq 65535) -and `
193 | ($this.sInt16Value -eq -32768) -and `
194 | ($this.uInt32Value -eq 4294967295) -and `
195 | ($this.sInt32Value -eq -2147483648) -and `
196 | ($this.uInt64Value -eq 18446744073709551615) -and `
197 | ($this.sInt64Value -eq -9223372036854775808) -and `
198 | ($this.Real32Value -eq $f) -and `
199 | ($this.Real64Value -eq $d) -and `
200 | ($this.bValueArray[1] -eq $true) -and `
201 | ($this.char16Value -eq 'c') -and `
202 | ($this.uInt8ValueArray[1] -eq 254) -and `
203 | ($this.sInt8ValueArray[1] -eq -127) -and `
204 | ($this.uInt16ValueArray[1] -eq 65534) -and `
205 | ($this.sInt16ValueArray[1] -eq -32767) -and `
206 | ($this.uInt32ValueArray[1] -eq 4294967294) -and `
207 | ($this.sInt32ValueArray[1] -eq -2147483647) -and `
208 | ($this.uInt64ValueArray[1] -eq 18446744073709551614) -and `
209 | ($this.sInt64ValueArray[1] -eq -9223372036854775807) -and `
210 | ($this.Real32ValueArray[1] -eq $f) -and `
211 | ($this.Real64ValueArray[1] -eq $d) -and `
212 | ($this.char16ValueArray[1] -eq 'd')
213 | }
214 |
215 | return $result
216 | }
217 |
218 | [xTestClassResource] Get()
219 | {
220 | Write-Debug "Inside Get()"
221 |
222 | if ($this.Value -ne "fail")
223 | {
224 | $this.Value = "Inside if"
225 | }
226 | else
227 | {
228 | $this.Value = "Inside else"
229 | }
230 |
231 | # initialize properties so that they are not null
232 | $this.char16Value = "A"
233 | $this.sArray = [String[]]::new(0)
234 |
235 | $this.EmbClassObj = [EmbClass]::new()
236 | $this.EmbClassObj.EmbClassStr1 = "TestEmbObjValue"
237 |
238 | $EmbObj = [EmbClass]::new()
239 | $EmbObj.EmbClassStr1 = "TestEmbClassStr1Value"
240 | $this.EmbClassObjArray = [EmbClass[]]::new(1)
241 | $this.EmbClassObjArray[0] = $EmbObj
242 |
243 | $this.dateTimeVal = [DateTime]::Now
244 | $this.dateTimeArrayVal = [DateTime[]]::new(0)
245 | $this.bValueArray = [Boolean[]]::new(0)
246 | $this.char16ValueArray = [Char[]]::new(0)
247 |
248 | $this.uInt8ValueArray = [Byte[]]::new(0)
249 | $this.sInt8ValueArray = [SByte[]]::new(0)
250 | $this.uInt16ValueArray = [UInt16[]]::new(0)
251 | $this.sInt16ValueArray = [Int16[]]::new(0)
252 | $this.uInt32ValueArray = [UInt32[]]::new(0)
253 | $this.sInt32ValueArray = [Int32[]]::new(0)
254 | $this.uInt64ValueArray = [UInt64[]]::new(0)
255 | $this.sInt64ValueArray = [Int64[]]::new(0)
256 |
257 | $this.Real32ValueArray = [single[]]::new(0)
258 | $this.Real64ValueArray = [double[]]::new(0)
259 |
260 | return $this
261 | }
262 | }
263 |
264 | [DscResource()]
265 | class ResourceForTests1
266 | {
267 | [DscProperty(Key)]
268 | [string] $Prop1
269 |
270 | [void] Set()
271 | {
272 | }
273 |
274 | [bool] Test()
275 | {
276 | return $true
277 | }
278 |
279 | [ResourceForTests1] Get()
280 | {
281 | return $this
282 | }
283 | }
284 |
285 | [DscResource()]
286 | class ResourceForTests2
287 | {
288 | [DscProperty(Key)]
289 | [string] $Prop1
290 |
291 | [void] Set()
292 | {
293 | }
294 |
295 | [bool] Test()
296 | {
297 | return $true
298 | }
299 |
300 | [ResourceForTests2] Get()
301 | {
302 | return $this
303 | }
304 | }
305 |
306 | [DscResource()]
307 | class ResourceForTests3
308 | {
309 | [DscProperty(Key)]
310 | [string] $Prop1
311 |
312 | [void] Set()
313 | {
314 | }
315 |
316 | [bool] Test()
317 | {
318 | return $true
319 | }
320 |
321 | [ResourceForTests3] Get()
322 | {
323 | return $this
324 | }
325 | }
326 |
--------------------------------------------------------------------------------
/tools/releaseBuild/FileCatalogSigning.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/tools/releaseBuild/generatePackgeSigning.ps1:
--------------------------------------------------------------------------------
1 | # Copyright (c) Microsoft Corporation. All rights reserved.
2 | # Licensed under the MIT License.
3 | param(
4 | [Parameter(Mandatory)]
5 | [string] $Path,
6 | [string[]] $AuthenticodeDualFiles,
7 | [string[]] $AuthenticodeFiles,
8 | [string[]] $NuPkgFiles,
9 | [string[]] $MacDeveloperFiles,
10 | [string[]] $LinuxFiles,
11 | [Parameter(Mandatory)]
12 | [string] $rootPath
13 | )
14 |
15 | $resolvedRootPath = (Resolve-Path $rootPath).ProviderPath
16 |
17 | if ((!$AuthenticodeDualFiles -or $AuthenticodeDualFiles.Count -eq 0) -and
18 | (!$AuthenticodeFiles -or $AuthenticodeFiles.Count -eq 0) -and
19 | (!$NuPkgFiles -or $NuPkgFiles.Count -eq 0) -and
20 | (!$MacDeveloperFiles -or $MacDeveloperFiles.Count -eq 0) -and
21 | (!$LinuxFiles -or $LinuxFiles.Count -eq 0))
22 | {
23 | throw "At least one file must be specified"
24 | }
25 |
26 | function New-Attribute
27 | {
28 | param(
29 | [Parameter(Mandatory)]
30 | [string]$Name,
31 | [Parameter(Mandatory)]
32 | [object]$Value,
33 | [Parameter(Mandatory)]
34 | [System.Xml.XmlElement]$Element
35 | )
36 |
37 | $attribute = $signingXml.CreateAttribute($Name)
38 | $attribute.Value = $value
39 | $null = $fileElement.Attributes.Append($attribute)
40 | }
41 |
42 | function New-FileElement
43 | {
44 | param(
45 | [Parameter(Mandatory)]
46 | [string]$File,
47 | [Parameter(Mandatory)]
48 | [string]$SignType,
49 | [Parameter(Mandatory)]
50 | [System.Xml.XmlDocument]$XmlDoc,
51 | [Parameter(Mandatory)]
52 | [System.Xml.XmlElement]$Job
53 | )
54 |
55 | if(Test-Path -Path $file)
56 | {
57 | $name = Split-Path -Leaf -Path $File
58 | $fileElement = $XmlDoc.CreateElement("file")
59 | $src = $file.replace($resolvedRootPath,'__INPATHROOT__\')
60 | $dest = $file.replace($resolvedRootPath,'__OUTPATHROOT__\')
61 | New-Attribute -Name 'src' -value $src -Element $fileElement
62 | New-Attribute -Name 'signType' -value $SignType -Element $fileElement
63 | New-Attribute -Name 'dest' -value $dest -Element $fileElement
64 | $null = $job.AppendChild($fileElement)
65 | }
66 | else
67 | {
68 | Write-Warning -Message "Skipping $SignType; $File because it does not exist"
69 | }
70 | }
71 |
72 | [xml]$signingXml = get-content (Join-Path -Path $PSScriptRoot -ChildPath 'packagesigning.xml')
73 | $job = $signingXml.SignConfigXML.job
74 |
75 | foreach($file in $AuthenticodeDualFiles)
76 | {
77 | New-FileElement -File $file -SignType 'AuthenticodeDual' -XmlDoc $signingXml -Job $job
78 | }
79 |
80 | foreach($file in $AuthenticodeFiles)
81 | {
82 | New-FileElement -File $file -SignType 'AuthenticodeFormer' -XmlDoc $signingXml -Job $job
83 | }
84 |
85 | foreach($file in $NuPkgFiles)
86 | {
87 | New-FileElement -File $file -SignType 'NuGet' -XmlDoc $signingXml -Job $job
88 | }
89 |
90 | foreach ($file in $MacDeveloperFiles) {
91 | New-FileElement -File $file -SignType 'MacDeveloper' -XmlDoc $signingXml -Job $job
92 | }
93 |
94 | foreach ($file in $LinuxFiles) {
95 | New-FileElement -File $file -SignType 'LinuxPack' -XmlDoc $signingXml -Job $job
96 | }
97 |
98 | $null = new-item -Path $path -ItemType file -Force
99 | $savePath = (Resolve-Path $Path).ProviderPath
100 | $signingXml.Save($savePath)
101 |
--------------------------------------------------------------------------------
/tools/releaseBuild/packagesigning.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/tools/releaseBuild/signing.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/tools/terms/FileTypeSet.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Pure Text Files
6 |
7 | .txt
8 | .des
9 | .pwd
10 | .asm
11 | .cmd
12 | .ini
13 | .poc
14 | .pwt
15 | .hpj
16 | .sql
17 | .inf
18 | .log
19 | .def
20 | .url
21 | .bat
22 | .aspx
23 | .idl
24 | .sys
25 | .resources
26 | .strings
27 | .md
28 | .yml
29 | .yaml
30 | .spelling
31 | .gitignore
32 | .gitattributes
33 | .gitmodules
34 | .csv
35 | .tsv
36 |
37 |
38 |
39 | CodeFiles
40 |
41 | .frm
42 | .inc
43 | .cpp
44 | .cls
45 | .c
46 | .hpp
47 | .vbs
48 | .java
49 | .cs
50 | .cxx
51 | .h
52 | .jav
53 | .bas
54 | .hxx
55 | .js
56 | .pl
57 | .rc
58 | .vb
59 | .json
60 | .resjson
61 | .fs
62 | .fsi
63 | .fsx
64 | .m
65 | .psm1
66 | .config
67 | .ps1
68 | .psd1
69 | .cmake
70 | .sh
71 | .cshtml
72 | .plist
73 | .mof
74 | .mc
75 |
76 |
77 |
78 | XML Files
79 |
80 | .xml
81 | .hxa
82 | .hxk
83 | .hxl
84 | .xsl
85 | .hxc
86 | .hxt
87 | .hxm
88 | .resx
89 | .hxe
90 | .hxf
91 | .hxv
92 | .acctb
93 | .accfl
94 | .xaml
95 | .ttml
96 | .ddue
97 | .sln
98 | .props
99 | .ps1xml
100 | .csproj
101 | .xsd
102 | .svg
103 | .clixml
104 | .nuspec
105 | .cdxml
106 | .manifest
107 |
108 |
109 |
110 | Microsoft Word Documents
111 |
112 | .doc
113 | .dot
114 | .wiz
115 |
116 |
117 |
118 | Microsoft Access Database Compatible
119 |
120 | .mdb
121 | .mda
122 | .mde
123 | .mpd
124 | .mdt
125 |
126 |
127 |
128 | Microsoft PowerPoint Presentation
129 |
130 | .ppt
131 | .pot
132 | .pps
133 |
134 |
135 |
136 | Microsoft Publisher Files
137 |
138 | .pub
139 |
140 |
141 |
142 | Microsoft Excel Workbooks
143 |
144 | .xls
145 | .xlt
146 |
147 |
148 |
149 | Pure Binary Files
150 |
151 | .com
152 | .bin
153 | .tlb
154 | .drv
155 | .fon
156 | .blg
157 | .gif
158 | .png
159 | .icns
160 | .ico
161 | .bmp
162 | .pfx
163 |
164 |
165 |
166 | Localization resource databases
167 |
168 | .edb
169 | .lcl
170 | .xlf
171 | .xliff
172 |
173 |
174 |
175 | Microsoft Project Files
176 |
177 | .mpp
178 | .mpt
179 |
180 |
181 |
182 | Microsoft Visio Files
183 |
184 | .vsd
185 | .vdx
186 | .vss
187 | .vst
188 |
189 |
190 |
191 | Windows Installer databases
192 |
193 | .msi
194 | .msm
195 |
196 |
197 |
198 | Zip Files
199 |
200 | .zip
201 | .accdt
202 | .axtr
203 |
204 |
205 |
206 | Cabinet / MS Compression Files
207 |
208 | .cab
209 |
210 |
211 |
212 | Table driven IME lexicons
213 |
214 | .mb
215 |
216 |
217 |
218 | IME ( IMD ) Files
219 |
220 | .imd
221 |
222 |
223 |
224 | TrueType Font Files
225 |
226 | .ttf
227 |
228 |
229 |
230 | Microsoft Outlook Mail Files
231 |
232 | .msg
233 | .oft
234 |
235 |
236 |
237 | HTML Help 2.0 Files / InfoTech5.x Storage System Files
238 |
239 | .its
240 | .hxh
241 | .hxr
242 | .hxw
243 | .hxi
244 | .hxs
245 | .hxq
246 |
247 |
248 |
249 | Adobe Acrobat PDF Files
250 |
251 | .pdf
252 |
253 |
254 |
255 | HTML Files / Web Page
256 |
257 | .htm
258 | .dtd
259 | .hhk
260 | .htw
261 | .asp
262 | .htc
263 | .htx
264 | .html
265 | .hhc
266 | .css
267 | .stm
268 |
269 |
270 |
271 | Rich Text Files
272 |
273 | .rtf
274 |
275 |
276 |
277 | Windows 3.x Write Files
278 |
279 | .wri
280 |
281 |
282 |
283 | MHTML Files
284 |
285 | .eml
286 | .nws
287 | .mht
288 |
289 |
290 |
291 | Word 2007 Files
292 |
293 | .docx
294 | .docm
295 | .dotx
296 | .dotm
297 |
298 |
299 |
300 | Excel 2007 Files
301 |
302 | .xlsx
303 | .xlsm
304 | .xltx
305 | .xltm
306 | .xlsb
307 | .xlam
308 |
309 |
310 |
311 | Power Point 2007 Files
312 |
313 | .pptx
314 | .pptm
315 | .potx
316 | .potm
317 | .ppsx
318 | .ppsm
319 | .ppam
320 |
321 |
322 |
323 | Access 2007 Files
324 |
325 | .accdb
326 | .accde
327 | .accdr
328 |
329 |
330 |
331 | Win32/64-based executable (image) Files
332 |
333 | .exe
334 | .dll
335 | .ocx
336 | .scr
337 | .acm
338 | .rll
339 | .cpl
340 | .mui
341 | .ax
342 | .ime
343 |
344 |
345 |
346 | HTML Help 1.0 Files
347 |
348 | .chm
349 |
350 |
351 |
352 | LocStudio lsg
353 |
354 | .lsg
355 |
356 |
357 |
358 | Microsoft Office OneNote Files
359 |
360 | .one
361 | .onepkg
362 |
363 |
364 |
365 | Custom Parsers
366 |
367 |
368 |
369 |
370 | Visio 2011 Files
371 |
372 | .vstx
373 | .vsdx
374 | .vssx
375 |
376 |
377 |
378 |
379 |
380 |
--------------------------------------------------------------------------------