Compare commits

..

28 Commits

Author SHA1 Message Date
unknown f48ffbcc11 Updated dobuild.ps1 2021-05-24 15:42:34 -07:00
unknown be08036a24 Bring in latest subsystem updates 2021-05-24 15:18:08 -07:00
unknown 53b693ab8e Fixed inherited properties 2021-05-24 14:41:18 -07:00
unknown 76f41549ad Fix NullReferenceException in DSC ClearCache() 2021-05-24 14:37:19 -07:00
Andrew a5787f0cb3 SubSystem work 1 2021-03-24 17:06:17 -07:00
Andrew 231356d2ba Changed namespace Internal.Json -> Internal.CrossPlatform 2021-01-28 13:54:32 -08:00
anmenaga 4a1c8e75e0 Class-based resource only support 2020-12-07 20:20:32 -08:00
anmenaga 67ee71793e Updated error reporting for class resources 2020-11-22 13:57:27 -08:00
anmenaga 86b0561f52 Fixed Get-DscResource shows the embedded class for class based resources 2020-11-20 22:35:22 -08:00
anmenaga a74f5ee8de Fixing Verbose message reporting from Class-based resources 2020-11-20 20:05:06 -08:00
anmenaga aa4652ce28 Added fix for PSModulePath resetting in Invoke-DscClassBasedResource 2020-10-01 15:55:28 -07:00
anmenaga 9ddb7e2305 Fix bug when same class-based module is in several module paths 2020-10-01 14:25:26 -07:00
anmenaga aa49a839e3 Disable cleaning caches in the end of Get-DscResource 2020-09-17 13:22:05 -07:00
anmenaga 82aa860cb1 remove hang related to composite resources 2020-09-16 12:51:52 -07:00
anmenaga 8b8e454b4e Merge branch 'master' into JsonWork 2020-09-14 17:39:17 -07:00
anmenaga 56e5460ef9 Make DSC_HOME env var cross platform 2020-09-01 23:08:18 -07:00
anmenaga eed19c33ed Updated namespace of SMA APIs 2020-09-01 10:54:50 -07:00
anmenaga c7f5c83843 Fixed typo in GetResourceFromKeyword 2020-08-24 03:15:30 -07:00
anmenaga 00be7c8e9d simplified schema 2020-08-23 23:41:40 -07:00
anmenaga 0f59c3cdba Fixed convertion cmdlet after namespace change 2020-08-21 15:12:51 -07:00
anmenaga d3b5218d0d Removed Internal from SMA APIs namespace 2020-08-20 17:32:06 -07:00
anmenaga 7f2d6ebf2e Started using Microsoft.PowerShell.DesiredStateConfiguration.Internal.Json namespace 2020-08-13 18:32:55 -07:00
anmenaga 5db42b0120 Bumped module version to 3.0.0 as was discussed offline 2020-08-13 18:20:54 -07:00
anmenaga bd0affdb4d Adding ConvertTo-DscJsonSchema cmdlet to DSC module 2020-08-11 21:19:02 -07:00
anmenaga 0b4412362b Set module Minimum PowerShellVersion to be 7.1 2020-08-11 16:44:31 -07:00
anmenaga 553a19715a Feedback 1 2020-08-11 16:40:20 -07:00
Andrew 94ca4dda32 Bumped module version to 2.0.6 2020-08-06 13:34:02 -07:00
Andrew 7cba5c16d5 adding BaseRegistration json files and ExportedCommands functionality 2020-08-05 16:41:28 -07:00
16 changed files with 4045 additions and 455 deletions
+50 -10
View File
@@ -9,22 +9,33 @@ pr:
branches:
include:
- master
resources:
repositories:
- repository: ComplianceRepo
type: github
endpoint: ComplianceGHRepo
name: PowerShell/compliance
- feature-*
paths:
exclude:
- /.dependabot/*
- /.poshchan/*
- /.github/**/*
- /.vscode/**/*
- /.vsts-ci/misc-analysis.yml
- /tools/**/*
- .editorconfig
- .gitattributes
- .gitignore
- /docs/**/*
- /CHANGELOG.md
- /CONTRIBUTING.md
- /README.md
- /LICENSE.txt
- /CODE_OF_CONDUCT.md
stages:
- stage: Build
displayName: Build PSDesiredStateConfiguration module
displayName: Build PowerShell Package
jobs:
- job: BuildPkg
displayName: Build Package
pool:
vmImage: windows-latest
vmImage: windows-2019
steps:
- template: templates/ci-build.yml
- pwsh: |
@@ -35,4 +46,33 @@ stages:
- pwsh: |
$(Build.SourcesDirectory)/build.ps1 -Publish -Signed
displayName: Publish
timeoutInMinutes: 10
timeoutInMinutes: 10
- stage: Test
displayName: Test Package
jobs:
- template: templates/ci-test.yml
parameters:
jobName: TestPkgWin
displayName: PowerShell Core on Windows
imageName: windows-2019
# Not supported on Windows PowerShell per PSD1
# - template: test.yml
# parameters:
# jobName: TestPkgWinPS
# displayName: Windows PowerShell on Windows
# imageName: windows-2019
# powershellExecutable: powershell
- template: templates/ci-test.yml
parameters:
jobName: TestPkgUbuntu16
displayName: PowerShell Core on Ubuntu 16.04
imageName: ubuntu-16.04
- template: templates/ci-test.yml
parameters:
jobName: TestPkgWinMacOS
displayName: PowerShell Core on macOS
imageName: macOS-10.14
+125 -161
View File
@@ -1,24 +1,36 @@
name: $(BuildDefinitionName)_$(date:yyMM).$(date:dd)$(rev:rrr)
trigger: none
resources:
repositories:
- repository: ComplianceRepo
type: github
endpoint: ComplianceGHRepo
name: PowerShell/compliance
trigger:
batch: true
branches:
include:
- master
paths:
exclude:
- /.dependabot/*
- /.poshchan/*
- /.github/**/*
- /.vscode/**/*
- /.vsts-ci/misc-analysis.yml
- /tools/**/*
- .editorconfig
- .gitattributes
- .gitignore
- /docs/**/*
- /CHANGELOG.md
- /CONTRIBUTING.md
- /README.md
- /LICENSE.txt
- /CODE_OF_CONDUCT.md
stages:
- stage: Build
displayName: Build PSDesiredStateConfiguration module
pool:
name: Package ES CodeHub Lab E
displayName: Build PowerShell Package
jobs:
- job: BuildPkg
displayName: Build Package
variables:
- group: ESRP
pool:
name: 'Package ES CodeHub Lab E'
steps:
- powershell: |
$powerShellPath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'powershell'
@@ -29,158 +41,110 @@ stages:
Write-Host "##$vstsCommandString"
displayName: Install PowerShell Core
- task: NuGetToolInstaller@1
displayName: 'Install NuGet 5.9.1'
- task: PkgESSetupBuild@10
displayName: 'Package ES - Setup Build'
inputs:
checkLatest: false
version: 5.9.1
productName: PSDesiredStateConfiguration
- pwsh: |
- template: templates/shouldsign.yml
- powershell: |
Get-ChildItem -Path env:
displayName: Capture environment for build
displayName: Capture environment
condition: succeededOrFailed()
- pwsh: |
$modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules'
if (Test-Path -Path $modulePath) {
Write-Verbose -Verbose "Deleting existing temp module path: $modulePath"
Remove-Item -Path $modulePath -Recurse -Force -ErrorAction Ignore
}
if (! (Test-Path -Path $modulePath)) {
Write-Verbose -Verbose "Creating new temp module path: $modulePath"
$null = New-Item -Path $modulePath -ItemType Directory
}
displayName: Create temporary module path
- template: templates/ci-build.yml
- powershell: |
Write-Verbose "BUILD_OUTPUT_PATH- $env:BUILD_OUTPUT_PATH" -Verbose
Write-Verbose "SIGNED_OUTPUT_PATH- $env:SIGNED_OUTPUT_PATH" -Verbose
Copy-Item $env:BUILD_OUTPUT_PATH $env:SIGNED_OUTPUT_PATH -Recurse -Force
displayName: Copy unsigned files first
- task: PkgESCodeSign@10
displayName: 'CodeSign tools/releaseBuild/signing.xml'
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
inputs:
signConfigXml: tools/releaseBuild/signing.xml
inPathRoot: '$(BUILD_OUTPUT_PATH)'
outPathRoot: '$(SIGNED_OUTPUT_PATH)'
condition: and(succeeded(), eq(variables['SHOULD_SIGN'], 'true'))
- task: PowerShell@1
displayName: 'Create catalog file'
inputs:
scriptType: inlineScript
inlineScript: |
$signedDir = "$env:SIGNED_OUTPUT_PATH\PSDesiredStateConfiguration"
New-FileCatalog -CatalogFilePath "$env:SIGNED_OUTPUT_PATH\PSDesiredStateConfiguration\PSDesiredStateConfiguration.cat" -Path "$signedDir"
- task: PkgESCodeSign@10
displayName: 'CodeSign tools/releaseBuild/FileCatalogSigning.xml'
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
inputs:
signConfigXml: tools/releaseBuild/FileCatalogSigning.xml
inPathRoot: '$(SIGNED_OUTPUT_PATH)'
outPathRoot: '$(SIGNED_OUTPUT_PATH)'
condition: and(succeeded(), eq(variables['SHOULD_SIGN'], 'true'))
- task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0
displayName: 'Component Detection'
- task: AntiMalware@3
inputs:
InputType: 'Basic'
ScanType: 'CustomScan'
FileDirPath: '$(SIGNED_OUTPUT_PATH)'
EnableServices: false
SupportLogOnError: false
TreatSignatureUpdateFailureAs: 'Warning'
SignatureFreshness: 'UpToDate'
TreatStaleSignatureAs: 'Error'
- task: PoliCheck@1
condition: succeededOrFailed()
inputs:
targetType: F
optionsFC: 0
optionsXS: 0
optionsPE: '1|2|3|4'
optionsHMENABLE: 0
optionsFTPATH: '$(Build.SourcesDirectory)\tools\terms\FileTypeSet.xml'
- task: CredScan@2
condition: succeededOrFailed()
# Publish results as artifacts
- task: PublishSecurityAnalysisLogs@3
condition: succeededOrFailed()
inputs:
ArtifactName: 'CodeAnalysisLogs'
ArtifactType: 'Container'
# Publish to TSA server
# - task: TSAUpload@1
# condition: succeededOrFailed()
# continueOnError: true
# inputs:
# tsaVersion: 'TsaV2'
# codebase: 'Existing'
# tsaEnvironment: 'PROD'
# codeBaseName: 'PSDesiredStateConfiguration_20190828'
# uploadAPIScan: false
# uploadBinSkim: false
# uploadCredScan: true
# uploadFortifySCA: false
# uploadFxCop: false
# uploadModernCop: false
# uploadPoliCheck: true
# uploadPREfast: false
# uploadRoslyn: false
# uploadTSLint: false
# uploadAsync: true
- pwsh: |
$modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules'
Write-Verbose -Verbose "Install PowerShellGet V3 to temp module path"
Save-Module -Name PowerShellGet -Path $modulePath -MinimumVersion 3.0.0-beta10 -AllowPrerelease -Force
Write-Verbose -Verbose "Install PlatyPS to temp module path"
Save-Module -Name "platyPS" -Path $modulePath -Force
Write-Verbose -Verbose "Install PSScriptAnalyzer to temp module path"
Save-Module -Name "PSScriptAnalyzer" -Path $modulePath -RequiredVersion 1.18.0 -Force
Write-Verbose -Verbose "Install Pester 4.X to temp module path"
Save-Module -Name "Pester" -MaximumVersion 4.99 -Path $modulePath -Force
Write-Verbose -Verbose "Install PSPackageProject to temp module path"
Save-Module -Name PSPackageProject -Path $modulePath -Force
displayName: Install PSPackageProject and dependencies
- pwsh: |
$modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules'
$env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath
$modPath = Join-Path -Path $modulePath -ChildPath PSPackageProject
Write-Verbose -Verbose "Importing PSPackageProject from: $modPath"
Import-Module -Name $modPath -Force
#
$(Build.SourcesDirectory)/build.ps1 -Build -Clean
displayName: Execute build
- pwsh: |
$signSrcPath = "$(Build.SourcesDirectory)\out\PSDesiredStateConfiguration"
# Set signing src path variable
$vstsCommandString = "vso[task.setvariable variable=signSrcPath]${signSrcPath}"
Write-Host "sending " + $vstsCommandString
Write-Host "##$vstsCommandString"
$signOutPath = "$(Build.SourcesDirectory)\signed\PSDesiredStateConfiguration"
$null = New-Item -ItemType Directory -Path $signOutPath
# Set signing out path variable
$vstsCommandString = "vso[task.setvariable variable=signOutPath]${signOutPath}"
Write-Host "sending " + $vstsCommandString
Write-Host "##$vstsCommandString"
# Set path variable for guardian codesign validation
$vstsCommandString = "vso[task.setvariable variable=GDN_CODESIGN_TARGETDIRECTORY]${signOutPath}"
Write-Host "sending " + $vstsCommandString
Write-Host "##$vstsCommandString"
displayName: Setup variables for signing
- template: EsrpSign.yml@ComplianceRepo
parameters:
# the folder which contains the binaries to sign
buildOutputPath: $(signSrcPath)
# the location to put the signed output
signOutputPath: $(signOutPath)
# the certificate ID to use
certificateId: "CP-230012"
# the file pattern to use, comma separated
pattern: '*.psm1,*.psd1'
- pwsh: |
$repoName = [guid]::newGuid().ToString("N")
$packageRoot = "$(Build.SourcesDirectory)\signed\PSDesiredStateConfiguration"
Register-PSRepository -Name $repoName -SourceLocation $packageRoot -InstallationPolicy Trusted
Publish-Module -Path $packageRoot -Repository $repoName
Unregister-PSRepository -Name $repoName
Get-ChildItem -Recurse -Path $packageRoot | Write-Verbose -Verbose
$nupkgPath = (Get-ChildItem -Recurse -Path $packageRoot -Filter "PSDesiredStateConfiguration*.nupkg" | select -First 1).FullName
Write-Host "##vso[artifact.upload containerfolder=nupkg;artifactname=nupkg]$nupkgPath"
displayName: Package and publish nupkg
name: ProduceNupkg
- publish: "$(signSrcPath)"
artifact: Build
displayName: Publish build
- publish: "$(signOutPath)"
artifact: SignedBuild
displayName: Publish signed build
- stage: Compliance
displayName: Compliance
dependsOn: Build
jobs:
- job: Compliance_Job
pool:
name: Package ES CodeHub Lab E
steps:
- checkout: self
- checkout: ComplianceRepo
- download: current
artifact: SignedBuild
- pwsh: |
Get-ChildItem -Path "$(Pipeline.Workspace)\SignedBuild" -Recurse
displayName: Capture downloaded artifacts
- template: script-module-compliance.yml@ComplianceRepo
parameters:
# component-governance
sourceScanPath: '$(Pipeline.Workspace)\SignedBuild'
# credscan
suppressionsFile: ''
# TermCheck
optionsRulesDBPath: ''
optionsFTPath: ''
# tsa-upload
codeBaseName: 'PSDesiredStateConfiguration_20210423'
# selections
APIScan: false # set to false when not using Windows APIs.
- stage: Deploy
displayName: Publish to PowerShell gallery
dependsOn:
- Build
- Compliance
jobs:
- deployment: DeployPowerShellGallery
displayName: Deploy nupkg to PowerShell Gallery
pool:
vmImage: windows-latest
environment: 'PSDesiredStateConfiguration-ReleaseApproval'
strategy:
runOnce:
deploy:
steps:
- download: current
artifact: 'nupkg'
- task: NuGetToolInstaller@1
displayName: 'Install NuGet 5.9.1'
inputs:
checkLatest: false
version: 5.9.1
- task: NuGetCommand@2
displayName: 'NuGet push'
inputs:
command: push
packagesToPush: '$(Pipeline.Workspace)\nupkg\PSDesiredStateConfiguration.*.nupkg'
nuGetFeedType: external
publishFeedCredentials: 'PowerShellGallery'
$(Build.SourcesDirectory)/build.ps1 -Publish -Signed
displayName: Publish
timeoutInMinutes: 10
+19
View File
@@ -0,0 +1,19 @@
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
steps:
- script: echo Hello, world!
displayName: 'Run a one-line script'
- script: |
echo Add other tasks to build, test, and deploy your project.
echo See https://aka.ms/yaml
displayName: 'Run a multi-line script'
+21 -17
View File
@@ -13,34 +13,38 @@ Implement build and packaging of the package and place the output $OutDirectory/
function DoBuild
{
Write-Verbose -Verbose -Message "Starting DoBuild"
Write-Verbose -Verbose -Message "Copying module files to '${OutDirectory}/${ModuleName}'"
# copy psm1 and psd1 files
copy-item "${SrcPath}/*" "${OutDirectory}/${ModuleName}" -Recurse
#
# copy help
Write-Verbose -Verbose -Message "Copying help files to '${OutDirectory}/${ModuleName}'"
copy-item -Recurse "${HelpPath}/${Culture}" "${OutDirectory}/${ModuleName}"
# Write-Verbose -Verbose -Message "Copying help files to '${OutDirectory}/${ModuleName}'"
# copy-item -Recurse "${HelpPath}/${Culture}" "${OutDirectory}/${ModuleName}"
if ( Test-Path "${SrcPath}/code" ) {
$subsystemCodePath = Resolve-Path "${SrcPath}\..\DscSubsystem"
$subsystemBinPath = "bin/Debug/net6.0/publish/Microsoft.PowerShell.DscSubsystem.dll"
Write-Verbose -Verbose -Message "Subsystem code path ${subsystemCodePath}"
if ( Test-Path $subsystemCodePath )
{
Write-Verbose -Verbose -Message "Building assembly and copying to '${OutDirectory}/${ModuleName}'"
# build code and place it in the staging location
try {
Push-Location "${SrcPath}/code"
$result = dotnet publish
copy-item "bin/Debug/netstandard2.0/publish/${ModuleName}.dll" "${OutDirectory}/${ModuleName}"
Push-Location $subsystemCodePath
$result = dotnet publish
if (Test-Path $subsystemBinPath)
{
Copy-Item $subsystemBinPath "${OutDirectory}/${ModuleName}"
}
catch {
$result | ForEach-Object { Write-Warning $_ }
Write-Error "dotnet build failed"
}
finally {
Pop-Location
else
{
Write-Error "dotnet build failed - $subsystemBinPath not found - $result"
}
Pop-Location
}
else {
Write-Verbose -Verbose -Message "No code to build in '${SrcPath}/code'"
Write-Verbose -Verbose -Message "No code to build in '$subsystemCodePath'"
}
## Add build and packaging here
+89
View File
@@ -0,0 +1,89 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#nullable enable
using System;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using System.Management.Automation;
using System.Management.Automation.Internal;
using System.Management.Automation.Language;
namespace System.Management.Automation.Subsystem.DSC
{
/// <summary>
/// Interface for implementing a cross platform desired state configuration component.
/// </summary>
public class CrossPlatformDsc : ICrossPlatformDsc, IModuleAssemblyInitializer
{
/// <summary>
/// Gets the unique identifier for a subsystem implementation.
/// </summary>
public Guid Id { get {return Guid.NewGuid();} }
/// <summary>
/// Gets the name of a subsystem implementation.
/// </summary>
public string Name { get {return "Cross platform desired state configuration";} }
/// <summary>
/// Gets the description of a subsystem implementation.
/// </summary>
public string Description { get {return "Cross platform desired state configuration";} }
/// <summary>
/// Gets a dictionary that contains the functions to be defined at the global scope of a PowerShell session.
/// Key: function name; Value: function script.
/// </summary>
Dictionary<string, string>? ISubsystem.FunctionsToDefine => null;
/// <summary>
/// Test.
/// </summary>
public void LoadDefaultKeywords(Collection<Exception> errors)
{
Microsoft.PowerShell.DesiredStateConfiguration.Internal.CrossPlatform.DscClassCache.LoadDefaultCimKeywords(errors);
}
/// <summary>
/// Default summary.
/// </summary>
public void ClearCache()
{
Microsoft.PowerShell.DesiredStateConfiguration.Internal.CrossPlatform.DscClassCache.ClearCache();
}
/// <summary>
/// Default summary.
/// </summary>
public string GetDSCResourceUsageString(DynamicKeyword keyword)
{
return Microsoft.PowerShell.DesiredStateConfiguration.Internal.CrossPlatform.DscClassCache.GetDSCResourceUsageString(keyword);
}
/// <summary>
/// Checks if a string is one of dynamic keywords that can be used in both configuration and meta configuration.
/// </summary>
public bool IsSystemResourceName(string name)
{
return Microsoft.PowerShell.DesiredStateConfiguration.Internal.CrossPlatform.DscClassCache.SystemResourceNames.Contains(name);
}
/// <summary>
/// Checks if a string matches default module name used for meta configuration resources.
/// </summary>
public bool IsDefaultModuleNameForMetaConfigResource(string name)
{
return name.Equals(Microsoft.PowerShell.DesiredStateConfiguration.Internal.CrossPlatform.DscClassCache.DefaultModuleInfoForMetaConfigResource.Item1, StringComparison.OrdinalIgnoreCase);
}
public void OnImport()
{
if (SubsystemManager.GetSubsystem<ICrossPlatformDsc>() == null)
{
SubsystemManager.RegisterSubsystem(SubsystemKind.CrossPlatformDsc, this);
}
}
}
}
+68
View File
@@ -0,0 +1,68 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Management.Automation;
using System.Security;
namespace Microsoft.PowerShell.DesiredStateConfiguration.Internal.CrossPlatform
{
/// <summary>
/// Class that does high level Cim schema parsing.
/// </summary>
internal class CimDSCParser
{
private readonly JsonDeserializer _jsonDeserializer;
internal CimDSCParser()
{
_jsonDeserializer = JsonDeserializer.Create();
}
internal IEnumerable<PSObject> ParseSchemaJson(string filePath, bool useNewRunspace = false)
{
try
{
string json = File.ReadAllText(filePath);
string fileNameDefiningClass = Path.GetFileNameWithoutExtension(filePath);
int dotIndex = fileNameDefiningClass.IndexOf(".schema", StringComparison.InvariantCultureIgnoreCase);
if (dotIndex != -1)
{
fileNameDefiningClass = fileNameDefiningClass.Substring(0, dotIndex);
}
IEnumerable<PSObject> result = _jsonDeserializer.DeserializeClasses(json, useNewRunspace);
foreach (dynamic classObject in result)
{
string superClassName = classObject.SuperClassName;
string className = classObject.ClassName;
if (string.Equals(superClassName, "OMI_BaseResource", StringComparison.OrdinalIgnoreCase))
{
// Get the name of the file without schema.mof/json extension
if (!className.Equals(fileNameDefiningClass, StringComparison.OrdinalIgnoreCase))
{
PSInvalidOperationException e = PSTraceSource.NewInvalidOperationException(
ParserStrings.ClassNameNotSameAsDefiningFile, className, fileNameDefiningClass);
throw e;
}
}
}
return result;
}
catch (Exception exception)
{
PSInvalidOperationException e = PSTraceSource.NewInvalidOperationException(
exception, ParserStrings.CimDeserializationError, filePath);
e.SetErrorId("CimDeserializationError");
throw e;
}
}
}
}
+72
View File
@@ -0,0 +1,72 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Management.Automation;
using System.Management.Automation.Runspaces;
namespace Microsoft.PowerShell.DesiredStateConfiguration.Internal.CrossPlatform
{
internal class JsonDeserializer
{
#region Constructors
/// <summary>
/// Instantiates a default deserializer.
/// </summary>
/// <returns>Default deserializer.</returns>
public static JsonDeserializer Create()
{
return new JsonDeserializer();
}
#endregion Constructors
#region Methods
/// <summary>
/// Returns schema of Cim classes from specified json file.
/// </summary>
/// <param name="json">Json text to deserialize.</param>
/// <param name="useNewRunspace">If a new runspace should be used.</param>
/// <returns>Deserialized PSObjects.</returns>
public IEnumerable<PSObject> DeserializeClasses(string json, bool useNewRunspace = false)
{
if (string.IsNullOrEmpty(json))
{
throw new ArgumentNullException(nameof(json));
}
System.Management.Automation.PowerShell powerShell = null;
if (useNewRunspace)
{
// currently using RunspaceMode.NewRunspace will reset PSModulePath env var for the entire process
// this is something we want to avoid in DSC GuestConfigAgent scenario, so we use following workaround
var s_iss = InitialSessionState.CreateDefault();
s_iss.EnvironmentVariables.Add(
new SessionStateVariableEntry(
"PSModulePath",
Environment.GetEnvironmentVariable("PSModulePath"),
description: null));
powerShell = System.Management.Automation.PowerShell.Create(s_iss);
}
else
{
powerShell = System.Management.Automation.PowerShell.Create(RunspaceMode.CurrentRunspace);
}
using (powerShell)
{
return powerShell.AddCommand("Microsoft.PowerShell.Utility\\ConvertFrom-Json")
.AddParameter("InputObject", json)
.AddParameter("Depth", 100) // maximum supported by cmdlet
.Invoke();
}
}
#endregion Methods
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<AssemblyName>Microsoft.PowerShell.DscSubsystem</AssemblyName>
<DelaySign>true</DelaySign>
<AssemblyOriginatorKeyFile>visualstudiopublic.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<ItemGroup>
<!-- TEMPORARY: This needs to be replaced with <PackageReference Include="System.Management.Automation" /> when Preview 6 is published with subsystem interface. -->
<Reference Include="C:\Temp\SMA-Reference\System.Management.Automation.dll"></Reference>
</ItemGroup>
</Project>
Binary file not shown.
@@ -0,0 +1,232 @@
[
{
"ClassName": "MSFT_Credential",
"ClassVersion": "1.0.0",
"ClassProperties": [
{
"Name": "UserName",
"CimType": "String",
"Qualifiers": {
"MaxLen": 256
}
},
{
"Name": "Password",
"CimType": "String"
}
]
},
{
"ClassName": "OMI_BaseResource",
"ClassVersion": "1.0.0",
"ClassProperties": [
{
"Name": "ResourceId",
"CimType": "String",
"Qualifiers": {
"Required": true
}
},
{
"Name": "SourceInfo",
"CimType": "String",
"Qualifiers": {
"Write": true
}
},
{
"Name": "DependsOn",
"CimType": "StringArray",
"Qualifiers": {
"Write": true
}
},
{
"Name": "ModuleName",
"CimType": "String",
"Qualifiers": {
"Required": true
}
},
{
"Name": "ModuleVersion",
"CimType": "String",
"Qualifiers": {
"Required": true
}
},
{
"Name": "ConfigurationName",
"CimType": "String",
"Qualifiers": {
"Write": true
}
},
{
"Name": "PsDscRunAsCredential",
"CimType": "Instance",
"ReferenceClassName": "MSFT_Credential",
"Qualifiers": {
"Write": true,
"EmbeddedInstance": "MSFT_Credential"
}
}
]
},
{
"ClassName": "MSFT_KeyValuePair",
"ClassVersion": "1.0.0",
"ClassProperties": [
{
"Name": "Key",
"CimType": "String",
"Qualifiers": {
"Key": true
}
},
{
"Name": "Value",
"CimType": "String",
"Qualifiers": {
"Write": true
}
}
]
},
{
"ClassName": "MSFT_BaseConfigurationProviderRegistration",
"ClassVersion": "1.0.0",
"ClassProperties": [
{
"Name": "ClassName",
"CimType": "String",
"Qualifiers": {
"Key": true
}
},
{
"Name": "DSCEngineCompatVersion",
"CimType": "String"
},
{
"Name": "DSCModuleVersion",
"CimType": "String"
}
]
},
{
"ClassName": "MSFT_CimConfigurationProviderRegistration",
"ClassVersion": "1.0.0",
"SuperClassName": "MSFT_BaseConfigurationProviderRegistration",
"ClassProperties": [
{
"Name": "Namespace",
"CimType": "String"
}
]
},
{
"ClassName": "MSFT_PSConfigurationProviderRegistration",
"ClassVersion": "1.0.0",
"SuperClassName": "MSFT_BaseConfigurationProviderRegistration",
"ClassProperties": [
{
"Name": "ModuleName",
"CimType": "String"
},
{
"Name": "ProviderPath",
"CimType": "String"
},
{
"Name": "ModulePath",
"CimType": "String"
}
]
},
{
"ClassName": "OMI_ConfigurationDocument",
"ClassVersion": "1.0.0",
"ClassProperties": [
{
"Name": "Version",
"CimType": "String"
},
{
"Name": "Author",
"CimType": "String"
},
{
"Name": "Copyright",
"CimType": "String"
},
{
"Name": "HelpInfoUri",
"CimType": "String"
},
{
"Name": "ContentType",
"CimType": "String"
},
{
"Name": "GenerationDate",
"CimType": "String"
},
{
"Name": "GenerationHost",
"CimType": "String"
},
{
"Name": "Name",
"CimType": "String"
},
{
"Name": "MinimumCompatibleVersion",
"CimType": "String"
},
{
"Name": "CompatibleVersionAdditionalProperties",
"CimType": "StringArray"
},
{
"Name": "UseCms",
"CimType": "Boolean"
}
]
},
{
"ClassName": "OMI_MetaConfigurationResource",
"ClassVersion": "1.0.0",
"ClassProperties": [
{
"Name": "ResourceId",
"CimType": "String",
"Qualifiers": {
"Required": true
}
},
{
"Name": "SourceInfo",
"CimType": "String",
"Qualifiers": {
"Write": true
}
}
]
},
{
"ClassName": "OMI_ResourceModuleManager",
"ClassVersion": "1.0.0",
"SuperClassName": "OMI_MetaConfigurationResource"
},
{
"ClassName": "OMI_ConfigurationDownloadManager",
"ClassVersion": "1.0.0",
"SuperClassName": "OMI_MetaConfigurationResource"
},
{
"ClassName": "OMI_ReportManager",
"ClassVersion": "1.0.0",
"SuperClassName": "OMI_MetaConfigurationResource"
}
]
@@ -0,0 +1,218 @@
{
"ClassName": "MSFT_DSCMetaConfiguration",
"FriendlyName": "LocalConfigurationManager",
"ClassVersion": "1.0.0",
"ClassProperties": [
{
"Name": "ConfigurationModeFrequencyMins",
"CimType": "UInt32"
},
{
"Name": "RebootNodeIfNeeded",
"CimType": "Boolean"
},
{
"Name": "ConfigurationMode",
"CimType": "String",
"Qualifiers": {
"ValueMap": [
"ApplyOnly",
"ApplyAndMonitor",
"ApplyAndAutoCorrect",
"MonitorOnly"
],
"Values": [
"ApplyOnly",
"ApplyAndMonitor",
"ApplyAndAutoCorrect",
"MonitorOnly"
]
}
},
{
"Name": "ActionAfterReboot",
"CimType": "String",
"Qualifiers": {
"ValueMap": [
"ContinueConfiguration",
"StopConfiguration"
],
"Values": [
"ContinueConfiguration",
"StopConfiguration"
]
}
},
{
"Name": "Credential",
"CimType": "Instance",
"ReferenceClassName": "MSFT_Credential",
"Qualifiers": {
"EmbeddedInstance": "MSFT_Credential"
}
},
{
"Name": "RefreshMode",
"CimType": "String",
"Qualifiers": {
"ValueMap": [
"Push",
"Pull",
"Disabled"
],
"Values": [
"Push",
"Pull",
"Disabled"
]
}
},
{
"Name": "CertificateID",
"CimType": "String"
},
{
"Name": "ConfigurationID",
"CimType": "String"
},
{
"Name": "DownloadManagerName",
"CimType": "String"
},
{
"Name": "DownloadManagerCustomData",
"CimType": "InstanceArray",
"ReferenceClassName": "MSFT_KeyValuePair",
"Qualifiers": {
"EmbeddedInstance": "MSFT_KeyValuePair"
}
},
{
"Name": "RefreshFrequencyMins",
"CimType": "UInt32"
},
{
"Name": "AllowModuleOverwrite",
"CimType": "Boolean"
},
{
"Name": "DebugMode",
"CimType": "StringArray",
"Qualifiers": {
"ValueMap": [
"None",
"ForceModuleImport",
"All",
"ResourceScriptBreakAll",
"ResourceScriptBreakpoint"
],
"Values": [
"None",
"ForceModuleImport",
"All",
"ResourceScriptBreakAll",
"ResourceScriptBreakpoint"
]
}
},
{
"Name": "LCMVersion",
"CimType": "String",
"Qualifiers": {
"Read": true
}
},
{
"Name": "LCMCompatibleVersions",
"CimType": "StringArray",
"Qualifiers": {
"Read": true
}
},
{
"Name": "LCMState",
"CimType": "String",
"Qualifiers": {
"Read": true,
"ValueMap": [
"Idle",
"Busy",
"PendingReboot",
"PendingConfiguration"
],
"Values": [
"Idle",
"Busy",
"PendingReboot",
"PendingConfiguration"
]
}
},
{
"Name": "LCMStateDetail",
"CimType": "String",
"Qualifiers": {
"Read": true
}
},
{
"Name": "ConfigurationDownloadManagers",
"CimType": "InstanceArray",
"ReferenceClassName": "OMI_ConfigurationDownloadManager",
"Qualifiers": {
"EmbeddedInstance": "OMI_ConfigurationDownloadManager"
}
},
{
"Name": "ResourceModuleManagers",
"CimType": "InstanceArray",
"ReferenceClassName": "OMI_ResourceModuleManager",
"Qualifiers": {
"EmbeddedInstance": "OMI_ResourceModuleManager"
}
},
{
"Name": "ReportManagers",
"CimType": "InstanceArray",
"ReferenceClassName": "OMI_ReportManager",
"Qualifiers": {
"EmbeddedInstance": "OMI_ReportManager"
}
},
{
"Name": "PartialConfigurations",
"CimType": "InstanceArray",
"ReferenceClassName": "MSFT_PartialConfiguration",
"Qualifiers": {
"EmbeddedInstance": "MSFT_PartialConfiguration"
}
},
{
"Name": "StatusRetentionTimeInDays",
"CimType": "UInt32"
},
{
"Name": "AgentId",
"CimType": "String",
"Qualifiers": {
"Read": true
}
},
{
"Name": "SignatureValidationPolicy",
"CimType": "String"
},
{
"Name": "SignatureValidations",
"CimType": "InstanceArray",
"ReferenceClassName": "MSFT_SignatureValidation",
"Qualifiers": {
"EmbeddedInstance": "MSFT_SignatureValidation"
}
},
{
"Name": "MaximumDownloadSizeMB",
"CimType": "UInt32"
}
]
}
@@ -0,0 +1,455 @@
[
{
"ClassName": "MSFT_WebDownloadManager",
"FriendlyName": "ConfigurationRepositoryWeb",
"ClassVersion": "1.0.0",
"SuperClassName": "OMI_ConfigurationDownloadManager",
"ClassProperties": [
{
"Name": "ServerURL",
"CimType": "String",
"Qualifiers": {
"Key": true
}
},
{
"Name": "CertificateID",
"CimType": "String"
},
{
"Name": "AllowUnsecureConnection",
"CimType": "Boolean"
},
{
"Name": "RegistrationKey",
"CimType": "String"
},
{
"Name": "ConfigurationNames",
"CimType": "StringArray"
},
{
"Name": "ProxyURL",
"CimType": "String"
},
{
"Name": "ProxyCredential",
"CimType": "Instance",
"ReferenceClassName": "MSFT_Credential",
"Qualifiers": {
"EmbeddedInstance": "MSFT_Credential"
}
}
]
},
{
"ClassName": "MSFT_FileDownloadManager",
"FriendlyName": "ConfigurationRepositoryShare",
"ClassVersion": "1.0.0",
"SuperClassName": "OMI_ConfigurationDownloadManager",
"ClassProperties": [
{
"Name": "SourcePath",
"CimType": "String",
"Qualifiers": {
"Key": true
}
},
{
"Name": "Credential",
"CimType": "Instance",
"ReferenceClassName": "MSFT_Credential",
"Qualifiers": {
"EmbeddedInstance": "MSFT_Credential"
}
}
]
},
{
"ClassName": "MSFT_WebResourceManager",
"FriendlyName": "ResourceRepositoryWeb",
"ClassVersion": "1.0.0",
"SuperClassName": "OMI_ResourceModuleManager",
"ClassProperties": [
{
"Name": "ServerURL",
"CimType": "String",
"Qualifiers": {
"Key": true
}
},
{
"Name": "CertificateID",
"CimType": "String"
},
{
"Name": "AllowUnsecureConnection",
"CimType": "Boolean"
},
{
"Name": "RegistrationKey",
"CimType": "String"
},
{
"Name": "ProxyURL",
"CimType": "String"
},
{
"Name": "ProxyCredential",
"CimType": "Instance",
"ReferenceClassName": "MSFT_Credential",
"Qualifiers": {
"EmbeddedInstance": "MSFT_Credential"
}
}
]
},
{
"ClassName": "MSFT_FileResourceManager",
"FriendlyName": "ResourceRepositoryShare",
"ClassVersion": "1.0.0",
"SuperClassName": "OMI_ResourceModuleManager",
"ClassProperties": [
{
"Name": "SourcePath",
"CimType": "String",
"Qualifiers": {
"Key": true
}
},
{
"Name": "Credential",
"CimType": "Instance",
"ReferenceClassName": "MSFT_Credential",
"Qualifiers": {
"EmbeddedInstance": "MSFT_Credential"
}
}
]
},
{
"ClassName": "MSFT_WebReportManager",
"FriendlyName": "ReportServerWeb",
"ClassVersion": "1.0.0",
"SuperClassName": "OMI_ReportManager",
"ClassProperties": [
{
"Name": "ServerURL",
"CimType": "String",
"Qualifiers": {
"Key": true
}
},
{
"Name": "CertificateID",
"CimType": "String"
},
{
"Name": "AllowUnsecureConnection",
"CimType": "Boolean"
},
{
"Name": "RegistrationKey",
"CimType": "String"
},
{
"Name": "ProxyURL",
"CimType": "String"
},
{
"Name": "ProxyCredential",
"CimType": "Instance",
"ReferenceClassName": "MSFT_Credential",
"Qualifiers": {
"EmbeddedInstance": "MSFT_Credential"
}
}
]
},
{
"ClassName": "MSFT_PartialConfiguration",
"FriendlyName": "PartialConfiguration",
"ClassVersion": "1.0.0",
"SuperClassName": "OMI_MetaConfigurationResource",
"ClassProperties": [
{
"Name": "Description",
"CimType": "String",
"Qualifiers": {
"Write": true
}
},
{
"Name": "ExclusiveResources",
"CimType": "StringArray",
"Qualifiers": {
"Write": true
}
},
{
"Name": "ConfigurationSource",
"CimType": "StringArray",
"Qualifiers": {
"Write": true
}
},
{
"Name": "ResourceModuleSource",
"CimType": "StringArray",
"Qualifiers": {
"Write": true
}
},
{
"Name": "DependsOn",
"CimType": "StringArray",
"Qualifiers": {
"Write": true
}
},
{
"Name": "RefreshMode",
"CimType": "String",
"Qualifiers": {
"ValueMap": [
"Push",
"Pull",
"Disabled"
],
"Values": [
"Push",
"Pull",
"Disabled"
]
}
}
]
},
{
"ClassName": "MSFT_SignatureValidation",
"FriendlyName": "SignatureValidation",
"ClassVersion": "1.0.0",
"SuperClassName": "OMI_MetaConfigurationResource",
"ClassProperties": [
{
"Name": "TrustedStorePath",
"CimType": "String",
"Qualifiers": {
"Write": true
}
},
{
"Name": "SignedItemType",
"CimType": "StringArray",
"Qualifiers": {
"ValueMap": [
"Configuration",
"Module"
],
"Values": [
"Configuration",
"Module"
]
}
}
]
},
{
"ClassName": "MSFT_DSCMetaConfigurationV2",
"FriendlyName": "Settings",
"ClassVersion": "2.0.0",
"ClassProperties": [
{
"Name": "ConfigurationModeFrequencyMins",
"CimType": "UInt32"
},
{
"Name": "RebootNodeIfNeeded",
"CimType": "Boolean"
},
{
"Name": "ConfigurationMode",
"CimType": "String",
"Qualifiers": {
"ValueMap": [
"ApplyOnly",
"ApplyAndMonitor",
"ApplyAndAutoCorrect",
"MonitorOnly"
],
"Values": [
"ApplyOnly",
"ApplyAndMonitor",
"ApplyAndAutoCorrect",
"MonitorOnly"
]
}
},
{
"Name": "ActionAfterReboot",
"CimType": "String",
"Qualifiers": {
"ValueMap": [
"ContinueConfiguration",
"StopConfiguration"
],
"Values": [
"ContinueConfiguration",
"StopConfiguration"
]
}
},
{
"Name": "RefreshMode",
"CimType": "String",
"Qualifiers": {
"ValueMap": [
"Push",
"Pull",
"Disabled"
],
"Values": [
"Push",
"Pull",
"Disabled"
]
}
},
{
"Name": "CertificateID",
"CimType": "String"
},
{
"Name": "ConfigurationID",
"CimType": "String"
},
{
"Name": "RefreshFrequencyMins",
"CimType": "UInt32"
},
{
"Name": "AllowModuleOverwrite",
"CimType": "Boolean"
},
{
"Name": "DebugMode",
"CimType": "StringArray",
"Qualifiers": {
"ValueMap": [
"None",
"ForceModuleImport",
"All",
"ResourceScriptBreakAll",
"ResourceScriptBreakpoint"
],
"Values": [
"None",
"ForceModuleImport",
"All",
"ResourceScriptBreakAll",
"ResourceScriptBreakpoint"
]
}
},
{
"Name": "LCMVersion",
"CimType": "String",
"Qualifiers": {
"Read": true
}
},
{
"Name": "LCMCompatibleVersions",
"CimType": "StringArray",
"Qualifiers": {
"Read": true
}
},
{
"Name": "LCMState",
"CimType": "String",
"Qualifiers": {
"Read": true,
"ValueMap": [
"Idle",
"Busy",
"PendingReboot",
"PendingConfiguration"
],
"Values": [
"Idle",
"Busy",
"PendingReboot",
"PendingConfiguration"
]
}
},
{
"Name": "LCMStateDetail",
"CimType": "String",
"Qualifiers": {
"Read": true
}
},
{
"Name": "ConfigurationDownloadManagers",
"CimType": "InstanceArray",
"ReferenceClassName": "OMI_ConfigurationDownloadManager",
"Qualifiers": {
"EmbeddedInstance": "OMI_ConfigurationDownloadManager"
}
},
{
"Name": "ResourceModuleManagers",
"CimType": "InstanceArray",
"ReferenceClassName": "OMI_ResourceModuleManager",
"Qualifiers": {
"EmbeddedInstance": "OMI_ResourceModuleManager"
}
},
{
"Name": "ReportManagers",
"CimType": "InstanceArray",
"ReferenceClassName": "OMI_ReportManager",
"Qualifiers": {
"EmbeddedInstance": "OMI_ReportManager"
}
},
{
"Name": "PartialConfigurations",
"CimType": "InstanceArray",
"ReferenceClassName": "MSFT_PartialConfiguration",
"Qualifiers": {
"EmbeddedInstance": "MSFT_PartialConfiguration"
}
},
{
"Name": "StatusRetentionTimeInDays",
"CimType": "UInt32"
},
{
"Name": "AgentId",
"CimType": "String",
"Qualifiers": {
"Read": true
}
},
{
"Name": "SignatureValidationPolicy",
"CimType": "String"
},
{
"Name": "SignatureValidations",
"CimType": "InstanceArray",
"ReferenceClassName": "MSFT_SignatureValidation",
"Qualifiers": {
"EmbeddedInstance": "MSFT_SignatureValidation"
}
},
{
"Name": "MaximumDownloadSizeMB",
"CimType": "UInt32"
}
]
}
]
@@ -9,7 +9,7 @@
RootModule = 'PSDesiredStateConfiguration.psm1'
# Version number of this module.
moduleVersion = '2.0.5'
moduleVersion = '3.0.0'
# Supported PSEditions
CompatiblePSEditions = @('Core')
@@ -30,7 +30,7 @@ Copyright = '(c) Microsoft Corporation. All rights reserved.'
Description = 'PowerShell Desired State Configuration'
# Minimum version of the Windows PowerShell engine required by this module
PowerShellVersion = '6.1'
PowerShellVersion = '7.1'
# Name of the Windows PowerShell host required by this module
# PowerShellHostName = ''
@@ -48,7 +48,7 @@ PowerShellVersion = '6.1'
# ProcessorArchitecture = ''
# Modules that must be imported into the global environment prior to importing this module
# RequiredModules = @()
#RequiredModules = @()
# Assemblies that must be loaded prior to importing this module
# RequiredAssemblies = @()
@@ -63,7 +63,7 @@ PowerShellVersion = '6.1'
# FormatsToProcess = @()
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
# NestedModules = @()
NestedModules = @('Microsoft.PowerShell.DscSubsystem.dll')
# 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.
FunctionsToExport = @(
@@ -71,6 +71,7 @@ FunctionsToExport = @(
'New-DscChecksum'
'Get-DscResource'
'Invoke-DscResource'
'ConvertTo-DscJsonSchema'
)
@@ -16,7 +16,7 @@ data LocalizedData
InvalidConfigurationName = Invalid Configuration Name '{0}' is specified. Standard names may only contain letters (a-z, A-Z), numbers (0-9), and underscore (_). The name may not be null or empty, and should start with a letter.
InvalidResourceSpecification = Found more than one resource named '{0}'. Please use the module specification to be more specific.
UnsupportedResourceImplementation = The resource '{0}' implemented as '{1}' is not supported by Invoke-DscResource.
NoValidConfigFileFound = No valid config files (mof,zip) were found.
NoValidConfigFileFound = No valid config files (json,zip) were found.
InputFileNotExist=File {0} doesn't exist.
FileReadError=Error Reading file {0}.
MatchingFileNotFound=No matching file found.
@@ -76,7 +76,7 @@ Import-LocalizedData -BindingVariable LocalizedData -FileName PSDesiredStateCon
Import-Module $PSScriptRoot/helpers/DscResourceInfo.psm1
# Set DSC HOME environment variable.
$env:DSC_HOME = "$PSScriptRoot/Configuration"
$env:DSC_HOME = Join-Path $PSScriptRoot "Configuration"
$script:V1MetaConfigPropertyList = @('ConfigurationModeFrequencyMins', 'RebootNodeIfNeeded', 'ConfigurationMode', 'ActionAfterReboot', 'RefreshMode', 'CertificateID', 'ConfigurationID', 'DownloadManagerName', 'DownloadManagerCustomData', 'RefreshFrequencyMins', 'AllowModuleOverwrite', 'DebugMode', 'Credential')
$script:DirectAccessMetaConfigPropertyList = @('AllowModuleOverWrite', 'CertificateID', 'ConfigurationDownloadManagers', 'ResourceModuleManagers', 'DebugMode', 'RebootNodeIfNeeded', 'RefreshMode', 'ConfigurationAgent')
@@ -307,7 +307,7 @@ function ConvertTo-MOFInstance
elseif ($Value -is [PSCredential] )
{
# If the input object is a PSCredential, turn it into an MSFT_Credential with an encrypted password.
$clearText = [Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache]::GetStringFromSecureString($Value.Password)
$clearText = [Microsoft.PowerShell.DesiredStateConfiguration.Internal.CrossPlatform.DscClassCache]::GetStringFromSecureString($Value.Password)
$newValue = @{
UserName = $Value.UserName
Password = $clearText
@@ -1793,59 +1793,6 @@ function ValidateUpdate-ConfigurationData
return $true
}
##############################################################
#
# Checks to see if a module defining composite resources should be reloaded
# based the last write time of the schema file. Returns true if the file exists
# and the last modified time was either not recorded or has change.
#
function Test-ModuleReloadRequired
{
[OutputType([bool])]
param (
[Parameter(Mandatory)]
[string]
$SchemaFilePath
)
if (-not $SchemaFilePath -or $SchemaFilePath -notmatch '\.schema\.psm1$')
{
# not a composite res
return $false
}
# If the path doesn't exist, then we can't reload it.
# Note: this condition is explicitly not an error for this function.
if ( -not (Test-Path $SchemaFilePath))
{
if ($schemaFileLastUpdate.ContainsKey($SchemaFilePath))
{
$schemaFileLastUpdate.Remove($SchemaFilePath)
}
return $false
}
# If we have a modified date, then return it.
if ($schemaFileLastUpdate.ContainsKey($SchemaFilePath))
{
if ( (Get-Item $SchemaFilePath).LastWriteTime -eq $schemaFileLastUpdate[$SchemaFilePath] )
{
return $false
}
else
{
return $true
}
}
# Otherwise, record the last write time and return true.
$script:schemaFileLastUpdate[$SchemaFilePath] = (Get-Item $SchemaFilePath).LastWriteTime
$true
}
# Holds the schema file to lastwritetime mapping.
[System.Collections.Generic.Dictionary[string,DateTime]] $script:schemaFileLastUpdate =
New-Object -TypeName 'System.Collections.Generic.Dictionary[string,datetime]'
###########################################################
# Configuration keyword implementation
###########################################################
@@ -1971,7 +1918,7 @@ function Configuration
# Load the default CIM keyword/function definitions set, populating the function collection
# with the default functions.
[Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache]::LoadDefaultCimKeywords($functionsToDefine)
[Microsoft.PowerShell.DesiredStateConfiguration.Internal.CrossPlatform.DscClassCache]::LoadDefaultCimKeywords($functionsToDefine)
# Set up the rest of the configuration runtime state.
Initialize-ConfigurationRuntimeState $Name
@@ -2062,25 +2009,8 @@ function Configuration
foreach ($mod in $modulesInfo) {
$null = ImportClassResourcesFromModule -Module $mod -Resources $res -functionsToDefine $functionsToDefine
$dscResourcesPath = Join-Path -Path $mod.ModuleBase -ChildPath 'DscResources'
if(Test-Path $dscResourcesPath)
{
foreach($requiredResource in $res)
{
if ($requiredResource.Contains('*')) {
# we historically resolve wildcards by Get-Item File System rules.
# We don't support wildcards resolutions for Friendly names.
foreach ($resource in Get-ChildItem -Path $dscResourcesPath -Directory -Name -Filter $requiredResource)
{
$null = ImportCimAndScriptKeywordsFromModule -Module $mod -Resource $resource -functionsToDefine $functionsToDefine
}
} else {
# ImportCimAndScriptKeywordsFromModule takes care about resolving $requiredResources names to ClassNames or FriendlyNames.
$null = ImportCimAndScriptKeywordsFromModule -Module $mod -Resource $requiredResource -functionsToDefine $functionsToDefine
}
}
}
elseif ($moduleInfos.Count -eq 1)
if ($moduleInfos.Count -eq 1)
{
$modules.Add($moduleInfos)
}
@@ -2316,7 +2246,7 @@ function Configuration
{
Write-Debug -Message " CONFIGURATION $Name : DOING TOP-LEVEL CLEAN UP"
[System.Management.Automation.Language.DynamicKeyword]::Reset()
[Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache]::ClearCache()
[Microsoft.PowerShell.DesiredStateConfiguration.Internal.CrossPlatform.DscClassCache]::ClearCache()
Initialize-ConfigurationRuntimeState
}
@@ -2493,66 +2423,16 @@ function ImportClassResourcesFromModule
$functionsToDefine
)
$resourcesFound = [Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache]::ImportClassResourcesFromModule($Module, $Resources, $functionsToDefine)
return ,$resourcesFound
}
$Errors = New-Object -TypeName 'System.Collections.ObjectModel.Collection[System.Exception]'
function ImportCimAndScriptKeywordsFromModule
{
param (
[Parameter(Mandatory)]
$Module,
$resourcesFound = [Microsoft.PowerShell.DesiredStateConfiguration.Internal.CrossPlatform.DscClassCache]::ImportClassResourcesFromModule($Module, $Resources, $functionsToDefine, $Errors)
[Parameter(Mandatory)]
$resource,
$functionsToDefine
)
trap
{
continue
}
$SchemaFilePath = $null
$oldCount = $functionsToDefine.Count
$keywordErrors = New-Object -TypeName 'System.Collections.ObjectModel.Collection[System.Exception]'
$foundCimSchema = [Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache]::ImportCimKeywordsFromModule(
$Module, $resource, [ref] $SchemaFilePath, $functionsToDefine, $keywordErrors)
foreach($ex in $keywordErrors)
foreach($ex in $Errors)
{
Write-Error -Exception $ex
if($ex.InnerException)
{
Write-Error -Exception $ex.InnerException
}
}
$functionsAdded = $functionsToDefine.Count - $oldCount
Write-Debug -Message " $Name : PROCESSING RESOURCE FILE: Added $functionsAdded type handler functions from '$SchemaFilePath'"
$SchemaFilePath = $null
$oldCount = $functionsToDefine.Count
$foundScriptSchema = [Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache]::ImportScriptKeywordsFromModule(
$Module, $resource, [ref] $SchemaFilePath, $functionsToDefine )
$functionsAdded = $functionsToDefine.Count - $oldCount
Write-Debug -Message " $Name : PROCESSING RESOURCE FILE: Added $functionsAdded type handler functions from '$SchemaFilePath'"
if ($foundScriptSchema -and $SchemaFilePath)
{
$resourceDirectory = Split-Path $SchemaFilePath
if($null -ne $resourceDirectory)
{
Import-Module -Force: (Test-ModuleReloadRequired $SchemaFilePath) -Verbose:$false -Name $resourceDirectory -Global -ErrorAction SilentlyContinue
}
}
return $foundCimSchema -or $foundScriptSchema
return ,$resourcesFound
}
#
@@ -2946,16 +2826,6 @@ function Write-NodeMOFFile
# Fix up newlines to be CRLF
$nodeDoc = $nodeDoc -replace "`n", "`r`n"
$errMsg = Test-MofInstanceText $nodeDoc
if($errMsg)
{
$errorMessage = $LocalizedData.InvalidMOFDefinition -f @($mofNode, $errMsg)
$exception = New-Object -TypeName System.InvalidOperationException -ArgumentList $errorMessage
Write-Error -Exception $exception -Message $errorMessage -Category InvalidOperation -ErrorId InvalidMOFDefinition
Update-ConfigurationErrorCount
$nodeOutfile = "$ConfigurationOutputDirectory/$($mofNode).mof.error"
}
if($nodeDocCount -gt 0)
{
# Write to a file only if no error was generated or we are writing to .mof.error file
@@ -3412,7 +3282,7 @@ function Test-MofInstanceText
{
try
{
[Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache]::ValidateInstanceText($instanceText)
[Microsoft.PowerShell.DesiredStateConfiguration.Internal.CrossPlatform.DscClassCache]::ValidateInstanceText($instanceText)
}
catch [System.Management.Automation.MethodInvocationException]
{
@@ -3655,7 +3525,7 @@ function New-DscChecksum
# Retrieve all valid configuration files at the specified $Path
$allConfigFiles = $Path | ForEach-Object -Process {
(Get-ChildItem -Path $_ -Recurse | Where-Object -FilterScript {
$_.Extension -eq '.mof' -or $_.Extension -eq '.zip'
$_.Extension -eq '.json' -or $_.Extension -eq '.zip'
}
)
}
@@ -3664,7 +3534,6 @@ function New-DscChecksum
if ($allConfigFiles.Length -eq 0)
{
Write-Log -Message $LocalizedData.NoValidConfigFileFound
return
}
@@ -3850,22 +3719,12 @@ function Get-DSCResourceModules
foreach($moduleFolder in Get-ChildItem $folder -Directory)
{
$addModule = $false
$dscFolders = Get-childitem "$($moduleFolder.FullName)\DscResources","$($moduleFolder.FullName)\*\DscResources" -ErrorAction Ignore
if($null -ne $dscFolders)
foreach($psd1 in Get-ChildItem -Recurse -Filter "$($moduleFolder.Name).psd1" -Path $moduleFolder.fullname -Depth 2)
{
$addModule = $true
}
if(-not $addModule)
{
foreach($psd1 in Get-ChildItem -Recurse -Filter "$($moduleFolder.Name).psd1" -Path $moduleFolder.fullname -Depth 2)
$containsDSCResource = select-string -LiteralPath $psd1 -pattern '^[^#]*\bDscResourcesToExport\b.*'
if($null -ne $containsDSCResource)
{
$containsDSCResource = select-string -LiteralPath $psd1 -pattern '^[^#]*\bDscResourcesToExport\b.*'
if($null -ne $containsDSCResource)
{
$addModule = $true
}
$addModule = $true
}
}
@@ -3879,14 +3738,167 @@ function Get-DSCResourceModules
$dscModuleFolderList
}
function CimPropertyIsInherited
{
param(
[parameter(Mandatory)]
[string]
$PropertyName,
[parameter(Mandatory)]
[AllowNull()]
[System.Object]
$ParentClass)
if (-not ($ParentClass))
{
return $false;
}
else
{
foreach($property in $ParentClass.CimClassProperties)
{
if ($property.Name -eq $PropertyName)
{
return $true;
}
}
return CimPropertyIsInherited -PropertyName $PropertyName -ParentClass $ParentClass.CimSuperClass
}
}
function PrepareCimClassesForJsonConvertion
{
param(
[parameter(Mandatory)]
$classList)
$resultList = New-Object -TypeName 'System.Collections.Generic.List[PSObject]'
foreach($class in $classList)
{
Write-Verbose "Preprocessing class $($class.CimSystemProperties.ClassName)"
$properties = New-Object -TypeName 'System.Collections.Generic.List[System.Object]'
# remove inherited properties
foreach($property in $class.CimClassProperties)
{
if (-not (CimPropertyIsInherited -PropertyName $property.Name -ParentClass $class.CimSuperClass))
{
Write-Verbose "Adding property $($property.Name)"
$qualifiers = New-Object -TypeName 'System.Collections.Generic.Dictionary[System.String,System.Object]'
foreach($qualifier in $property.Qualifiers)
{
$qualifiers.Add($qualifier.Name, $qualifier.Value)
}
if ($qualifiers.Count -eq 0) { $qualifiers = $null}
$flags = $property.Flags
$flags = $flags -band -bnot [Microsoft.Management.Infrastructure.CimFlags]::Property # this is set for all properties
$flags = $flags -band -bnot [Microsoft.Management.Infrastructure.CimFlags]::NullValue # this is set for all properties
$flags = $flags -band -bnot [Microsoft.Management.Infrastructure.CimFlags]::Required # this is also specified in Qualifiers
$flags = $flags -band -bnot [Microsoft.Management.Infrastructure.CimFlags]::Key # this is also specified in Qualifiers
$flags = $flags -band -bnot [Microsoft.Management.Infrastructure.CimFlags]::ReadOnly # this is also specified in Qualifiers
if ($flags -eq 0) { $flags = $null}
$p = [pscustomobject]@{
Name = $property.Name
Value = $property.Value
CimType = $property.CimType
Flags = $flags
ReferenceClassName = $property.ReferenceClassName
Qualifiers = $qualifiers
}
# remove properties that have null value
$p.PSobject.Properties | % {if ($_.Value -eq $null) {$p.PSobject.Properties.Remove($_.Name)}}
$properties.Add($p);
}
else
{
Write-Verbose "Property $($property.Name) is inherited, ignoring it"
}
}
if ($properties.Count -eq 0) { $properties = $null}
# construct the processed class
$processedClass = [pscustomobject]@{
ClassName = $class.CimSystemProperties.ClassName
FriendlyName = ($class.CimClassQualifiers | Where-Object {$_.Name -eq "FriendlyName"}).Value
ClassVersion = ($class.CimClassQualifiers | Where-Object {$_.Name -eq "ClassVersion"}).Value
Description = ($class.CimClassQualifiers | Where-Object {$_.Name -eq "Description"}).Value
SuperClassName = $class.CimSuperClassName
ClassProperties = $properties
}
# remove properties that have null value
$processedClass.PSobject.Properties | % {if ($_.Value -eq $null) {$processedClass.PSobject.Properties.Remove($_.Name)}}
$resultList.Add($processedClass)
}
return $resultList
}
###########################################################
# ConvertTo-DscJsonSchema
###########################################################
#
# Reads CIM MOF schema files and creates json files with equivalent json schema
#
function ConvertTo-DscJsonSchema
{
param (
[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[ValidateNotNullOrEmpty()]
[Alias("Path")]
[string[]]
$Directory
)
Process
{
foreach($dir in $Directory)
{
Write-Verbose "Processing $dir"
if (-not (Test-Path -Path $dir))
{
Write-Error "Can not find directory $dir" # non-terminating error
}
else
{
[Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache]::Initialize()
$schemaFilePaths = Get-ChildItem -Recurse -File -Path $dir -Filter '*.schema.mof'
foreach($mofPath in $schemaFilePaths)
{
$cimClasses = [Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache]::ReadCimSchemaMof($mofPath)
Write-Verbose "Read $($cimClasses.Count) classes from $mofPath"
$preprocessedCimClasses = PrepareCimClassesForJsonConvertion $cimClasses
[string] $jsonPath = $mofPath.FullName.Substring(0, $mofPath.FullName.LastIndexOf('.')) + ".json";
Write-Verbose "Writing $jsonPath"
ConvertTo-Json -InputObject $preprocessedCimClasses -Depth 100 -EnumsAsStrings | Out-File -Force -Path $jsonPath
}
}
}
}
}
###########################################################
# Get-DSCResource
###########################################################
#
# Gets DSC resources on the machine. Allows to filter on a particular resource.
# It parses all the resources defined in the schema.mof file and also the composite
# resources defined or imported from PowerShell modules
# It parses class-based resources defined in the psm1 module files.
#
function Get-DscResource
{
@@ -3919,7 +3931,7 @@ function Get-DscResource
$keywordErrors = New-Object -TypeName 'System.Collections.ObjectModel.Collection[System.Exception]'
# Load the default Inbox providers (keyword) in cache, also allow caching the resources from multiple versions of modules.
[Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache]::LoadDefaultCimKeywords($keywordErrors, $true)
[Microsoft.PowerShell.DesiredStateConfiguration.Internal.CrossPlatform.DscClassCache]::LoadDefaultCimKeywords($keywordErrors, $true)
foreach($ex in $keywordErrors)
{
@@ -3966,15 +3978,6 @@ function Get-DscResource
{
$null = ImportClassResourcesFromModule -Module $mod -Resources * -functionsToDefine $functionsToDefine
}
$dscResources = Join-Path -Path $mod.ModuleBase -ChildPath 'DscResources'
if(Test-Path $dscResources)
{
foreach ($resource in Get-ChildItem -Path $dscResources -Directory -Name)
{
$null = ImportCimAndScriptKeywordsFromModule -Module $mod -Resource $resource -functionsToDefine $functionsToDefine
}
}
}
$Resources = @()
@@ -4004,7 +4007,7 @@ function Get-DscResource
Write-Progress -Id 3 -Activity $LocalizedData.CreatingResourceList
# Get resources for CIM cache
$keywords = [Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache]::GetCachedKeywords() | Where-Object -FilterScript {
$keywords = [Microsoft.PowerShell.DesiredStateConfiguration.Internal.CrossPlatform.DscClassCache]::GetKeywordsFromCachedClasses() | Where-Object -FilterScript {
(!$_.IsReservedKeyword) -and ($null -ne $_.ResourceName) -and !(IsHiddenResource $_.ResourceName) -and (![bool]$Module -or ($_.ImplementingModule -like $ModuleString))
}
@@ -4018,16 +4021,6 @@ function Get-DscResource
$_ -ne $null
}
# Get composite resources
$Resources += Get-Command -CommandType Configuration |
ForEach-Object -Process {
GetCompositeResource $patterns $_ $ignoreResourceParameters -modules $modules
} |
Where-Object -FilterScript {
$_ -ne $null -and (![bool]$ModuleString -or ($_.Module -like $ModuleString)) -and
($_.Path -and ((Split-Path -Leaf $_.Path) -eq "$($_.Name).schema.psm1"))
}
# check whether all resources are found
CheckResourceFound $Name $Resources
}
@@ -4036,7 +4029,7 @@ function Get-DscResource
if ($initialized)
{
[System.Management.Automation.Language.DynamicKeyword]::Reset()
[Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache]::ClearCache()
[Microsoft.PowerShell.DesiredStateConfiguration.Internal.CrossPlatform.DscClassCache]::ClearCache()
$initialized = $false
}
@@ -4064,7 +4057,7 @@ function Get-DscResource
if ($initialized)
{
[System.Management.Automation.Language.DynamicKeyword]::Reset()
[Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache]::ClearCache()
[Microsoft.PowerShell.DesiredStateConfiguration.Internal.CrossPlatform.DscClassCache]::ClearCache()
$initialized = $false
}
@@ -4117,68 +4110,23 @@ function GetResourceFromKeyword
$resource.Name = $keyword.Keyword
$schemaFiles = [Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache]::GetFileDefiningClass($keyword.ResourceName)
# only supporting class-based resources at this time
$implementationDetail = 'ClassBased'
$Module = $modules | Where-Object -FilterScript {
$_.Name -eq $keyword.ImplementingModule -and
$_.Version -eq $keyword.ImplementingModuleVersion
} | Select-Object -First 1
if ($schemaFiles.Count)
if ($Module -and $Module.ExportedDscResources -contains $keyword.Keyword)
{
# Find the correct schema file that matches module name and version
# if same module/version is installed in multiple locations, then pick the first schema file.
foreach ($schemaFileName in $schemaFiles){
$moduleInfo = GetModule $modules $schemaFileName;
if ($moduleInfo.Name -eq $keyword.ImplementingModule -and $moduleInfo.Version -eq $keyword.ImplementingModuleVersion){
break
}
}
# if the class is not a resource we will ignore it except if it is DSC inbox resource.
if(-not $schemaFileName.StartsWith("$env:windir\system32\configuration",[stringComparison]::OrdinalIgnoreCase))
{
$classesFromSchema = [Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache]::GetCachedClassByFileName($schemaFileName)
if($null -ne $classesFromSchema)
{
# check if the resource is proper DSC resource that always derives from OMI_BaseResource.
$schemaToProcess = $classesFromSchema | ForEach-Object -Process {
if(($_.CimSystemProperties.ClassName -ieq $keyword.ResourceName) -and ($_.CimSuperClassName -ieq 'OMI_BaseResource'))
{
if ([ExperimentalFeature]::IsEnabled("PSDesiredStateConfiguration.InvokeDscResource"))
{
$_ | Add-Member -MemberType NoteProperty -Name 'ImplementationDetail' -Value $implementationDetail -PassThru
}
else
{
$_
}
}
}
if($null -eq $schemaToProcess)
{
return
}
}
}
$message = $LocalizedData.SchemaFileForResource -f @($schemaFileName)
Write-Verbose -Message $message
$resource.Module = $moduleInfo
$resource.Path = GetImplementingModulePath $schemaFileName
$resource.ParentPath = Split-Path $schemaFileName
$resource.Module = $Module
$resource.Path = $Module.Path
$resource.ParentPath = Split-Path -Path $Module.Path
}
else
{
$implementationDetail = 'ClassBased'
$Module = $modules | Where-Object -FilterScript {
$_.Name -eq $keyword.ImplementingModule -and
$_.Version -eq $keyword.ImplementingModuleVersion
}
if ($Module -and $Module.ExportedDscResources -contains $keyword.Keyword)
{
$implementationDetail = 'ClassBased'
$resource.Module = $Module
$resource.Path = $Module.Path
$resource.ParentPath = Split-Path -Path $Module.Path
}
# a class-based keyword must be in the ExportedDscResources of the module that implements it
return $null
}
if ([system.string]::IsNullOrEmpty($resource.Path) -eq $false)
@@ -4331,7 +4279,6 @@ function AddDscResourceProperty
$dscProperty.Values.Add($_)
}
}
$dscProperty.PropertyType = $Type
$dscProperty.IsMandatory = $property.Mandatory
@@ -4451,13 +4398,13 @@ function GetImplementingModulePath
$schemaFileName
)
$moduleFileName = ($schemaFileName -replace ".schema.mof$", '') + '.psd1'
$moduleFileName = ($schemaFileName -replace ".schema.json$", '') + '.psd1'
if (Test-Path $moduleFileName)
{
return $moduleFileName
}
$moduleFileName = ($schemaFileName -replace ".schema.mof$", '') + '.psm1'
$moduleFileName = ($schemaFileName -replace ".schema.json$", '') + '.psm1'
if (Test-Path $moduleFileName)
{
return $moduleFileName
@@ -4487,9 +4434,9 @@ function GetModule
}
$schemaFileExt = $null
if ($schemaFileName -match '.schema.mof')
if ($schemaFileName -match '.schema.json')
{
$schemaFileExt = ".schema.mof$"
$schemaFileExt = ".schema.json$"
}
if ($schemaFileName -match '.schema.psm1')
@@ -4749,29 +4696,29 @@ function Invoke-DscClassBasedResource
Write-Debug "Importing $path ..."
$iss = [System.Management.Automation.Runspaces.InitialSessionState]::CreateDefault2()
# next line prevents PSModulePath from being reset to default
$iss.EnvironmentVariables.Add([System.Management.Automation.Runspaces.SessionStateVariableEntry]::new("PSModulePath", $env:PSModulePath, $null))
$powershell = [PowerShell]::Create($iss)
$script = @"
using module $path
Write-Host -Message ([$type]::new | out-string)
return [$type]::new()
return [$type]
"@
$null= $powershell.AddScript($script)
$dscType=$powershell.Invoke() | Select-object -First 1
$null = $powershell.AddScript($script)
$dscType = $powershell.Invoke() | Select-object -First 1
Write-Debug "Imported Type: $($dscType | Out-String)"
$dscObj = $dscType::new()
foreach($key in $Property.Keys)
{
$value = $Property.$key
Write-Debug "Setting $key to $value"
$dscType.$key = $value
$dscObj.$key = $value
}
$info = $dscType | Out-String
Write-Debug $info
Write-Debug "Object with filled keys: $($dscObj | Out-String)"
Write-Debug "calling $type.$Method() ..."
Write-Debug "Calling $type.$Method() ..."
$global:DSCMachineStatus = $null
$output = $dscType.$Method()
$output = $dscObj.$Method()
return Get-InvokeDscResourceResult -Output $output -Method $Method
}
@@ -4836,6 +4783,7 @@ function Get-InvokeDscResourceResult
Export-ModuleMember -Function @(
'Invoke-DscResource'
'ConvertTo-DscJsonSchema'
)
###########################################################
@@ -24,7 +24,7 @@ namespace Microsoft.PowerShell.DesiredStateConfiguration
/// DSC resource implementation type not known
/// </summary>
None = 0,
/// <summary>
/// DSC resource is implemented using PowerShell module
/// </summary>
@@ -70,13 +70,13 @@ namespace Microsoft.PowerShell.DesiredStateConfiguration
public string FriendlyName { get; set; }
/// <summary>
/// Gets or sets module which implements the resource. This could point to parent module, if the DSC resource is implemented
/// Gets or sets module which implements the resource. This could point to parent module, if the DSC resource is implemented
/// by one of nested modules.
/// </summary>
public PSModuleInfo Module { get; set; }
/// <summary>
/// Gets name of the module which implements the resource.
/// Gets name of the module which implements the resource.
/// </summary>
public string ModuleName
{
@@ -88,7 +88,7 @@ namespace Microsoft.PowerShell.DesiredStateConfiguration
}
/// <summary>
/// Gets version of the module which implements the resource.
/// Gets version of the module which implements the resource.
/// </summary>
public Version Version
{
@@ -100,7 +100,7 @@ namespace Microsoft.PowerShell.DesiredStateConfiguration
}
/// <summary>
/// Gets or sets of the file which implements the resource. For the reosurces which are defined using
/// Gets or sets of the file which implements the resource. For the reosurces which are defined using
/// MOF file, this will be path to a module which resides in the same folder where schema.mof file is present.
/// For composite resources, this will be the module which implements the resource
/// </summary>
@@ -108,7 +108,7 @@ namespace Microsoft.PowerShell.DesiredStateConfiguration
/// <summary>
/// Gets or sets parent folder, where the resource is defined
/// It is the folder containing either the implementing module(=Path) or folder containing ".schema.mof".
/// It is the folder containing either the implementing module(=Path) or folder containing ".schema.mof".
/// For native providers, Path will be null and only ParentPath will be present.
/// </summary>
public string ParentPath { get; set; }
@@ -150,7 +150,7 @@ namespace Microsoft.PowerShell.DesiredStateConfiguration
{
this.Values = new List<string>();
}
/// <summary>
/// Gets or sets name of the property
/// </summary>