使用Windows Server 2012 R2。
目标是设置服务器的IPv4地址。 正如DSC在下面的详细消息中正确指出的那样,Expected [ip是] 192.168.0.203,[while] actual [ip is] 192.168.0.205
以下错误消息:
Start-DscConfiguration -Path .\BasicServer -Verbose -Wait -Force VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = SendConfigurationApply,'className' = MSFT_DSCLocalConfigurationManager,'namespaceName' = root/Microsoft/Windows/DesiredStateConfiguration'. VERBOSE: An LCM method call arrived from computer ComputerName with user sid S-1-5-21-139086020-2308268882-217435134-1104. VERBOSE: [ComputerName]: LCM: [ Start Set ] VERBOSE: [ComputerName]: LCM: [ Start Resource ] [[xIPAddress]IPAddress] VERBOSE: [ComputerName]: LCM: [ Start Test ] [[xIPAddress]IPAddress] VERBOSE: [ComputerName]: [[xIPAddress]IPAddress] Checking the IPAddress ... VERBOSE: [ComputerName]: [[xIPAddress]IPAddress] IPAddress not correct. Expected 192.168.0.203, actual 192.168.0.205 VERBOSE: [ComputerName]: LCM: [ End Test ] [[xIPAddress]IPAddress] in 0.0310 seconds. VERBOSE: [ComputerName]: LCM: [ Start Set ] [[xIPAddress]IPAddress] VERBOSE: [ComputerName]: [[xIPAddress]IPAddress] Checking the IPAddress ... VERBOSE: [ComputerName]: [[xIPAddress]IPAddress] IPAddress not correct. Expected 192.168.0.203, actual 192.168.0.205 VERBOSE: [ComputerName]: [[xIPAddress]IPAddress] Setting IPAddress ... VERBOSE: [ComputerName]: [[xIPAddress]IPAddress] Instance DefaultGateway already exists VERBOSE: [ComputerName]: LCM: [ End Set ] [[xIPAddress]IPAddress] in 0.0620 seconds. PowerShell DSC resource MSFT_xIPAddress failed to execute Set-TargetResource functionality with error message: Can not set or find valid IPAddress using InterfaceAlias Ethernet and AddressFamily IPv4 + CategoryInfo : InvalidOperation: (:) [], CimException + FullyQualifiedErrorId : ProviderOperationExecutionFailure + PSComputerName : ComputerName.domain.com The SendConfigurationApply function did not succeed. + CategoryInfo : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException + FullyQualifiedErrorId : MI RESULT 1 + PSComputerName : ComputerName.domain.com VERBOSE: Operation 'Invoke CimMethod' complete. VERBOSE: Time taken for configuration job to complete is 0.268 seconds
在应用以下xNetworking DSCconfiguration时抛出…
Import-DscResource -Module xNetworking Node $NodeFQDN { xIPAddress IPAddress { InterfaceAlias = "Ethernet" IPAddress = $IPv4 AddressFamily = "IPV4" DefaultGateway = '192.168.0.1' SubnetMask = 24 }}
其中$ IPv4 ='192.168.0.203'。
我注意到本地configurationpipe理器能够进行Test-DSCCconfiguration,只能应用任何与IP相关的更改。 我已经通过在系统上运行上面的configuration来testing这个,而IP已经被正确设置了。
由于在Test-DSCCconfiguration操作期间LCM显然能够find适配器,所以“无法使用InterfaceAlias Ethernet和AddressFamily IPv4设置或查找有效的IP地址”消息令人困惑。
有关为什么本地configurationpipe理器无法应用configuration的任何线索? 我没有看到什么?
解决方法是从configuration中删除默认网关:DefaultGateway ='192.168.0.1'
看起来,如果除了基本的configuration(IPAddress,InterfaceAlias,SubnetMask,AddressFamily)之外还有其他的configuration,DSC将会把重点放在附加的项目上,并把基础的项目作为参考。 考虑以下:
xIPAddress IPAddress { InterfaceAlias = 'Ethernet' IPAddress = '192.168.0.203' AddressFamily = 'IPV4' SubnetMask = 24 }
以上configuration将IP地址设置为192.168.0.203。
xIPAddress IPAddress { InterfaceAlias = 'Ethernet' IPAddress = '192.168.0.203' AddressFamily = 'IPV4' SubnetMask = 24 DefaultGateway = '192.168.0.1' }
以上configuration将find一个名为“Ethernet”的适配器,其IP地址为192.168.0.203,并将其DefaultGatewayconfiguration为192.168.0.1。 在我的问题中,本地configurationpipe理器无法find这样一个适配器。 我试图同时设置IP和网关。
这一发现使我明白,设置IP和configuration其他适配器属性不能在单个configuration中完成。 这种消除了使用单个(是的,只有1个)脚本来configuration服务器端到端的想法。
我得到这个权利?
PS我也经历了configuration追加新的IP而不是replace。 现在不会进入,但非常有趣的行为…