windows – 如何在推送设置中进行正确的错误处理?

前端之家收集整理的这篇文章主要介绍了windows – 如何在推送设置中进行正确的错误处理?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我目前正在建立一个实验室环境,以了解DSC可以实现什么以及限制在哪里.

我们需要根据操作系统,AD组成员资格和包含目标的OU等标准将一次性配置推送到节点组.

所以我开发了以下示例脚本:

  1. # Pulls computer objects from Active Directory
  2. Function Get-Nodes
  3. {
  4. Param($OperatingSystem)
  5.  
  6. Get-AdComputer -Filter 'OperatingSystem -eq ${OperatingSystem}' -SearchBase "OU=SomeThing,DC=contoso,DC=com"
  7. }
  8.  
  9. # Defines the configuration to apply
  10. Configuration ConfigureHostsPush
  11. {
  12. Node $Allnodes.NodeName
  13. {
  14. # This resource is not able to delete a key,only values
  15. Registry ConfigureRegistry
  16. {
  17. Ensure = "Present"
  18. Key = "HKEY_LOCAL_MACHINE\SOFTWARE\"
  19. ValueName = "MachineType"
  20. ValueData = "Hyper-V"
  21. }
  22.  
  23. # This logs the defined message at the _destination_ host
  24. # within Microsoft->Windows->DesiredStateConfiguration->Analytic
  25. # requires showing and enabling the log first!
  26. Log LogSuccessfulRegistry
  27. {
  28. Message = "Successfully configued the defined registry value"
  29. DependsOn = "[Registry]ConfigureRegistry"
  30. }
  31. }
  32. }
  33.  
  34. $nodes = Get-Nodes -OperatingSystem "Windows Server 2012 R2 Standard"
  35. # $nodes = Get-Nodes -OperatingSystem "Windows Server 2008 R2 Standard"
  36. # $nodes = Get-Nodes -OperatingSystem "Windows 7 Professional"
  37.  
  38. # Pulls a list of nodes into a hash table
  39. $ConfigData = @{
  40. AllNodes = @(
  41. foreach ($node in $nodes)
  42. {
  43. @{NodeName = $node.Name}
  44. }
  45. )
  46. }
  47.  
  48. # Generate the MOFs based on the configuration and hosts pulled from AD
  49. ConfigureHostsPush -ConfigurationData $ConfigData
  50.  
  51. # Actually push out the configuration to the nodes
  52. Start-DscConfiguration -wait -Path D:\DATA\DSC\ConfigureHostsPush

但是,在我的情况下,某些节点并不总是可以访问并且处于脱机状态.我该如何进行错误处理和记录?所以我以后可以控制哪些节点成功配置或需要重新配置.

我知道我可以使用DSC日志资源,但这似乎非常有限,只能在LCM /目标节点端生成日志.

一种方法是不跟踪.只需将所有mof文件放在一个文件夹中,并让计划任务每​​天运行两次,将它们推送到您的节点.这很容易设置和管理.设置它并忘记它.

预期的用例是设置拉服务器.您仍然必须配置每个节点与拉取服务器通信.由于节点必须使用拉取服务器签入,因此您确实有一个中心位置,可以告诉您节点是否已签入并且配置正确.您还可以更改拉取服务器上的配置,节点将在下次签入时获取该配置.您不必照看推送过程.

在开始尝试配置所有现有服务器时,您将面临最大的问题.但是,在未来,部署新服务器将处于您可以在配置过程中密切管理的状态.

猜你在找的Windows相关文章