问题标签 [dsc]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
529 浏览

powershell - PowerShell DSC 资源未找到配置关键字

我正在为我们的开发机器获取 DSC 配置设置。我遇到的要么是我如何处理复合资源的错误,要么是我看不到的东西。

我可以毫无问题地运行 DevMachineConfig.ps1,但是当我使用 创建 MOF 文件时DeveloperMachine -ConfigurationData $ConfigurationData,出现以下错误:

我只是不清楚为什么Configuration关键字上会出现空值,因为这似乎是内置于 DSC 中的。

所以我的问题是这是我的错误还是 DSC 的错误?

以下是文件和相关信息

我的“项目”布局:

*Modules 文件夹连接到 $env:ProgramFiles\WindowsPowershell\Modules

开发机器配置.ps1

获取DscResources.schema.psm1

CreateDomainController.schema.psm1

0 投票
2 回答
1628 浏览

powershell - 使用 Powershell DSC 管理常用配置文件

我们正在为我们的内部 .NET 应用程序开发基于 Windows DSC 的部署系统。作为当前安装说明的一部分,有一个步骤可以编辑 .NET machine.config 文件。(是的,我知道我们的应用程序需要这个很糟糕,但我目前无法解决这个问题)。

我想知道其他人如何使用 DSC 管理“通用”配置文件?我看不出有什么方法可以很好地做到这一点,但很高兴能看到如何做到这一点。

我能想到的唯一方法是创建几个自定义 DSC 模块来管理部分 INI 文件和 XML 配置文件。

我提出具有以下规范的模块:

(注意:当目标可能不存在时,我不知道有任何方法可以获取任意 XPath 选择器并将其分解以获取父元素的选择器,因此我必须同时指定父元素和目标元素)

要将自定义设置组添加到 machine.config 我将声明如下内容:

创建这些模块是解决这个问题的“最佳”方法吗?我是否错过了一些关于 DSC 的“正确”方法?

任何建议将不胜感激。

0 投票
1 回答
507 浏览

powershell - PowerShell DSC:错误 22 使用证书加密服务资源中的凭据

我正在尝试使用证书将凭据嵌入到服务资源中。我在基础设施中安装了 PKI,并且我的所有测试服务器都是自动注册的。我在本地导出了他们的证书以使用并将它们放在我的 ConfigData 中,如下所示:

这是我正在运行的配置脚本:

据我所知,它应该可以工作。我的 MOF 是在内部使用加密密码生成的,但是当客户端服务器获取配置并进入服务步骤时,它会出错。检查事件查看器,这是事件的详细信息:

"此事件表示 LCM 处理配置时发生故障。ErrorId 为 0x1。ErrorDetail 为 SendConfigurationApply 函数未成功。ResourceId 为 [Service]Service-Adobe CF9 1,SourceInfo 为 D:\EQ_DSCModule\EqConfig.ps1: :285::4::Service。ErrorMessage 是 PowerShell 提供程序 MSFT_ServiceResource 无法执行 Set-TargetResource 功能,并显示错误消息:无法更改“凭据”属性。消息:“Win32_Service”的“更改”方法失败,错误代码: '22'。。”

根据 MSDN ( https://msdn.microsoft.com/en-us/library/aa384901%28v=vs.85%29.aspx ) Change 方法上的错误代码 22 表示“运行此服务的帐户是无效或缺乏运行服务的权限。” 我知道服务帐户工作正常,我可以使用 WMI 自己添加它,如下所示:

因此,如果我可以使用 WMI 添加帐户,那么 DSC 应该也可以,对吧?啊!

想法?

0 投票
1 回答
306 浏览

powershell - xWebAdministration 资源未出现在 Get-DscResource 中

我正在尝试在 Windows Server 2012 R2 VM 上进行基本 DSC 配置,但是当我运行 Get-DscResource 时,列表中没有出现任何 xWebAdministration 资源。

当我跑

我得到以下

查看其他模块exportedCommands 不应为空。

关于如何解决这个问题的任何建议?

我做了什么

我已经下载了1.3.2 版本并将其解压到 C:\Program Files\WindowsPowerShell\Modules

发现此xWebAdministration 未出现在 Get-DscResource (PowerShell) 中,但结构正确。

0 投票
0 回答
237 浏览

powershell - Implement PowerShell DSC with existing continuous Deployment Process

I am doing PowerShell DSC POC. I configured the Pull server and one client machine. It is working fine and I am very much happy about PowerShell DSC feature.

Now I want to integrate this feature with our continuous Integration process. We are using Nolio for MSI deployment and do the other configurations. As of now I want to use DSC only for configurations and Nolio will continue for deployment process (due to reduce the Migration complexity). Later we planned to replace the Nolio with DSC including deployment. Here is my questions.

1) We have monthly releases. As per my understanding I need to install the MSI(will deploy websites) in all machines including Pull Server and Nodes. Then I will do the configuration settings using Pull Server configuration. Once I configured the Pull server how could I do the second deployment. Will Pull server node create any problem at the time of deployment like reverting the installed files as per old configurations? Is there any way to stop the Pull server settings at the time of deployment?

2) If I want to install MSI also from DSC, I am planning to do that like below.

  • Change the Pull server configuration to install the MSI from other configuration settings.
  • Install the MSI in Pull server and all Node machines.
  • Do all other configurations in Pull server.
  • Change the configuration to apply pull server configurations to Node from Install MSI.

Is this good process?

Could you please anyone help me to achieve this? Please share if you have any other best practices.

Thanks in advance.

0 投票
1 回答
575 浏览

powershell - DSC 资源全局变量

我正在尝试使用全局变量将一些信息从 Test-TargetResource 传递给 Set-TargetResource,但是当我运行我的配置时它不起作用。

您可以在 DSC 资源中使用全局变量吗?

0 投票
1 回答
802 浏览

powershell - 通过 dsc 设置机器代理

我想通过 DSC 设置机器代理配置,是否有人已经这样做或知道我应该使用哪个 dsc 资源?

我尝试按照https://p0w3rsh3ll.wordpress.com/2015/01/29/dsc-configuring-a-proxy/设置注册表项

0 投票
1 回答
502 浏览

powershell - 两个包资源没有在 Powershell DSC 中连续安装

我正在使用包资源在 PowerShell DSC 中安装 MSI 和 EXE。我正在使用拉模式。我正在触发一致性作业以检查配置是否应用于测试。(无法等待 30 分钟进行单次测试:))这是我的代码。

当我运行作业时,有时会安装一个包。下次安装另一个包,依此类推。我们需要安装 10 多个安装程序。如果一次安装一次,那么如果每 30 分钟安装一次,配置将需要一天以上的时间才能完全配置。

无论如何,这是一次安装所有软件包吗?

提前致谢。

0 投票
2 回答
2082 浏览

powershell - 我可以在 DSC 文件资源中有动态变量吗

如何在运行时获取所需状态配置的文件资源以确定它的 $DestinationPath?这似乎仅在生成 mof 文件时设置。

我下面的脚本显示了我正在尝试做的事情。我知道为什么它不起作用,我找不到如何使它起作用。

该脚本查看目标计算机上的 PSModulePath 变量并从变量中提取单个路径。我想将此路径传递给脚本中的文件资源,以在该路径中安装一些自定义 Powershell 模块。

我使用变量 $LocalInstallPath 但这不起作用,因为它是在创建 mof 文件时在 File 资源中设置的。尝试设置为环境变量,但同样的问题。

有没有办法做到这一点?

0 投票
2 回答
359 浏览

powershell - AzureVM 上的 Powershell DSC xChrome 示例失败

我正在尝试在 Azure VM 上运行 xChrome 示例 ( https://gallery.technet.microsoft.com/scriptcenter/DSC-Resource-Kit-All-c449312d ),但它无法运行。一切都运行并执行,但我收到错误(下面是更大的日志片段):

CategoryInfo : ObjectNotFound: (MSFT_xChrome\MSFT_xChrome:String) [配置]

AzureVM 是带有 Powershell 版本 5 的 Windows Server 2012:$PSVersionTable.PSVersion

主要次要版本修订


5 0 9883 0
我用来执行的步骤是:

  1. 下载 xChrome 扩展程序(从上面的 url)并将其添加到我的模块目录中
  2. 发布-AzureVMDscConfiguration -ConfigurationPath C:\Users\Documents\WindowsPowerShell\Modules\xChrome\Example\Sample_xChrome.ps1 -Force
  3. 获取 AzureVM -ServiceName '' -Name '' | Set-AzureVMDscExtension -ConfigurationArchive Sample_xChrome.ps1.zip -ConfigurationName Sample_InstallChromeBrowser -ConfigurationArgument @{Language='en';LocalPath='$env:SystemDrive\Windows\DtlDownloads\GoogleChromeStandaloneEnterprise.msi'} | 更新-AzureVM
  4. **错误片段:* [2015-04-17T23:35:06] 执行配置函数生成 MOF 文件。PSDesiredStateConfiguration\Configuration :无法加载模块“MSFT_xChrome”。有关更多信息,请运行“导入模块 MSFT_xChrome”。在 C:\Packages\Plugins\Microsoft.Powershell.DSC\1.7.0.0\DSCWork\Sample_xChrome.ps1.8\Sample_xChrome.ps1:3 char:1
    • 配置示例_InstallChromeBrowser
    • ~~~~~~~~~~~~~
    • CategoryInfo : ObjectNotFound: (MSFT_xChrome\MSFT_xChrome:String) [配置],ParentContainsErrorRecordException
    • fullyQualifiedErrorId : CouldNotAutoLoadModule,Configuration

[2015-04-17T23:35:08] 删除文件锁定 C:\Packages\Plugins\Microsoft.Powershell.DSC\1.7.0.0\bin\DscExtensionHandler.ps1:启用 DSC 扩展时出错:处理配置“Sample_InstallChromeBrowser”时出错'。在 line:7 char:2 + C:\Packages\Plugins\Microsoft.Powershell.DSC\1.7.0.0\bin\DscExtensio ...