I'm trying to create a Windows 10 VM in Azure from an ARM template and configure it with a DSC extension to change the letter of the temporary drive.
I found the module cMoveAzureTempDrive that allow to do it easily.
However when I deploy the template in Azure I receive an error saying that the module cannot be loaded because running scripts is disabled on the system :
{"code":"DeploymentFailed","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.","details":[{"code":"VMExtensionProvisioningError","message":"VM has reported a failure when processing extension 'Install'. Error message: "DSC Configuration 'Install' completed with error(s). Following are the first few: Importing module cMoveAzureTempDrive failed with error - File C:\Program Files\WindowsPowerShell\Modules\cMoveAzureTempDrive\cMoveAzureTempDrive.psm1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170."
More information on troubleshooting is available at https://aka.ms/VMExtensionDSCWindowsTroubleshoot "}]}
I understand that I could enable script execution from a custom script extension but it doesn't seem optimal to me that we can't use DSC module without doing that. I have the same problem with all external modules.
Do you have a solution to be able to use DSC modules?
Here is my DSC extension in the ARM template :
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"apiVersion": "2020-06-01",
"name": "[concat(parameters('vmName'),'/', 'Install')]",
"location": "[parameters('location')]",
"tags": "[parameters('resourceTags')]",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/',parameters('vmName'))]"
],
"properties": {
"publisher": "Microsoft.Powershell",
"type": "DSC",
"typeHandlerVersion": "2.9",
"autoUpgradeMinorVersion":true,
"settings": {
"wmfVersion": "latest",
"configuration": {
"url": "[variables('DSCLocationURI')]",
"script": "Install.ps1",
"function": "Install"
},
"configurationArguments": {
}
},
"protectedSettings": {
"configurationUrlSasToken": "[parameters('storageAccountSASToken')]"
}
}
}
And here is my DSC code :
{
Import-DscResource -ModuleName 'PSDesiredStateConfiguration'
Import-DscResource -ModuleName 'cAzureStorage'
Import-DscResource -ModuleName 'cMoveAzureTempDrive'
Node localhost
{
LocalConfigurationManager
{
ActionAfterReboot = 'ContinueConfiguration'
RebootNodeIfNeeded = $true
}
cMoveAzureTempDrive cMoveAzureTempDrive
{
TempDriveLetter = 'T'
Name = "MachineName"
}
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…