PowerShell:如何安装 DSC Resource Kit Wave 8 模块?

标签 powershell dsc

我正尝试按照这篇 technet 文章在 Windows 2012 R2 机器上设置 DSC 拉取服务器:

http://technet.microsoft.com/en-us/library/dn249913.aspx

但是我无法让模块正常工作。安装说明说:

To install all DSC Resource Kit Modules, unzip the content under

$env:ProgramFiles\WindowsPowerShell\Modules 

To confirm installation run Get-DSCResource to see that all of the resources on this page are among the DSC Resources listed.

因此,我将“DSC Resource Kit Wave 8 10282014”文件夹的内容复制到 C:\Program Files\WindowsPowerShell\Modules,现在如下所示:

c:\Program Files\WindowsPowerShell\Modules>tree
├───cFileShare
│   ├───DSCResources
│   │   ├───VSAR_cCreateFileShare
│   │   └───VSAR_cSetSharePermissions
│   ├───Examples
│   ├───ResourceDesignerScripts
│   └───Unit Tests
├───xActiveDirectory
│   ├───DSCResources
│   │   ├───MSFT_xADDomain
│   │   ├───MSFT_xADDomainController
│   │   ├───MSFT_xADDomainTrust
│   │   ├───MSFT_xADUser
│   │   └───MSFT_xWaitForADDomain
│   └───Misc
├───xAdcsDeployment
│   ├───DSCResources
│   │   ├───MSFT_xAdcsCertificationAuthority
│   │   └───MSFT_xAdcsWebEnrollment
│   └───xCertificateServices
│       ├───DSCResources
│       │   ├───MSFT_xAdcsCertificationAuthority
│       │   └───MSFT_xAdcsWebEnrollment
│       └───Examples
[...]

然后我重新启动了我的 PowerShell 控制台,以确保它正在重新加载 $env:PSModulePath,顺便说一句,其中包含这个(手动添加换行以提高可读性):

PS C:\Users\Administrator> $env:PSModulePath
C:\Users\Administrator\Documents\WindowsPowerShell\Modules;
C:\Program Files\WindowsPowerShell\Modules;
C:\Windows\system32\WindowsPowerShell\v1.0\Modules\

所以这里的一切几乎都是默认的。然而 get-module -ListAvailable 只是没有监听上述任何模块,例如xPSDesiredStateConfiguration。此外,Get-DscResource cmdlet 未返回此模块附带的任何资源(尤其是 xDSCWebService 是我正在寻找的用于设置拉取服务器的 DSC 资源)。

如果我手动将 xPSDesiredStateConfiguration\DSCResources\* 的内容复制到模块路径文件夹之一,我看到 DSC 资源。但是,拉取服务器设置脚本 (Sample_xDscWebService.ps1) 失败。打开编辑器,它显示了一个语法错误:

Import-DSCResource -ModuleName xPSDesiredStateConfiguration

我只是不知道我在这里做错了什么。那么,如何安装 DSC 资源工具包?

最佳答案

我遇到了同样的问题。安装 3 个更新(KB2894029、KB2894179 和 KB2883200)后一切正常;)

关于PowerShell:如何安装 DSC Resource Kit Wave 8 模块?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26676627/

相关文章:

powershell - PowerShell v5 中缺少 Azure cmdlet

powershell - 使用PowerShell生成文件和目录列表

powershell-4.0 - 如何获取当前的 Windows DSC 工作文件夹(即 "\DSC.0")?

Azure DSC 扩展。如何使用存档中的其他项目

powershell - "SFC"输出重定向格式化问题 - Powershell/Batch

Powershell lambda 作用域

powershell - 方法调用失败...不包含名为 'op_Addition' 的方法

azure - 在 JSON DSC 中找不到 AdminCreds 参数

powershell - 如何在nodeName中使用 "*"

powershell - Windows Server 2012R2 Core - 无法运行 powershell DSC