%3CLINGO-SUB%20id%3D%22lingo-sub-1472360%22%20slang%3D%22en-US%22%3EDesired%20State%20Configuration%20code%3A%20How%20to%20troubleshoot%20the%20extension%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1472360%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20folks!%20If%20you%20have%20made%20it%20this%20far%2C%20know%20I%20think%20you%E2%80%99re%20amazing%20and%20one%20of%20a%20kind!%20If%20you%20are%20just%20tuning%20in%20now%20and%20would%20like%20to%20see%20the%20full%20blog%20series%20daisy%20chained%20together%2C%20take%20note%20of%20the%20URLs%20below%2C%20so%20you%20can%20take%20in%20the%20full%20spectrum%20of%20what%20it%20looks%20like%20to%20fully%20automate%20a%20replica%20domain%20controller%20build%20within%20Azure%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fitops-talk-blog%2Fintroduction-to-building-a-replica-domain-controller-arm%2Fba-p%2F1286005%3FWT.mc_id%3DITOPSTALK-blog-shkuehn%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3EIntroduction%20to%20Building%20a%20Replica%20Domain%20Controller%20ARM%20Template%3C%2FA%3E%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fitops-talk-blog%2Fpre-requisites-to-build-a-replica-domain-controller-arm-template%2Fba-p%2F1296961%3FWT.mc_id%3DITOPSTALK-blog-shkuehn%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3EPre-Requisites%20to%20Build%20a%20Replica%20Domain%20Controller%20ARM%20Template%3C%2FA%3E%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fitops-talk-blog%2Fdesign-considerations-of-building-a-replica-domain-controller%2Fba-p%2F1326149%3FWT.mc_id%3DITOPSTALK-blog-shkuehn%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3EDesign%20Considerations%20of%20Building%20a%20Replica%3C%2FA%3E%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fitops-talk-blog%2Fdigging-into-the-replica-domain-controller-arm-template-code%2Fba-p%2F1341004%3FWT.mc_id%3DITOPSTALK-blog-shkuehn%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3EDigging%20into%20the%20Replica%20Domain%20Controller%20ARM%20Template%20Code%3C%2FA%3E%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fitops-talk-blog%2Fdesired-state-configuration-extension-and-the-replica-domain%2Fba-p%2F1390241%3FWT.mc_id%3DITOPSTALK-blog-shkuehn%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3EDesired%20State%20Configuration%20Extension%20and%20the%20Replica%20Domain%20Controller%20ARM%20Template%3C%2FA%3E%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fsbkuehn%2FreplicaDcs%3FWT.mc_id%3DITOPSTALK-blog-shkuehn%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EGitHub%20Repo%20%E2%80%93%20Sample%20Code%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20last%20post%20will%20surround%20the%20actual%20Desired%20State%20Configuration%20code%20%2B%20how%20to%20troubleshoot%20the%20extension.%20Since%20troubleshooting%20the%20extension%20is%20quick%2C%20let%20us%20step%20through%20that%20task%20first.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhen%20you%20head%20over%20to%20the%20extensions%20setting%20underneath%20your%20VM%20blade%2C%20you%20always%20want%20to%20see%20something%20like%20this%3A%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorshankuehn_0%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%20id%3D%22tinyMceEditorshankuehn_9%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%20id%3D%22tinyMceEditorshankuehn_10%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%20id%3D%22tinyMceEditorshankuehn_11%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22pic1-lastblog.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F199331iE9000E9F846DADB4%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22pic1-lastblog.png%22%20alt%3D%22pic1-lastblog.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CBR%20%2F%3EIt%20might%20seem%20obvious%2C%20but%20%E2%80%9CProvisioning%20succeeded%E2%80%9D%20means%20the%20script%20ran%20and%20the%20desired%20state%20configuration%20extension%20has%20been%20applied%20to%20the%20VM%20object.%20Since%20some%20of%20you%20may%20be%20newer%20to%20DSC%2C%20the%20first%20handful%20of%20times%20this%20operation%20may%20not%20work%20properly.%20What%20happens%20if%20you%20see%20something%20like%20this%20instead%3F%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorshankuehn_1%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22pic2-lastblog.png%22%20style%3D%22width%3A%20773px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F199332i7157FD04C77BEF44%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22pic2-lastblog.png%22%20alt%3D%22pic2-lastblog.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EUnfortunately%2C%20that%20means%20you%20must%20dig%20on%20the%20VM%20itself.%20Since%20there%20is%20no%20pull%20server%2C%20all%20troubleshooting%20logs%20show%20up%20on%20the%20deployed%20VM.%20So%20long%20as%20the%20VM%20is%20up%2C%20it%20provisioned%20successfully%2C%20and%20is%20accessible%2C%20the%20log%20files%20will%20generate%20in%20the%20following%20location%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EC%3A%5CWindowsAzure%5CLogs%5CPlugins%5CMicrosoft.Powershell.DSC%5C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhat%20you%20will%20find%20here%20are%20the%20extension%20output%20logs.%20When%20you%20log%20into%20the%20VM%20in%20Azure%2C%20you%20should%20see%20a%20folder%20like%20this%3A%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorshankuehn_2%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22pic3-lastblog.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F199334iEEC3222EF100E8C5%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22pic3-lastblog.png%22%20alt%3D%22pic3-lastblog.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EDrilling%20into%20that%20folder%2C%20you%20should%20see%20a%20series%20of%20text%20files%20with%20number%20GUIDs%20generated%20at%20the%20end.%20Ensure%20you%20see%20%E2%80%9CCommandExecution%E2%80%9D%20and%20%E2%80%9CDscExtensionHandler%E2%80%9D%20files%3A%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorshankuehn_3%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22pic4-lastblog.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F199335iFF5AD7F0EC5FA14A%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22pic4-lastblog.png%22%20alt%3D%22pic4-lastblog.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOpen%20the%20DscExtensionHandler%20file%20and%20filter%20on%20error.%20You%20should%20hopefully%20see%20some%20helpful%20clues%20show%20up%2C%20seeing%20as%20this%20extension%20throws%20verbose%20logging%20into%20these%20files.%20In%20my%20example%20below%2C%20I%20discovered%20that%20I%20had%20either%20mistyped%20the%20password%20or%20did%20not%20formulate%20the%20password%20correctly%20in%20the%20way%20DSC%20requires%3A%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorshankuehn_4%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22pic5-lastblog.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F199336i75F1BC58D50BA8A5%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22pic5-lastblog.png%22%20alt%3D%22pic5-lastblog.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThere%20is%20a%20specific%20workflow%20the%20extension%20follows%20for%20any%20Azure%20VM.%20The%20extension%20package%20is%20downloaded%20and%20deployed%20to%20this%20location%20on%20the%20Azure%20VM%20itself%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EC%3A%5CPackages%5CPlugins%5C%7BExtension_Name%7D%5C%7BExtension_Version%7D%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorshankuehn_5%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22pic6-lastblog.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F199338iBCFB97C53FC0AC66%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22pic6-lastblog.png%22%20alt%3D%22pic6-lastblog.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20extension%20status%20file%20contains%20the%20sub%20status%20and%20the%20status%20success%2Ferror%20codes%20along%20with%20the%20detailed%20error%20and%20description%20for%20each%20extension%20run%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EC%3A%5CPackages%5CPlugins%5C%7BExtension_Name%7D%5C%7BExtension_Version%7D%5CStatus%5C%7B0%7D.Status%26nbsp%3B%20-%26gt%3B%20%7B0%7D%20being%20the%20sequence%20number%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorshankuehn_6%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%20id%3D%22tinyMceEditorshankuehn_12%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22pic7-lastblog.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F199341i32631B1C77D0D49D%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22pic7-lastblog.png%22%20alt%3D%22pic7-lastblog.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENow%2C%20in%20my%20screen%20shots%2C%20you%20will%20not%20see%20any%20%221.status%22%20folders%20because%20one%20of%20the%20troubleshooting%20steps%20within%20the%20DSC%20Extension%20deployment%20is%20to%20remove%20any%20failed%20deployments.%20Remember%20this%20screen%20shot%3F%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorshankuehn_7%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22pic2-lastblog.png%22%20style%3D%22width%3A%20773px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F199342iE2F71A68C3091C77%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22pic2-lastblog.png%22%20alt%3D%22pic2-lastblog.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20the%20DSC%20extension%20deployment%20fails%2C%20you%20need%20to%20uninstall%20the%20extension%20using%20something%20like%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fvirtual-machines%2Fextensions%2Ffeatures-windows%23rerun-vm-extensions%3FWT.mc_id%3DITOPSTALK-blog-shkuehn%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EPowerShell%3C%2FA%3E%2C%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fcli%2Fazure%2Fvm%2Fextension%3Fview%3Dazure-cli-latest%23az-vm-extension-delete%3FWT.mc_id%3DITOPSTALK-blog-shkuehn%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20CLI%3C%2FA%3E%2C%20or%20in%20the%20portal%20by%20examining%20the%20screen%20shot%20below%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22pic8-lastblog.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F199346i08E613E2FB36143F%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22pic8-lastblog.png%22%20alt%3D%22pic8-lastblog.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorshankuehn_8%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENow%20that%20the%20troubleshooting%20and%20caveats%20for%20re-running%20a%20DSC%20extension%20have%20been%20covered%2C%20let%20us%20move%20into%20the%20DSC%20code%20itself.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EMany%20sysadmins%20have%20come%20to%20me%20over%20the%20years%20and%20asked%20how%20to%20manage%20systems%20at%20scale.%20With%20the%20cloud%2C%20many%20sysadmins%20are%20looking%20at%20ways%20to%20build%20and%20manage%20infrastructure%20without%20manual%20intervention.%20Desired%20State%20Configuration%20is%20one%20of%20the%20tools%20I%20talk%20about%20and%20I%20personally%20feel%20it%20can%20be%20one%20of%20the%20unsung%20heroes%20of%20any%20Windows%20server%20system%20environment.%20In%20a%20regular%20configuration%20management%20flow%2C%20DSC%20is%20comprised%20of%20both%20a%20data%20file%20and%20a%20configuration%20file%20that%20are%20compiled%20into%20a%20text%20file%20following%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fwin32%2Fwmisdk%2Fmanaged-object-format--mof-%3FWT.mc_id%3DITOPSTALK-blog-shkuehn%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EManaged%20Object%20Format%20(MOF)%3C%2FA%3E.%20The%20MOF%20file%20is%20then%20parsed%20and%20executed%20on%20the%20target%20server%20using%20DSC%20features%20that%20know%20how%20to%20configure%20the%20system.%20Now%2C%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fscripting%2Fdsc%2Fmanaging-nodes%2Fmetaconfig%3Fview%3Dpowershell-7%3FWT.mc_id%3DITOPSTALK-blog-shkuehn%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3ELocal%20Configuration%20Manager%20(LCM)%3C%2FA%3E%20is%20the%20engine%20of%20DSC.%20The%20LCM%20runs%20on%20every%20target%20node%20and%20is%20responsible%20for%20parsing%20and%20enacting%20configurations%20that%20are%20sent%20to%20the%20node.%20Fun%20fact%2C%20every%20Azure%20VM%20deployed%20within%20your%20subscriptions%20is%20a%20LCM%2C%20so%20DSC%20runs%20naturally%2C%20whether%20evoked%20from%20a%20pull%20server%20or%20through%20a%20DSC%20extension.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20Azure%20DSC%20extension%20uses%20the%20Azure%20VM%20Agent%20framework%20to%20configure%20and%20report%20on%20DSC%20configurations%20running%20on%20Azure%20VMs.%20When%20the%20DSC%20extension%20is%20processed%20the%20first%20time%2C%20it%20will%20install%20the%20right%20version%20of%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fscripting%2Fwindows-powershell%2Fwmf%2Foverview%3Fview%3Dpowershell-7%3FWT.mc_id%3DITOPSTALK-blog-shkuehn%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EWindows%20Management%20Framework%20(WMF)%3C%2FA%3E%2C%20unless%20the%20server%20OS%20is%20Windows%20Server%202016%20or%20newer%20(Windows%20Server%202016%20and%20newer%20OSes%20have%20the%20latest%20version%20of%20PowerShell%20installed).%20If%20WMF%20winds%20up%20installed%20because%20you%20are%20using%20an%20older%20Windows%20OS%2C%20it%20will%20require%20a%20reboot.%20When%20you%20use%20the%20DSC%20extension%2C%20the%20DSC%20extension%20is%20what%20creates%20the%20MOF%20file%2C%20so%20all%20you%20need%20to%20supply%20is%20the%20PowerShell%20script.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESeems%20pretty%20darn%20awesome%2C%20right%3F%20Right.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESo%2C%20what%20does%20the%20actual%20DSC%20script%20look%20like%20in%20my%20GitHub%20repo%3F%20Let%E2%80%99s%20go%20through%20it%20section%20by%20section.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFirst%2C%20the%20configuration%20itself%20is%20given%20a%20title.%20This%20is%20called%20upon%20within%20the%20ARM%20Template.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22pic9-lastblog.png%22%20style%3D%22width%3A%20331px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F199577i6D70AD08A99B19CC%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22pic9-lastblog.png%22%20alt%3D%22pic9-lastblog.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22pic10-lastblog.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F199579iF4276B52F673EBAB%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22pic10-lastblog.png%22%20alt%3D%22pic10-lastblog.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ELet%20us%20expand%20the%20parameters%20next.%20These%20are%20declared%20parameters%20within%20your%20parameters%20JSON%20file%20from%20the%20ARM%20Template%20deployment.%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22pic11-lastblog.png%22%20style%3D%22width%3A%20876px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F199580i9A6CBA5F6E343E5F%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22pic11-lastblog.png%22%20alt%3D%22pic11-lastblog.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22pic12-lastblog.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F199581i1B79356341817E48%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22pic12-lastblog.png%22%20alt%3D%22pic12-lastblog.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOnce%20the%20parameters%20are%20effectively%20declared%2C%20the%20DSC%20script%20imports%20some%20DSC%20modules%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22pic13-lastblog.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F199582i91A1DA2FA6E535F6%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22pic13-lastblog.png%22%20alt%3D%22pic13-lastblog.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWithin%20the%20template%2C%20the%20DSC%20ZIP%20file%20I%20reference%20(found%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fsbkuehn%2FreplicaDcs%2Fblob%2Fmaster%2FDSC%2Fpromote-adds.zip%3Fraw%3Dtrue%3FWT.mc_id%3DITOPSTALK-blog-shkuehn%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E)%20contains%20the%20right%20manifests%20%2B%20DSC%20modules.%20If%20you%20download%20and%20open%20the%20ZIP%20file%2C%20you%20will%20see%20this%20in%20the%20folder%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22pic14-lastblog.png%22%20style%3D%22width%3A%20121px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F199583i111856900CD932EA%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22pic14-lastblog.png%22%20alt%3D%22pic14-lastblog.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ExActiveDirectory%2C%20xDSCDomainjoin%2C%20xNetworking%2C%20xPendingReboot%2C%20and%20xStorage%20are%20all%20experimental%20DSC%20modules%20and%20can%20be%20downloaded%20%3CA%20href%3D%22https%3A%2F%2Fgallery.technet.microsoft.com%2Fscriptcenter%2FDSC-Resource-Kit-All-c449312d%3FWT.mc_id%3DITOPSTALK-blog-shkuehn%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E%20or%20you%20can%20search%20for%20these%20modules%20using%20your%20search%20engine%20of%20choice%20and%20download%20accordingly.%20The%20larger%20zip%20from%20the%20script%20center%20packages%20up%20all%20Microsoft%20documentation%20for%20each%20experimental%20module.%20Personally%2C%20I%20have%20found%20that%20helpful%20when%20trying%20to%20figure%20out%20how%20to%20make%20use%20of%20the%20modules%20to%20build%20a%20domain%20controller.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22pic15-lastblog.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F199584i694606230C4A5106%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22pic15-lastblog.png%22%20alt%3D%22pic15-lastblog.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPackaging%20up%20the%20DSC%20modules%20and%20then%20importing%20them%20in%20the%20script%20you%20pass%20to%20the%20DSC%20extension%20is%20how%20the%20DSC%20extension%20can%20align%20the%20configuration%20on%20the%20target%20nodes.%20The%20DSC%20extension%20takes%20the%20ZIP%20file%20and%20extracts%20the%20modules%20to%20the%20following%20folder%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22pic16-lastblog.png%22%20style%3D%22width%3A%20625px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F199585i532DE6780170F3F2%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22pic16-lastblog.png%22%20alt%3D%22pic16-lastblog.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAdditionally%2C%20the%20PowerShell%20script%20gets%20plugged%20into%20the%20following%20folder%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22pic17-lastblog.png%22%20style%3D%22width%3A%20904px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F199586i17BDF07008FC493A%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22pic17-lastblog.png%22%20alt%3D%22pic17-lastblog.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAnd%20if%20you%20double%20click%20into%20%22CreateADReplicaDC%2C%22%20you%20will%20see%20the%20MOF%20files%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22pic18-lastblog.png%22%20style%3D%22width%3A%20904px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F199588i42044759343C5D60%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22pic18-lastblog.png%22%20alt%3D%22pic18-lastblog.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EBy%20this%20point%2C%20it%20should%20be%20hopefully%20coming%20full%20circle%20in%20terms%20of%20how%20DSC%20and%20the%20DSC%20extension%20work%20to%20configure%20VMs%20during%20deployment%20using%20the%20Azure%20Resource%20Manager%20(ARM)%20model.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAfter%20the%20modules%20are%20imported%2C%20we%20need%20to%20lean%20on%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fdotnet%2Fapi%2Fsystem.management.automation.pscredential%3Fview%3Dpowershellsdk%3FWT.mc_id%3DITOPSTALK-blog-shkuehn-7.0.0%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EPSCredential%20Class%20System.Management.Automation%3C%2FA%3E.%20This%20class%20offers%20a%20centralized%20way%20to%20manage%20usernames%2C%20passwords%2C%20and%20credentials.%20I%20incorrectly%20passed%20credentials%20in%20as%20strings%20(I%20know%2C%20I%20know%20%E2%80%93%20I%20should%20have%20been%20thinking%20about%20credentials%20being%20secure%20objects%20and%20placed%20my%20dev%20hat%20on%2C%20but%20I%20digress).%20I%20leaned%20on%20my%20pal%20%3CA%20href%3D%22https%3A%2F%2Fwww.linkedin.com%2Fin%2Fmattcanty%2F%3FWT.mc_id%3DITOPSTALK-blog-shkuehn%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EMatt%20Canty%3C%2FA%3E%20once%20more%20and%20he%20helped%20me%20formulate%20the%20right%20credential%20object%20by%20using%20these%20two%20lines%20of%20code%20in%20the%20PowerShell%20script%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22pic19-lastblog.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F199589i88FF3AC3936D62FA%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22pic19-lastblog.png%22%20alt%3D%22pic19-lastblog.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAfter%20all%20parameters%20and%20credential%20objects%20are%20declared%20at%20the%20beginning%20of%20the%20PowerShell%20script%2C%20the%20PowerShell%20script%20follows%20a%20specific%20flow.%20I%20will%20outline%20those%20steps%20next%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22pic20-lastblog.png%22%20style%3D%22width%3A%20488px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F199590i8E0997DF86960407%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22pic20-lastblog.png%22%20alt%3D%22pic20-lastblog.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20we%20read%20this%2C%20the%20script%20declaratively%20states%20that%20on%20the%20localhost%2C%20the%20Local%20Configuration%20Manager%20(LCM)%20first%20gets%20called.%20The%20script%20then%20indicates%20that%20the%20configuration%20should%20continue%20after%20any%20reboots%2C%20the%20configuration%20mode%20should%20apply%20the%20configuration%2C%20and%20the%20server%20will%20reboot%20if%20needed.%20The%20script%20then%20installs%20%3CA%20href%3D%22https%3A%2F%2Fwww.microsoft.com%2Fen-us%2Fdownload%2Fdetails.aspx%3Fid%3D45520%3FWT.mc_id%3DITOPSTALK-blog-shkuehn%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3ERSAT%3C%2FA%3E%2C%20which%20are%20good%20tools%20to%20have%20on%20any%20Windows%20server.%20From%20there%2C%20the%20script%20calls%20upon%20the%20xDisk%20experimental%20module%20to%20add%20the%20non-cached%20drive%20for%20the%20SYSVOL%20folder%20(you%20may%20recall%20this%20was%20a%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fitops-talk-blog%2Fdesign-considerations-of-building-a-replica-domain-controller%2Fba-p%2F1326149%3FWT.mc_id%3DITOPSTALK-blog-shkuehn%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3Edesign%20consideration%3C%2FA%3E%20in%20my%203%3CSUP%3Erd%3C%2FSUP%3E%20blog%20post).%20The%20steps%20taken%20to%20initialize%20the%20extra%20drive%20and%20format%20happen%20sequentially%20after%20previous%20tasks%20run%20on%20the%20target%20node.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAfter%20the%20disk%20has%20been%20initialized%20and%20is%20reporting%20as%20ready%20to%20the%20LCM%2C%20the%20script%20moves%20on%20into%20joining%20the%20VM%20to%20the%20domain%2C%20adding%20the%20Active%20Directory%20Domain%20Services%20role%2C%20and%20building%20out%20the%20replica%20domain%20controller%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22pic21-lastblog.png%22%20style%3D%22width%3A%20525px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F199591i23BD1EC0F40BBBAE%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22pic21-lastblog.png%22%20alt%3D%22pic21-lastblog.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAs%20you%20can%20see%2C%20DSC%20code%20is%20not%20too%20hard%20to%20read%20through%20and%20understand%20each%20step%20taken%20before%20deployment.%20Each%20step%20depends%20on%20the%20previous%20step%2C%20so%20you%20declare%20some%20parameters%20you%20want%20met%20related%20to%20the%20Log%20Path%2C%20SYSVOL%20Path%2C%20and%20Database%20Path%2C%20and%20let%20the%20LCM%20do%20the%20rest%20after%20the%20script%20is%20parsed%20and%20applied%20to%20the%20node.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20closing%2C%20if%20you%20take%20on%20this%20code%20and%20run%20into%20problems%2C%20please%20do%20not%20hesitate%20to%20reach%20out.%20The%20steps%20involved%20to%20break%20this%20down%20so%20everyone%20understands%20took%20me%20many%20posts%20to%20unravel.%20The%20beauty%20here%20is%20you%20can%20reach%20out%20if%20you%20get%20stuck%2C%20but%20getting%20deeper%20with%20ARM%20Templates%20and%20understanding%20DSC%20scripting%20is%20going%20to%20take%20you%20from%20regular%20sysadmin%20status%20to%20HERO%20or%20HEROINE%20status%20in%20your%20current%20role.%20%3Asmiling_face_with_smiling_eyes%3A%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1472360%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%3EFinal%20installment%20of%20the%20Replica%20Domain%20Controller%20ARM%20Template%20series%20-%20daisy%20chaining%20all%20blog%20posts%20together%2C%20troubleshooting%20the%20DSC%20extension%2C%20and%20walking%20through%20the%20DSC%20code.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1472360%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EWindows%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EWindows%20Server%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

Hello folks! If you have made it this far, know I think you’re amazing and one of a kind! If you are just tuning in now and would like to see the full blog series daisy chained together, take note of the URLs below, so you can take in the full spectrum of what it looks like to fully automate a replica domain controller build within Azure:

 

Introduction to Building a Replica Domain Controller ARM Template
Pre-Requisites to Build a Replica Domain Controller ARM Template
Design Considerations of Building a Replica
Digging into the Replica Domain Controller ARM Template Code
Desired State Configuration Extension and the Replica Domain Controller ARM Template
GitHub Repo – Sample Code

 

This last post will surround the actual Desired State Configuration code + how to troubleshoot the extension. Since troubleshooting the extension is quick, let us step through that task first.

 

When you head over to the extensions setting underneath your VM blade, you always want to see something like this:

 
 
 
 

pic1-lastblog.png


It might seem obvious, but “Provisioning succeeded” means the script ran and the desired state configuration extension has been applied to the VM object. Since some of you may be newer to DSC, the first handful of times this operation may not work properly. What happens if you see something like this instead?

 

pic2-lastblog.png

 

Unfortunately, that means you must dig on the VM itself. Since there is no pull server, all troubleshooting logs show up on the deployed VM. So long as the VM is up, it provisioned successfully, and is accessible, the log files will generate in the following location:

 

C:\WindowsAzure\Logs\Plugins\Microsoft.Powershell.DSC\

 

What you will find here are the extension output logs. When you log into the VM in Azure, you should see a folder like this:

 

pic3-lastblog.png

 

Drilling into that folder, you should see a series of text files with number GUIDs generated at the end. Ensure you see “CommandExecution” and “DscExtensionHandler” files:

 

pic4-lastblog.png

 

Open the DscExtensionHandler file and filter on error. You should hopefully see some helpful clues show up, seeing as this extension throws verbose logging into these files. In my example below, I discovered that I had either mistyped the password or did not formulate the password correctly in the way DSC requires:

 

pic5-lastblog.png

 

There is a specific workflow the extension follows for any Azure VM. The extension package is downloaded and deployed to this location on the Azure VM itself:

 

C:\Packages\Plugins\{Extension_Name}\{Extension_Version}

 

pic6-lastblog.png

 

The extension status file contains the sub status and the status success/error codes along with the detailed error and description for each extension run:

 

C:\Packages\Plugins\{Extension_Name}\{Extension_Version}\Status\{0}.Status  -> {0} being the sequence number

 
 

pic7-lastblog.png

 

Now, in my screen shots, you will not see any "1.status" folders because one of the troubleshooting steps within the DSC Extension deployment is to remove any failed deployments. Remember this screen shot?

 

pic2-lastblog.png

 

If the DSC extension deployment fails, you need to uninstall the extension using something like PowerShell, the Azure CLI, or in the portal by examining the screen shot below:

 

pic8-lastblog.png

 

 

Now that the troubleshooting and caveats for re-running a DSC extension have been covered, let us move into the DSC code itself.

 

Many sysadmins have come to me over the years and asked how to manage systems at scale. With the cloud, many sysadmins are looking at ways to build and manage infrastructure without manual intervention. Desired State Configuration is one of the tools I talk about and I personally feel it can be one of the unsung heroes of any Windows server system environment. In a regular configuration management flow, DSC is comprised of both a data file and a configuration file that are compiled into a text file following the Managed Object Format (MOF). The MOF file is then parsed and executed on the target server using DSC features that know how to configure the system. Now, the Local Configuration Manager (LCM) is the engine of DSC. The LCM runs on every target node and is responsible for parsing and enacting configurations that are sent to the node. Fun fact, every Azure VM deployed within your subscriptions is a LCM, so DSC runs naturally, whether evoked from a pull server or through a DSC extension.

 

The Azure DSC extension uses the Azure VM Agent framework to configure and report on DSC configurations running on Azure VMs. When the DSC extension is processed the first time, it will install the right version of Windows Management Framework (WMF), unless the server OS is Windows Server 2016 or newer (Windows Server 2016 and newer OSes have the latest version of PowerShell installed). If WMF winds up installed because you are using an older Windows OS, it will require a reboot. When you use the DSC extension, the DSC extension is what creates the MOF file, so all you need to supply is the PowerShell script.

 

Seems pretty darn awesome, right? Right.

 

So, what does the actual DSC script look like in my GitHub repo? Let’s go through it section by section.

 

First, the configuration itself is given a title. This is called upon within the ARM Template.

 

pic9-lastblog.png

pic10-lastblog.png

 

Let us expand the parameters next. These are declared parameters within your parameters JSON file from the ARM Template deployment.

pic11-lastblog.png

pic12-lastblog.png

 

Once the parameters are effectively declared, the DSC script imports some DSC modules:

 

pic13-lastblog.png

 

Within the template, the DSC ZIP file I reference (found here) contains the right manifests + DSC modules. If you download and open the ZIP file, you will see this in the folder:

 

pic14-lastblog.png

 

xActiveDirectory, xDSCDomainjoin, xNetworking, xPendingReboot, and xStorage are all experimental DSC modules and can be downloaded here or you can search for these modules using your search engine of choice and download accordingly. The larger zip from the script center packages up all Microsoft documentation for each experimental module. Personally, I have found that helpful when trying to figure out how to make use of the modules to build a domain controller.

 

pic15-lastblog.png

 

Packaging up the DSC modules and then importing them in the script you pass to the DSC extension is how the DSC extension can align the configuration on the target nodes. The DSC extension takes the ZIP file and extracts the modules to the following folder:

 

pic16-lastblog.png

 

Additionally, the PowerShell script gets plugged into the following folder:

 

pic17-lastblog.png

 

And if you double click into "CreateADReplicaDC," you will see the MOF files:

 

pic18-lastblog.png

 

By this point, it should be hopefully coming full circle in terms of how DSC and the DSC extension work to configure VMs during deployment using the Azure Resource Manager (ARM) model.

 

After the modules are imported, we need to lean on the PSCredential Class System.Management.Automation. This class offers a centralized way to manage usernames, passwords, and credentials. I incorrectly passed credentials in as strings (I know, I know – I should have been thinking about credentials being secure objects and placed my dev hat on, but I digress). I leaned on my pal Matt Canty once more and he helped me formulate the right credential object by using these two lines of code in the PowerShell script:

 

pic19-lastblog.png

 

After all parameters and credential objects are declared at the beginning of the PowerShell script, the PowerShell script follows a specific flow. I will outline those steps next:

 

pic20-lastblog.png

 

If we read this, the script declaratively states that on the localhost, the Local Configuration Manager (LCM) first gets called. The script then indicates that the configuration should continue after any reboots, the configuration mode should apply the configuration, and the server will reboot if needed. The script then installs RSAT, which are good tools to have on any Windows server. From there, the script calls upon the xDisk experimental module to add the non-cached drive for the SYSVOL folder (you may recall this was a design consideration in my 3rd blog post). The steps taken to initialize the extra drive and format happen sequentially after previous tasks run on the target node.

 

After the disk has been initialized and is reporting as ready to the LCM, the script moves on into joining the VM to the domain, adding the Active Directory Domain Services role, and building out the replica domain controller:

pic21-lastblog.png

 

As you can see, DSC code is not too hard to read through and understand each step taken before deployment. Each step depends on the previous step, so you declare some parameters you want met related to the Log Path, SYSVOL Path, and Database Path, and let the LCM do the rest after the script is parsed and applied to the node.

 

In closing, if you take on this code and run into problems, please do not hesitate to reach out. The steps involved to break this down so everyone understands took me many posts to unravel. The beauty here is you can reach out if you get stuck, but getting deeper with ARM Templates and understanding DSC scripting is going to take you from regular sysadmin status to HERO or HEROINE status in your current role. :smiling_face_with_smiling_eyes: