Open bdanse opened 8 years ago
@bdanse The way I understand is that the XML value for content needs to be base64 encoded. What was the error you got?
1e attempt :
"content": "<FirstLogonCommands><AsynchronousCommand wcm:action=\"add\"><CommandLine>dir</CommandLine><Description></Description><Order>1</Order></AsynchronousCommand></FirstLogonCommands>"
2e attempt with encoding
"content": "base64('<FirstLogonCommands><AsynchronousCommand wcm:action=\"add\"><CommandLine>dir</CommandLine><Description></Description><Order>1</Order></AsynchronousCommand></FirstLogonCommands>')"
Both result in the same error : 'The value of parameter windowsConfiguration.additionalUnattendContent.content is invalid.'
@bdanse base64 usage looks off. Expressions are enclosed with brackets ([ and ]).
Try "content": "[base64('<FirstLogonCommands><AsynchronousCommand wcm:action=\"add\"><CommandLine>dir</CommandLine><Description></Description><Order>1</Order></AsynchronousCommand>/FirstLogonCommands>')]"
If that doesn't work, then try base64 the value outside of the function and then paste that value in to the string.
Tried making a parameter for the xml and let visual studio encode the xml. Then used that string and the base64 encoded variant.
Tried encoding it outside arm. still same error.
Changed the AsynchronousCommand tag to SyschronousCommand.
"firstLogonXml": "<FirstLogonCommands><SynchronousCommand wcm:action=\"add\"><CommandLine>c:\\Windows\\notepad.exe</CommandLine><Order>1</Order></SynchronousCommand></FirstLogonCommands>"
Keeps giving the same error : 'The value of parameter windowsConfiguration.additionalUnattendContent.content is invalid.'
Is this a parsing error caused by the colon in wcm:action?
The below JSON passes validation and did actually execute the command, so it appears it is acceptable to remove the wcm:action attribute, and perhaps that is a work-around for now.
{
"passName": "oobesystem",
"componentName": "Microsoft-Windows-Shell-Setup",
"settingName": "FirstLogonCommands",
"content": "<FirstLogonCommands><SynchronousCommand><CommandLine>shutdown /r /t 0 /c \"initial reboot\"</CommandLine><Description>reboot</Description><Order>1</Order></SynchronousCommand></FirstLogonCommands>"
}
Someone should also update the documentation, because clearly it should not be base64 encoded.
@gregjhogan thank you that did the trick for now. @singhkay I have to agree with gregjhogan. additionalUnattendContent needs some work.
@bdanse @gregjhogan Thanks for the investigation. I'll get the windows agent team to look at this.
I would like to use multiple "additionalUnattendContent" paramters. One to set the AutoLogon and one to set the FirstLogonCommand. Could somebody please provide an example?
I think I figured out how to do the multiple components but I'm having trouble with the computer actually logging in. Here is code in case anybody else is trying. This goes into the virtual machine resource:
"osProfile": { "computerName": "[concat(variables('TierBEName'), copyindex(1))]", "adminUsername": "[parameters('adminUsername')]", "adminPassword": "[parameters('adminPassword')]", "windowsConfiguration": { "provisionVMAgent": true, "additionalUnattendContent": [ { "passName": "oobesystem", "componentName": "Microsoft-Windows-Shell-Setup", "settingName": "AutoLogon", "content": "<AutoLogon><Password><Value>[parameters('adminPassword')]</Value></Password><Domain>[concat(variables('TierBEName'), copyindex(1)))]</Domain><Enabled>true</Enabled><LogonCount>3</LogonCount><Username>[parameters('adminUsername')]</Username></AutoLogon>" }, { "passName": "oobesystem", "componentName": "Microsoft-Windows-Shell-Setup", "settingName": "FirstLogonCommands", "content": "<FirstLogonCommands><SynchronousCommand><CommandLine>shutdown /r /t 0 /c \"initial reboot\"</CommandLine><Description>reboot</Description><Order>1</Order></SynchronousCommand></FirstLogonCommands>" } ] } },
You have to concat() the "content" together when you want to use variables, for example:
{
"passName": "oobesystem",
"componentName": "Microsoft-Windows-Shell-Setup",
"settingName": "AutoLogon",
"content": "[concat('<AutoLogon><Domain>', variables('vmName'), '</Domain><Username>', parameters('adminUsername'), '</Username><Password><Value>', parameters('adminPassword'), '</Value></Password><LogonCount>3</LogonCount><Enabled>true</Enabled></AutoLogon>')]"
}
Hi, could someone provide a working example of a VM using additionalUnattendContent. For some reason I'm unable to get the FirstLogonCommands working. Always receive an error: 'The value of parameter windowsConfiguration.additionalUnattendContent.content is invalid.'
Also tried to base-64 encode the content string. Same error.
additionalUnattendContent