在通过ARM模板运行DSC配置之前配置Azure VM LCM

时间:2017-03-09 15:02:31

标签: powershell azure dsc

我尝试通过ARM模板配置Azure VM,并且需要在VM上设置本地配置管理器以允许在运行DSC配置之前重新启动。我有一种方法,有时但不总是有效。我通过Azure CustomScriptExtension

运行以下脚本
Sub copier_texte()  'je veux copier le contenu de la forme, et non pas la forme en entier

Dim nb_slide As Integer
nb_slide = ActivePresentation.Slides.Count

With ActivePresentation
.Slides(1).Shapes(2).TextFrame.TextRange.Copy 'je sélectionne uniquement le contenu de la forme
For i = 2 To .Slides.Count
        .Slides(i).Select
        ActiveWindow.View.Paste
Next i
End With

End Sub 
然后是DSC扩展。似乎CustomScriptExtension工作,但DSC扩展可能会将RebootNodeIfNeeded更改为false。 DSC扩展取决于CustomScriptExtension。

[DscLocalConfigurationManager()]
Configuration ConfigureLcm {
  Node localhost {
    Settings {
        RebootNodeIfNeeded   = $true
    }
  }
}

if (!(Get-DscLocalConfigurationManager).RebootNodeIfNeeded) {
    ConfigureLcm -OutputPath C:\Config
    Set-DscLocalConfigurationManager -Path C:\Config
}

还有其他人经历过这个吗?

1 个答案:

答案 0 :(得分:0)

DSC扩展将覆盖本地配置管理器(LCM),如果您没有明确的LCM设置,它们将恢复为默认值。因此,您需要在用于DSC扩展的配置功能中再次设置它:

Configuration Main
{
  Node localhost
  {
    LocalConfigurationManager
    {
      RebootNodeIfNeeded = $true
      ...
    }
    # Your other resources
    ...
  }
}´
相关问题