【问题标题】:How to run a Powershell DSC script locally如何在本地运行 Powershell DSC 脚本
【发布时间】:2016-09-13 01:08:22
【问题描述】:

我正在尝试在本地运行一个非常简单的 Powershell DSC 脚本。 (我从不打算在这个阶段拉取或推送配置文件)

我收到以下错误消息。 WS-Management 服务正在运行,但没有防火墙漏洞或保留端口(服务器恰好是网络服务器)......无论如何我可以让这个服务器只接受本地请求吗?

客户端无法连接到请求中指定的目的地。 验证目标上的服务是否正在运行并且正在接受 要求。查阅 WS-Management 的日志和文档 在目标上运行的服务,最常见的是 IIS 或 WinRM。如果 目的地是WinRM服务,在上面运行以下命令 分析和配置 WinRM 服务的目的地:“winrm 快速配置”。 + CategoryInfo : ConnectionError: (root/Microsoft/...gurationManager:String) [], CimException + 完全限定错误 ID:HRESULT 0x80338012 + PSComputerName : 本地主机

 configuration SampleIISInstall
    {
        Node 127.0.0.1
        {
          File FileDemo {
            Type = 'Directory'
            DestinationPath = 'C:\TestUser3'
            Ensure = "Present"
        }
        }
    }

    # Compile the configuration file to a MOF format
    SampleIISInstall

    # Run the configuration on localhost
    Start-DscConfiguration -Path .\SampleIISInstall -Wait -Force -Verbose

【问题讨论】:

    标签: web-services powershell dsc


    【解决方案1】:

    试试:

    配置示例IISInstall { 节点“本地主机” { 文件文件演示{ 类型 = '目录' DestinationPath = 'C:\TestUser3' 确保 = “现在” } } } # 将配置文件编译成MOF格式 示例IIS安装 # 在 localhost 上运行配置 开始-DscConfiguration -Path .\SampleIISInstall -Wait -Force -Verbose

    【讨论】:

      【解决方案2】:

      由于 DSC 使用 PowerShell 远程处理,您不能使用 IP 地址作为节点名,您必须指定计算机名称。使用 localhost 或 $env:computername 应该可以工作,您还可以完全删除节点块,只编写没有它的 DSC 配置。

       configuration SampleIISInstall
          {
                File FileDemo {
                  Type = 'Directory'
                  DestinationPath = 'C:\TestUser3'
                  Ensure = "Present"
              }
              }
      
          # Compile the configuration file to a MOF format
          SampleIISInstall
      
          # Run the configuration on localhost
          Start-DscConfiguration -Path .\SampleIISInstall -Wait -Force -Verbose
      

      【讨论】:

        猜你喜欢
        • 2011-01-03
        • 1970-01-01
        • 1970-01-01
        • 2013-03-06
        • 1970-01-01
        • 1970-01-01
        • 2017-09-30
        • 1970-01-01
        • 2017-08-24
        相关资源
        最近更新 更多