如何在本地 运行 Powershell DSC 脚本
How to run a Powershell DSC script locally
我正在尝试在本地 运行 一个非常简单的 Powershell DSC 脚本。 (我从不打算在此阶段拉取或推送配置文件)
我收到以下错误消息。 WS-Management 服务是 运行ning,但没有防火墙漏洞或保留端口(服务器恰好是网络服务器)...无论如何我可以允许此服务器只接受本地请求吗?
The client cannot connect to the destination specified in the request.
Verify that the service on the destination is running and is accepting
requests. Consult the logs and documentation for the WS-Management
service running on the destination, most commonly IIS or WinRM. If the
destination is the WinRM service, run the following command on the
destination to analyze and configure the WinRM service: "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
尝试:
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
由于 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
我正在尝试在本地 运行 一个非常简单的 Powershell DSC 脚本。 (我从不打算在此阶段拉取或推送配置文件)
我收到以下错误消息。 WS-Management 服务是 运行ning,但没有防火墙漏洞或保留端口(服务器恰好是网络服务器)...无论如何我可以允许此服务器只接受本地请求吗?
The client cannot connect to the destination specified in the request. Verify that the service on the destination is running and is accepting requests. Consult the logs and documentation for the WS-Management service running on the destination, most commonly IIS or WinRM. If the destination is the WinRM service, run the following command on the destination to analyze and configure the WinRM service: "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
尝试:
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
由于 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