Quantcast
Channel: Azure Virtual Machines forum
Viewing all articles
Browse latest Browse all 12545

Custom Script Extension Not Fully Running in a VM JSON Template

$
0
0

Hi,

I have a JSON template that deploys a Windows Server 2016 VM, with a Custom Script Extension that runs a PowerShell script.
The script is meant to install ADDS/DNS/GPMC and promote the server to a DC.

This is the PowerShell script:

Add-WindowsFeature AD-Domain-Services, DNS, GPMC -IncludeAllSubFeature -IncludeManagementTools
Import-Module ADDSDeployment
Install-ADDSForest -CreateDnsDelegation:$false -DatabasePath C:\Windows\NTDS -DomainMode 7 -DomainName DomainName.local -DomainNetbiosName DomainName -ForestMode 7 -InstallDns:$true -LogPath C:\Windows\NTDS -NoRebootOnCompletion:$false -SysvolPath C:\Windows\SYSVOL -Force:$true

I'm running the script via a Custom Script Extension with the following CommandToExecute command:

"fileUris": ["ScriptURL.ps1"
              ],"commandToExecute": "[concat('powershell -verbose -ExecutionPolicy Unrestricted -File Script.ps1', ' -SafeModeAdministratorPassword ', parameters('adminPassword'))]"

To automate the DC promotion with no prompts, I'm trying to pass the adminPassword parameter from the JSON template to the-SafeModeAdministratorPassword switch in the Install-ADDSForest command.

The VM is deployed and the first command in the script is running (installing ADDS, DNS, GPMC) but the second part where it promotes the DC doesn't work. 

In Azure portal, the template deployment gets stuck on the Custom Script Extension part for a long time (more than an hour) and at the end times out. Myabe it's the adminPassword-SafeModeAdministratorPasswordpart that causes issues, but I'm not sure. 

Is something wrong with my script? Is there a way to debug why it is hungs on the DC promotion?
Any suggestion on how to achive this in another way?

Thanks!


Viewing all articles
Browse latest Browse all 12545

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>