我遇到了一个问题,即使用复合资源时无法生成 .mof 文件。目录创建正常,没有显示任何错误。对于一些新手来说,这可能是一个简单的问题,但我没有看到它 :)
复合资源被正确识别,正如我所说,没有显示任何错误。任何帮助我都会很感激!
这是我的配置文件:
复合资源
Configuration OfficeServer
{
PARAM
(
[string]$IPAddress
)
Import-DscResource -Modulename XNetworking, PSDesiredStateConfiguration
{
xIPAddress IPAddress
{
IPAddress = $IPAddress
InterfaceAlias = "Ethernet"
DefaultGateway = "192.168.10.1"
SubnetMask = 24
AddressFamily = "IPV4"
}
xDNSServerAddress DNSServer
{
Address = "192.168.10.44"
InterfaceAlias = "Ethernet"
AddressFamily = "IPV4"
}
}
}
生成 .mof 的配置
Configuration test
{
Import-DscResource -modulename CommonConfig
Node localhost
{
OfficeServer test
{
IPAddress = "192.168.10.92"
}
}
}
答案1
感谢大家的回答,原来我在复合资源中多了一对花括号。直到睡着了才看到它:)
复合资源的工作版本
Configuration OfficeServer
{
PARAM
(
[string]$IPAddress
)
Import-DscResource -Modulename XNetworking, PSDesiredStateConfiguration
xIPAddress IPAddress
{
IPAddress = $IPAddress
InterfaceAlias = "Ethernet"
DefaultGateway = "192.168.10.1"
SubnetMask = 24
AddressFamily = "IPV4"
}
xDNSServerAddress DNSServer
{
Address = "192.168.10.44"
InterfaceAlias = "Ethernet"
AddressFamily = "IPV4"
}
}