powershell - Unable to run Node and Script in Desired State Configuration -


background

i provisioning vm in azure using arm template , created desired state configuration .ps1 file installs , configures iis. far good.

i added script block right next node block.

current set up:

configuration main {     param ( [string] $nodename )      import-dscresource -modulename psdesiredstateconfiguration      node $nodename     {         windowsfeature webserver         {             name = "web-server"             ensure = "present"         }          #other windowsfeatures     }      script formatdiskscript     {         setscript =         {             #powershell format disks         }         testscript = { return $false }         getscript = { }     } } 

inside arm template, have added dsc extension vm , specified url zip file, script run , function invoke.

"properties": {   "publisher": "microsoft.powershell",   "type": "dsc",   "typehandlerversion": "2.23",   "autoupgrademinorversion": true,   "settings": {     "configuration": {       "url": "[concat(parameters('_artifactslocation'), '/', variables('dscarchivefolder'), '/', variables('webvm_dsczipfilename'))]",       "script": "webvm-dsc.ps1",       "function": "main"     },     "configurationarguments": {       "nodename": "[variables('webvm_name')]"     }   },   "protectedsettings": {     "configurationurlsastoken": "[parameters('_artifactslocationsastoken')]"   } } 

question

it generates 2 .mof files , executes both node , script sections node section completes successfully.

when run script, works, script valid. problem when running both of them.

this see in output in c:\packages\plugins\microsoft.powershell.dsc\2.23.0.0\status\0.status

settings handler status 'transitioning'  updating execution status  dsc configuration completed no meta mof file exist restore ... settings handler status 'error'  

answer

after trying different approaches, stumbled across 1 worked. placed script inside node instead of being peer:

configuration main {     param ( [string] $nodename )      import-dscresource -modulename psdesiredstateconfiguration      node $nodename     {         windowsfeature webserver         {             name = "web-server"             ensure = "present"         }          #other windowsfeatures          script formatdiskscript         {              setscript =              {                  #powershell format disks              }              testscript = { return $false }              getscript = { }         }     } } 

you need create 2 configurations inside dsc configuration (say main , manual) , put thing want executed arm template main , other thing manual

or create 2 separate configurations in 2 separate files.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -