PowerShell DSC节点'localhost'的MOF定义无效

时间:2016-05-27 09:09:37

标签: powershell dsc

由于我是PowerShell和DSC(以及总体编程)的新手,我有一个问题,我无法在网上找到答案。

我正在尝试使用PS DSC安装msi(或exe)。我成功地编写了一个脚本来检查和安装windows-features并安装JDK并设置ressources。 但是我的下一步似乎过度挑战了。

所以我的代码到目前为止:

$ConfigurationData = @{
AllNodes = @(
            @{
                NodeName="*"
                PSDscAllowPlainTextPassword=$true
             }
       )
    }



    Configuration AppFabric
    {
        param (
            $TargetNodes,

            [Parameter(Mandatory=$false)]
            [PSCredential]$Credential
        )

        Import-DscResource –ModuleName ’PSDesiredStateConfiguration’

        Node localhost
        {

            Package AppFabric
            {
                 Ensure = "Present"
                 Name = "AppFabric"
                 Path  = "$PWD\src\AppFabric\package\appfabric-1.1-for-windows-server-64.msi"
                 ProductId = ""
                 LogPath = "$PWD\logs\$env:computername-AppFabric"
                 Arguments = "/i HostingServices,CacheClient,HostingServicesAdmin"
                 Credential = "$Credential"
            }
         }
      }

      AppFabric -OutputPath $PWD\mof\AppFabric\

      Start-DscConfiguration -Path $PWD\mof\AppFabric\ -wait -verbose -Force

因此,当您看到我尝试在Windows Server 2012R2上安装最新的AppFabric时。

当我运行脚本时,我收到以下错误:

enter image description here

我不知道,这意味着什么,在网络上找不到任何有用的东西。

如果您需要更多信息,请告诉我,正如我所说,我是新手:x

谢谢!

编辑: 如果我在没有凭据的情况下尝试这样做,我会得到以下结果:

VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = SendConfigurationApply,'className' = MSFT_DSCLocalConfigurationManager,'namespaceName' = root/Microsoft/Windows/DesiredStateConfiguration'.

1 个答案:

答案 0 :(得分:0)

您将凭据属性视为字符串而非 PSCredential 。 从凭据属性中删除双引号以解决此问题。

Package AppFabric
            {
                 Ensure = "Present"
                 Name = "AppFabric"
                 Path  = "$PWD\src\AppFabric\package\appfabric-1.1-for-windows-server-64.msi"
                 ProductId = ""
                 LogPath = "$PWD\logs\$env:computername-AppFabric"
                 Arguments = "/i HostingServices,CacheClient,HostingServicesAdmin"
                 Credential = $Credential
            }