mirror of
https://github.com/PowerShell/PSDesiredStateConfiguration
synced 2026-06-21 13:45:25 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b2145e76cd |
@@ -13,8 +13,9 @@ jobs:
|
||||
- ${{ parameters.powershellExecutable }}: |
|
||||
if($IsMacOs)
|
||||
{
|
||||
brew install powershell/tap/powershell-preview
|
||||
sudo ln -s -f /usr/local/opt/powershell-preview/libexec/pwsh /usr/local/bin/pwsh
|
||||
brew update
|
||||
brew cask install powershell-preview
|
||||
sudo ln -s -f /usr/local/microsoft/powershell/7-preview/pwsh /usr/local/bin/pwsh
|
||||
}
|
||||
elseif($IsLinux)
|
||||
{
|
||||
@@ -48,28 +49,19 @@ jobs:
|
||||
displayName: Capture PSRepository
|
||||
|
||||
- ${{ parameters.powershellExecutable }}: |
|
||||
Install-module Pester -Force -MaximumVersion 4.99
|
||||
displayName: Install dependencies - Pester
|
||||
timeoutInMinutes: 10
|
||||
|
||||
- ${{ parameters.powershellExecutable }}: |
|
||||
Install-Module -Name "platyPS" -Force
|
||||
displayName: Install dependencies - PlatyPS
|
||||
Install-Module -Name "platyPS","Pester" -Force
|
||||
displayName: Install dependencies
|
||||
timeoutInMinutes: 10
|
||||
|
||||
- ${{ parameters.powershellExecutable }}: |
|
||||
Install-Module -Name "PSScriptAnalyzer" -RequiredVersion 1.18.0 -Force
|
||||
displayName: Install dependencies - PSScriptAnalyzer
|
||||
displayName: Install dependencies
|
||||
timeoutInMinutes: 10
|
||||
|
||||
- ${{ parameters.powershellExecutable }}: |
|
||||
Install-Module -Name PSPackageProject -Force
|
||||
displayName: Install PSPackageProject module
|
||||
|
||||
- ${{ parameters.powershellExecutable }}: |
|
||||
Get-InstalledModule -Name pester -AllVersions | Where-Object {$_.Version -ge ([version]::new(5,0,0))} | Uninstall-Module -Force
|
||||
displayName: Remove >= 5.0.0 Pester
|
||||
|
||||
- task: DownloadBuildArtifacts@0
|
||||
displayName: 'Download artifacts'
|
||||
inputs:
|
||||
@@ -109,8 +101,6 @@ jobs:
|
||||
- ${{ parameters.powershellExecutable }}: |
|
||||
Invoke-PSPackageProjectTest -Type StaticAnalysis
|
||||
displayName: Execute static analysis tests
|
||||
# need to figure out how to disable PSAvoidOverwritingBuiltInCmdlets
|
||||
continueOnError: true
|
||||
errorActionPreference: continue
|
||||
condition: succeededOrFailed()
|
||||
|
||||
|
||||
+17
-21
@@ -13,38 +13,34 @@ 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}"
|
||||
|
||||
$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 )
|
||||
{
|
||||
if ( Test-Path "${SrcPath}/code" ) {
|
||||
Write-Verbose -Verbose -Message "Building assembly and copying to '${OutDirectory}/${ModuleName}'"
|
||||
|
||||
Push-Location $subsystemCodePath
|
||||
$result = dotnet publish
|
||||
if (Test-Path $subsystemBinPath)
|
||||
{
|
||||
Copy-Item $subsystemBinPath "${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}"
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Error "dotnet build failed - $subsystemBinPath not found - $result"
|
||||
catch {
|
||||
$result | ForEach-Object { Write-Warning $_ }
|
||||
Write-Error "dotnet build failed"
|
||||
}
|
||||
finally {
|
||||
Pop-Location
|
||||
}
|
||||
|
||||
Pop-Location
|
||||
}
|
||||
else {
|
||||
Write-Verbose -Verbose -Message "No code to build in '$subsystemCodePath'"
|
||||
Write-Verbose -Verbose -Message "No code to build in '${SrcPath}/code'"
|
||||
}
|
||||
|
||||
## Add build and packaging here
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
// 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
@@ -1,16 +0,0 @@
|
||||
<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.
-232
@@ -1,232 +0,0 @@
|
||||
[
|
||||
{
|
||||
"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"
|
||||
}
|
||||
]
|
||||
-218
@@ -1,218 +0,0 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
]
|
||||
}
|
||||
-455
@@ -1,455 +0,0 @@
|
||||
[
|
||||
{
|
||||
"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 = '3.0.0'
|
||||
moduleVersion = '2.0.5'
|
||||
|
||||
# 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 = '7.1'
|
||||
PowerShellVersion = '6.1'
|
||||
|
||||
# Name of the Windows PowerShell host required by this module
|
||||
# PowerShellHostName = ''
|
||||
@@ -48,7 +48,7 @@ PowerShellVersion = '7.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 = '7.1'
|
||||
# FormatsToProcess = @()
|
||||
|
||||
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
|
||||
NestedModules = @('Microsoft.PowerShell.DscSubsystem.dll')
|
||||
# NestedModules = @()
|
||||
|
||||
# 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,7 +71,6 @@ 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 (json,zip) were found.
|
||||
NoValidConfigFileFound = No valid config files (mof,zip) were found.
|
||||
InputFileNotExist=File {0} doesn't exist.
|
||||
FileReadError=Error Reading file {0}.
|
||||
MatchingFileNotFound=No matching file found.
|
||||
@@ -66,6 +66,7 @@ data LocalizedData
|
||||
ImportDscResourceWarningForInbuiltResource=The configuration '{0}' is loading one or more built-in resources without explicitly importing associated modules. Add Import-DscResource -ModuleName 'PSDesiredStateConfiguration' to your configuration to avoid this message.
|
||||
PasswordTooLong=An error occurred during encryption of a password in node '{0}'. Most likely the password entered is too long to be encrypted using the selected certificate. Please either use a shorter password or select a certificate with a larger key.
|
||||
PsDscRunAsCredentialNotSupport=The 'PsDscRunAsCredential' property is not currently support when using Invoke-DscResource.
|
||||
EmbeddedResourcesNotSupported=Embedded resources are not support on Linux or macOS. Please see https://aka.ms/PSCoreDSC for more details.
|
||||
'@
|
||||
}
|
||||
Set-StrictMode -Off
|
||||
@@ -76,7 +77,7 @@ Import-LocalizedData -BindingVariable LocalizedData -FileName PSDesiredStateCon
|
||||
Import-Module $PSScriptRoot/helpers/DscResourceInfo.psm1
|
||||
|
||||
# Set DSC HOME environment variable.
|
||||
$env:DSC_HOME = Join-Path $PSScriptRoot "Configuration"
|
||||
$env:DSC_HOME = "$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 +308,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.CrossPlatform.DscClassCache]::GetStringFromSecureString($Value.Password)
|
||||
$clearText = [Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache]::GetStringFromSecureString($Value.Password)
|
||||
$newValue = @{
|
||||
UserName = $Value.UserName
|
||||
Password = $clearText
|
||||
@@ -1793,6 +1794,59 @@ 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
|
||||
###########################################################
|
||||
@@ -1851,6 +1905,10 @@ function Configuration
|
||||
return $moduleInfos
|
||||
}
|
||||
|
||||
if ( $IsMacOS -or $IsLinux ) {
|
||||
Write-Warning -Message $LocalizedData.EmbeddedResourcesNotSupported
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Write-Debug -Message "BEGIN CONFIGURATION '$Name' PROCESSING: OutputPath: '$OutputPath'"
|
||||
@@ -1918,7 +1976,7 @@ function Configuration
|
||||
|
||||
# Load the default CIM keyword/function definitions set, populating the function collection
|
||||
# with the default functions.
|
||||
[Microsoft.PowerShell.DesiredStateConfiguration.Internal.CrossPlatform.DscClassCache]::LoadDefaultCimKeywords($functionsToDefine)
|
||||
[Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache]::LoadDefaultCimKeywords($functionsToDefine)
|
||||
|
||||
# Set up the rest of the configuration runtime state.
|
||||
Initialize-ConfigurationRuntimeState $Name
|
||||
@@ -2009,8 +2067,25 @@ function Configuration
|
||||
foreach ($mod in $modulesInfo) {
|
||||
|
||||
$null = ImportClassResourcesFromModule -Module $mod -Resources $res -functionsToDefine $functionsToDefine
|
||||
|
||||
if ($moduleInfos.Count -eq 1)
|
||||
$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)
|
||||
{
|
||||
$modules.Add($moduleInfos)
|
||||
}
|
||||
@@ -2246,7 +2321,7 @@ function Configuration
|
||||
{
|
||||
Write-Debug -Message " CONFIGURATION $Name : DOING TOP-LEVEL CLEAN UP"
|
||||
[System.Management.Automation.Language.DynamicKeyword]::Reset()
|
||||
[Microsoft.PowerShell.DesiredStateConfiguration.Internal.CrossPlatform.DscClassCache]::ClearCache()
|
||||
[Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache]::ClearCache()
|
||||
|
||||
Initialize-ConfigurationRuntimeState
|
||||
}
|
||||
@@ -2423,16 +2498,66 @@ function ImportClassResourcesFromModule
|
||||
$functionsToDefine
|
||||
)
|
||||
|
||||
$Errors = New-Object -TypeName 'System.Collections.ObjectModel.Collection[System.Exception]'
|
||||
$resourcesFound = [Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache]::ImportClassResourcesFromModule($Module, $Resources, $functionsToDefine)
|
||||
return ,$resourcesFound
|
||||
}
|
||||
|
||||
$resourcesFound = [Microsoft.PowerShell.DesiredStateConfiguration.Internal.CrossPlatform.DscClassCache]::ImportClassResourcesFromModule($Module, $Resources, $functionsToDefine, $Errors)
|
||||
function ImportCimAndScriptKeywordsFromModule
|
||||
{
|
||||
param (
|
||||
[Parameter(Mandatory)]
|
||||
$Module,
|
||||
|
||||
foreach($ex in $Errors)
|
||||
[Parameter(Mandatory)]
|
||||
$resource,
|
||||
|
||||
$functionsToDefine
|
||||
)
|
||||
|
||||
trap
|
||||
{
|
||||
Write-Error -Exception $ex
|
||||
continue
|
||||
}
|
||||
|
||||
return ,$resourcesFound
|
||||
$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)
|
||||
{
|
||||
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
|
||||
}
|
||||
|
||||
#
|
||||
@@ -2826,6 +2951,16 @@ 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
|
||||
@@ -3282,7 +3417,7 @@ function Test-MofInstanceText
|
||||
{
|
||||
try
|
||||
{
|
||||
[Microsoft.PowerShell.DesiredStateConfiguration.Internal.CrossPlatform.DscClassCache]::ValidateInstanceText($instanceText)
|
||||
[Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache]::ValidateInstanceText($instanceText)
|
||||
}
|
||||
catch [System.Management.Automation.MethodInvocationException]
|
||||
{
|
||||
@@ -3525,7 +3660,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 '.json' -or $_.Extension -eq '.zip'
|
||||
$_.Extension -eq '.mof' -or $_.Extension -eq '.zip'
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -3534,6 +3669,7 @@ function New-DscChecksum
|
||||
if ($allConfigFiles.Length -eq 0)
|
||||
{
|
||||
Write-Log -Message $LocalizedData.NoValidConfigFileFound
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -3706,7 +3842,7 @@ function ReadEnvironmentFile
|
||||
|
||||
function Get-DSCResourceModules
|
||||
{
|
||||
$listPSModuleFolders = $env:PSModulePath.Split([IO.Path]::PathSeparator)
|
||||
$listPSModuleFolders = $env:PSModulePath.Split(":")
|
||||
$dscModuleFolderList = [System.Collections.Generic.HashSet[System.String]]::new()
|
||||
|
||||
foreach ($folder in $listPSModuleFolders)
|
||||
@@ -3719,12 +3855,22 @@ function Get-DSCResourceModules
|
||||
foreach($moduleFolder in Get-ChildItem $folder -Directory)
|
||||
{
|
||||
$addModule = $false
|
||||
foreach($psd1 in Get-ChildItem -Recurse -Filter "$($moduleFolder.Name).psd1" -Path $moduleFolder.fullname -Depth 2)
|
||||
|
||||
$dscFolders = Get-childitem "$($moduleFolder.FullName)\DscResources","$($moduleFolder.FullName)\*\DscResources" -ErrorAction Ignore
|
||||
if($null -ne $dscFolders)
|
||||
{
|
||||
$containsDSCResource = select-string -LiteralPath $psd1 -pattern '^[^#]*\bDscResourcesToExport\b.*'
|
||||
if($null -ne $containsDSCResource)
|
||||
$addModule = $true
|
||||
}
|
||||
|
||||
if(-not $addModule)
|
||||
{
|
||||
foreach($psd1 in Get-ChildItem -Recurse -Filter "$($moduleFolder.Name).psd1" -Path $moduleFolder.fullname -Depth 2)
|
||||
{
|
||||
$addModule = $true
|
||||
$containsDSCResource = select-string -LiteralPath $psd1 -pattern '^[^#]*\bDscResourcesToExport\b.*'
|
||||
if($null -ne $containsDSCResource)
|
||||
{
|
||||
$addModule = $true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3738,167 +3884,14 @@ 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 class-based resources defined in the psm1 module files.
|
||||
# It parses all the resources defined in the schema.mof file and also the composite
|
||||
# resources defined or imported from PowerShell modules
|
||||
#
|
||||
function Get-DscResource
|
||||
{
|
||||
@@ -3931,7 +3924,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.CrossPlatform.DscClassCache]::LoadDefaultCimKeywords($keywordErrors, $true)
|
||||
[Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache]::LoadDefaultCimKeywords($keywordErrors, $true)
|
||||
|
||||
foreach($ex in $keywordErrors)
|
||||
{
|
||||
@@ -3978,6 +3971,15 @@ 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 = @()
|
||||
@@ -4007,20 +4009,28 @@ function Get-DscResource
|
||||
Write-Progress -Id 3 -Activity $LocalizedData.CreatingResourceList
|
||||
|
||||
# Get resources for CIM cache
|
||||
$keywords = [Microsoft.PowerShell.DesiredStateConfiguration.Internal.CrossPlatform.DscClassCache]::GetKeywordsFromCachedClasses() | Where-Object -FilterScript {
|
||||
$keywords = [Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache]::GetCachedKeywords() | Where-Object -FilterScript {
|
||||
(!$_.IsReservedKeyword) -and ($null -ne $_.ResourceName) -and !(IsHiddenResource $_.ResourceName) -and (![bool]$Module -or ($_.ImplementingModule -like $ModuleString))
|
||||
}
|
||||
|
||||
$dscResourceNames = $keywords.keyword
|
||||
|
||||
$Resources += $keywords |
|
||||
ForEach-Object -Process {
|
||||
GetResourceFromKeyword -keyword $_ -patterns $patterns -modules $modules -dscResourceNames $dscResourceNames
|
||||
GetResourceFromKeyword -keyword $_ -patterns $patterns -modules $modules
|
||||
} |
|
||||
Where-Object -FilterScript {
|
||||
$_ -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
|
||||
}
|
||||
@@ -4029,7 +4039,7 @@ function Get-DscResource
|
||||
if ($initialized)
|
||||
{
|
||||
[System.Management.Automation.Language.DynamicKeyword]::Reset()
|
||||
[Microsoft.PowerShell.DesiredStateConfiguration.Internal.CrossPlatform.DscClassCache]::ClearCache()
|
||||
[Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache]::ClearCache()
|
||||
|
||||
$initialized = $false
|
||||
}
|
||||
@@ -4057,7 +4067,7 @@ function Get-DscResource
|
||||
if ($initialized)
|
||||
{
|
||||
[System.Management.Automation.Language.DynamicKeyword]::Reset()
|
||||
[Microsoft.PowerShell.DesiredStateConfiguration.Internal.CrossPlatform.DscClassCache]::ClearCache()
|
||||
[Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache]::ClearCache()
|
||||
|
||||
$initialized = $false
|
||||
}
|
||||
@@ -4078,11 +4088,9 @@ function GetResourceFromKeyword
|
||||
$patterns,
|
||||
[Parameter(Mandatory)]
|
||||
[System.Management.Automation.PSModuleInfo[]]
|
||||
$modules,
|
||||
[Parameter(Mandatory)]
|
||||
[Object[]]
|
||||
$dscResourceNames
|
||||
$modules
|
||||
)
|
||||
|
||||
$implementationDetail = 'ScriptBased'
|
||||
|
||||
# Find whether $name follows the pattern
|
||||
@@ -4110,23 +4118,68 @@ function GetResourceFromKeyword
|
||||
|
||||
$resource.Name = $keyword.Keyword
|
||||
|
||||
# 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
|
||||
$schemaFiles = [Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache]::GetFileDefiningClass($keyword.ResourceName)
|
||||
|
||||
if ($Module -and $Module.ExportedDscResources -contains $keyword.Keyword)
|
||||
if ($schemaFiles.Count)
|
||||
{
|
||||
$resource.Module = $Module
|
||||
$resource.Path = $Module.Path
|
||||
$resource.ParentPath = Split-Path -Path $Module.Path
|
||||
# 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
|
||||
}
|
||||
else
|
||||
{
|
||||
# a class-based keyword must be in the ExportedDscResources of the module that implements it
|
||||
return $null
|
||||
$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
|
||||
}
|
||||
}
|
||||
|
||||
if ([system.string]::IsNullOrEmpty($resource.Path) -eq $false)
|
||||
@@ -4146,7 +4199,7 @@ function GetResourceFromKeyword
|
||||
|
||||
# add properties
|
||||
$keyword.Properties.Values | ForEach-Object -Process {
|
||||
AddDscResourceProperty $resource $_ $dscResourceNames
|
||||
AddDscResourceProperty $resource $_
|
||||
}
|
||||
|
||||
# sort properties
|
||||
@@ -4238,9 +4291,7 @@ function AddDscResourceProperty
|
||||
[Microsoft.PowerShell.DesiredStateConfiguration.DscResourceInfo]
|
||||
$dscresource,
|
||||
[Parameter(Mandatory)]
|
||||
$property,
|
||||
[Parameter(Mandatory)]
|
||||
$dscResourceNames
|
||||
$property
|
||||
)
|
||||
|
||||
$convertTypeMap = @{
|
||||
@@ -4264,11 +4315,6 @@ function AddDscResourceProperty
|
||||
else
|
||||
{
|
||||
$Type = [System.Management.Automation.LanguagePrimitives]::ConvertTypeNameToPSTypeName($property.TypeConstraint)
|
||||
if ([string]::IsNullOrEmpty($Type)) {
|
||||
$dscResourceNames | ForEach-Object -Process {
|
||||
if (($property.TypeConstraint -eq $_) -or ($property.TypeConstraint -eq ($_ + "[]"))) { $Type = "[$($property.TypeConstraint)]" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($null -ne $property.ValueMap)
|
||||
@@ -4279,6 +4325,7 @@ function AddDscResourceProperty
|
||||
$dscProperty.Values.Add($_)
|
||||
}
|
||||
}
|
||||
|
||||
$dscProperty.PropertyType = $Type
|
||||
$dscProperty.IsMandatory = $property.Mandatory
|
||||
|
||||
@@ -4398,13 +4445,13 @@ function GetImplementingModulePath
|
||||
$schemaFileName
|
||||
)
|
||||
|
||||
$moduleFileName = ($schemaFileName -replace ".schema.json$", '') + '.psd1'
|
||||
$moduleFileName = ($schemaFileName -replace ".schema.mof$", '') + '.psd1'
|
||||
if (Test-Path $moduleFileName)
|
||||
{
|
||||
return $moduleFileName
|
||||
}
|
||||
|
||||
$moduleFileName = ($schemaFileName -replace ".schema.json$", '') + '.psm1'
|
||||
$moduleFileName = ($schemaFileName -replace ".schema.mof$", '') + '.psm1'
|
||||
if (Test-Path $moduleFileName)
|
||||
{
|
||||
return $moduleFileName
|
||||
@@ -4434,9 +4481,9 @@ function GetModule
|
||||
}
|
||||
|
||||
$schemaFileExt = $null
|
||||
if ($schemaFileName -match '.schema.json')
|
||||
if ($schemaFileName -match '.schema.mof')
|
||||
{
|
||||
$schemaFileExt = ".schema.json$"
|
||||
$schemaFileExt = ".schema.mof$"
|
||||
}
|
||||
|
||||
if ($schemaFileName -match '.schema.psm1')
|
||||
@@ -4645,6 +4692,10 @@ function Invoke-DscResource
|
||||
ThrowError -ExceptionName 'System.ArgumentException' -ExceptionMessage $errorMessage -ExceptionObject $exception -ErrorId 'InvalidResourceSpecification,Invoke-DscResource' -ErrorCategory InvalidArgument
|
||||
}
|
||||
|
||||
if ( @($resource.Properties | Where-Object { $_.PropertyType -eq '' }).Count -gt 0 -and ($IsMacOS -or $IsLinux)) {
|
||||
Write-Warning -Message $LocalizedData.EmbeddedResourcesNotSupported
|
||||
}
|
||||
|
||||
[Microsoft.PowerShell.DesiredStateConfiguration.DscResourceInfo] $resource = $resource[0]
|
||||
if($resource.ImplementedAs -ne 'PowerShell')
|
||||
{
|
||||
@@ -4696,29 +4747,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
|
||||
return [$type]
|
||||
|
||||
Write-Host -Message ([$type]::new | out-string)
|
||||
return [$type]::new()
|
||||
"@
|
||||
|
||||
$null = $powershell.AddScript($script)
|
||||
$dscType = $powershell.Invoke() | Select-object -First 1
|
||||
Write-Debug "Imported Type: $($dscType | Out-String)"
|
||||
$dscObj = $dscType::new()
|
||||
|
||||
$null= $powershell.AddScript($script)
|
||||
$dscType=$powershell.Invoke() | Select-object -First 1
|
||||
foreach($key in $Property.Keys)
|
||||
{
|
||||
$value = $Property.$key
|
||||
Write-Debug "Setting $key to $value"
|
||||
$dscObj.$key = $value
|
||||
$dscType.$key = $value
|
||||
}
|
||||
Write-Debug "Object with filled keys: $($dscObj | Out-String)"
|
||||
$info = $dscType | Out-String
|
||||
Write-Debug $info
|
||||
|
||||
Write-Debug "Calling $type.$Method() ..."
|
||||
Write-Debug "calling $type.$Method() ..."
|
||||
$global:DSCMachineStatus = $null
|
||||
$output = $dscObj.$Method()
|
||||
$output = $dscType.$Method()
|
||||
return Get-InvokeDscResourceResult -Output $output -Method $Method
|
||||
}
|
||||
|
||||
@@ -4783,7 +4834,6 @@ 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>
|
||||
|
||||
@@ -429,37 +429,25 @@ Describe "Test PSDesiredStateConfiguration" -tags CI {
|
||||
Should -Throw -ErrorId 'InvalidResourceSpecification,Invoke-DscResource' -ExpectedMessage 'Invalid Resource Name ''Script'' or module specification.'
|
||||
}
|
||||
|
||||
it "Test an embedded DSC resource" {
|
||||
it "Resource with embedded resource not supported and a warning should be produced" {
|
||||
|
||||
if (!(Test-IsInvokeDscResourceEnable)) {
|
||||
Set-ItResult -Skipped -Because "Feature not enabled"
|
||||
}
|
||||
|
||||
$resourceName="TestRes"
|
||||
$moduleName="TestEmbeddedDSCResource"
|
||||
$embObj = @(New-Object -TypeName psobject -Property @{embclassprop="property1"})
|
||||
if (!$IsMacOS) {
|
||||
Set-ItResult -Skipped -Because "Not applicable on Windows and xWebAdministration resources don't load on linux"
|
||||
}
|
||||
|
||||
Install-ModuleIfMissing -Name $moduleName -Force
|
||||
try {
|
||||
Invoke-DscResource -Name xWebSite -ModuleName 'xWebAdministration' -Method Test -Property @{TestScript = 'foobar' } -ErrorAction Stop -WarningVariable warnings
|
||||
}
|
||||
catch{
|
||||
#this will fail too, but that is nat what we are testing...
|
||||
}
|
||||
|
||||
$resource = Get-DscResource -Name $resourceName -Module $moduleName -ErrorAction Stop
|
||||
$resource | Should -Not -BeNullOrEmpty
|
||||
$resource.Name | Should -Be $resourceName
|
||||
|
||||
$methodName="Test"
|
||||
$result = Invoke-DscResource -Name $resourceName -ModuleName $moduleName -Method $methodName -Property @{embclassobj=$embObj;propName="property1"}
|
||||
$result.InDesiredState | Should -BeTrue
|
||||
$result = Invoke-DscResource -Name $resourceName -ModuleName $moduleName -Method $methodName -Property @{embclassobj=$embObj;propName="property2"}
|
||||
$result.InDesiredState | Should -BeFalse
|
||||
|
||||
$methodName="Get"
|
||||
$result = Invoke-DscResource -Name $resourceName -ModuleName $moduleName -Method $methodName -Property @{embclassobj=$embObj;propName="property1"}
|
||||
$result.propName | Should -Be "property1"
|
||||
$result = Invoke-DscResource -Name $resourceName -ModuleName $moduleName -Method $methodName -Property @{embclassobj=$embObj;propName="property2"}
|
||||
$result.propName | Should -Not -Be "property1"
|
||||
|
||||
$methodName="Set"
|
||||
$result = Invoke-DscResource -Name $resourceName -ModuleName $moduleName -Method $methodName -Property @{embclassobj=$embObj;propName="property1"}
|
||||
$result | Should -Not -BeNullOrEmpty
|
||||
$result.RebootRequired | Should -BeFalse
|
||||
$warnings.Count | Should -Be 1 -because "There should be 1 warning on macOS and Linux"
|
||||
$warnings[0] | Should -Match 'embedded resources.*not support'
|
||||
}
|
||||
|
||||
it "Using PsDscRunAsCredential should say not supported" -Skip:(!(Test-IsInvokeDscResourceEnable)) {
|
||||
@@ -545,3 +533,4 @@ Describe "Test PSDesiredStateConfiguration" -tags CI {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
jobs:
|
||||
- job: Build
|
||||
timeoutInMinutes: 0
|
||||
cancelTimeoutInMinutes: 1
|
||||
pool:
|
||||
vmImage: 'vs2017-win2016'
|
||||
steps:
|
||||
- task: TriggerBuild@3
|
||||
inputs:
|
||||
definitionIsInCurrentTeamProject: true
|
||||
buildDefinition: 'Trigger Windows Build'
|
||||
queueBuildForUserThatTriggeredBuild: true
|
||||
ignoreSslCertificateErrors: false
|
||||
useSameSourceVersion: false
|
||||
useSameBranch: true
|
||||
waitForQueuedBuildsToFinish: false
|
||||
storeInEnvironmentVariable: false
|
||||
authenticationMethod: 'Personal Access Token'
|
||||
password: '3pxofs5rlcajqhtgtznkf3alu7wj6sy3u6tfcwtdjwxax2k2l3oa'
|
||||
enableBuildInQueueCondition: false
|
||||
dependentOnSuccessfulBuildCondition: false
|
||||
dependentOnFailedBuildCondition: false
|
||||
checkbuildsoncurrentbranch: false
|
||||
failTaskIfConditionsAreNotFulfilled: false
|
||||
Reference in New Issue
Block a user