如何在Powershell 5.0 DSC拉模式下设置客户端

时间:2016-04-26 06:44:46

标签: powershell dsc

我为DSC设置了2台服务器,运行Powershell 5.0和Server 12 R2,DSCPULL通过HTTP配置为DSC Pull Server,DSCIIS是客户端。

在DSCIIS上我试图设置它以便它通过配置名称从Pull服务器下载配置,我从MSDN网站获取代码并稍微改变了我的要求,但它仍然无法正常工作。 / p>

[DSCLocalConfigurationManager()]
configuration PullClientConfigID
{
    Node localhost
    {
        Settings
        {
            RefreshMode = 'Pull'
            RefreshFrequencyMins = 30 
            RebootNodeIfNeeded = $true
        }

        ConfigurationRepositoryWeb DSCPULL
        {
            ServerURL = 'http://DSCPULL:8080/PSDSCPullServer.svc'
            RegistrationKey = 'test'
            ConfigurationNames = @('WebServer')
            AllowUnsecureConnection = $true
        }
    }
}

PullClientConfigID -OutputPath c:\Configs\TargetNodes
Start-DscConfiguration C:\Configs\TargetNodes -ComputerName localhost -wait -Verbose

我收到的错误是

Start-DscConfiguration : The computer-specific MOF file for computer localhost does not exist in the current directory.
At line:1 char:1
+ Start-DscConfiguration C:\Configs\TargetNodes -ComputerName localhost ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Start-DscConfiguration], ArgumentException
    + FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.DesiredStateConfiguration.Commands.StartDscConfiguration 
   Command

我已尝试将“Node Localhost”更改为服务器名称,然后使用正确的“ComputerName”运行最后一行,但我得到相同的错误。

1 个答案:

答案 0 :(得分:1)

我本应该使用Set-DSCLocalConfigurationManager而不是Start-DSCConfiguration

Set-DSCLocalConfigurationManager localhost –Path C:\Configs\TargetNodes –Verbose