如何在本地运行Powershell DSC脚本

Kye*_*Kye 6 powershell web-services dsc

我正试图在本地运行一个非常简单的Powershell DSC脚本.(我从不计划在此阶段提取或推送配置文件)

我收到以下错误消息.WS-Management服务正在运行,但没有保留防火墙漏洞或端口(服务器恰好是一个Web服务器)...反正我是否可以允许此服务器只接受本地请求?

客户端无法连接到请求中指定的目标.验证目标上的服务是否正在运行并且正在接受请求.查阅目标上运行的WS-Management服务的日志和文档,最常见的是IIS或WinRM.如果目标是WinRM服务,请在目标上运行以下命令以分析和配置WinRM服务:"winrm quickconfig".+ CategoryInfo:ConnectionError:(root/Microsoft/... gurationManager:String)[],CimException + FullyQualifiedErrorId:HRESULT 0x80338012 + PSComputerName:localhost

 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
Run Code Online (Sandbox Code Playgroud)

N.G*_*pta 5

尝试:

configuration SampleIISInstall
    {
        Node "localhost"
        {
          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