如何找到DSC资源的参数/模式?使用我的配置说一个是未定义的

时间:2017-03-29 15:40:23

标签: powershell dsc

我正在编写DSC Pull Server脚本来生成MOF文件。 xDSCWebService 资源需要一个布尔值来表示我已定义的值 UseSecurityBestPractices 。但是,运行该脚本会生成错误:“Undefined Property UseSecurityBestPractices”。

正如您可能已经说过的那样,我对Powershell世界,尤其是DSC都很陌生 Link to picture of error message
有什么想法吗?

Configuration NewPullServer
{
$ComputerName = 'localhost'
Import-DscResource -ModuleName PSDesiredStateConfiguration
Import-DscResource -Name xDSCWebService

Node $ComputerName 
{
    WindowsFeature DSCServiceFeature
    {
        Ensure = "Present"
        Name = "DSC-Service"
    }

    xDscWebService PSDSCPullServer
    {
        Ensure = "Present"
        UseSecurityBestPractices = $True
        EndpointName = "PSDSCPullServer"
        Port = 8080
        PhysicalPath = "$env:SystemDrive\inetpub\wwwroot\PSDSCPullServer"
        CertificateThumbprint = "AllowUnencryptedTraffic"
        ModulePath = "$env:PROGRAMFILES\WindowsPowershell\DscService\Modules"
        ConfigurationPath = "$env:PROGRAMFILES\WindowsPowershell\DscService\Configuration"
        State = "Started"
        DependsOn = "[WindowsFeature]DSCServiceFeature"
    }

    xDscWebService PSDSCComplianceServer
    {
        Ensure = "Present"
        EndpointName = "PSDSCComplianceServer"
        Port = 9080
        PhysicalPath = "$env:SystemDrive\inetpub\wwwroot\PSDSCComplianceServer"
        CertificateThumbprint = "AllowUnencryptedTraffic"
        State = "Started"
        UseSecurityBestPractices = $True
        DependsOn = ("[WindowsFeature]DSCServiceFeature","[xDSCWebService]PSDSCPullServer")
    }
}
}


NewPullServer
Start-DscConfiguration ./NewPullServer -Wait -verbose

1 个答案:

答案 0 :(得分:1)

您的资源上没有UseSecurityBestPractices参数。

MSFT_xDSCWebService xPSDesiredStateConfiguration来自https://gallery.technet.microsoft.com/xPSDesiredStateConfiguratio-417dc71d

下载并打开zip,您将在xPSDesiredStateConfiguration_3.0.3.4.zip \ xPSDesiredStateConfiguration \ DSCResources \ MSFT_xDSCWebService中找到该资源的定义,并在MSFT_xDSCWebService.Schema.mof中找到其参数架构。

可用参数是:

[ClassVersion("1.0.0"), FriendlyName("xDSCWebService")] 
class MSFT_xDSCWebService : OMI_BaseResource
{
  [Key] string EndpointName;
  [required] string CertificateThumbPrint;
  [write] uint32 Port;
  [write] string PhysicalPath;
  [write,ValueMap{"Present", "Absent"},Values{"Present", "Absent"}] string Ensure;
  [write,ValueMap{"Started","Stopped"},Values{"Started", "Stopped"}] string State;
  [write] string ModulePath;
  [write] string ConfigurationPath;
  [write] boolean IsComplianceServer;
  [read] string DSCServerUrl;  
};