Hi
I want to automate a VM to join ADDS domain using Bicep and PowerShell.
The Bicep I created uses custom script Extension to execute all the PowerShell commands to make the VM to join the domain but it fails to execute the last PS command which is Add-Computer. When it reaches this line, it just hangs indefinately. I have to terminate the run of the Bicep to get out of the indefinate hang.
The powershell code is as follows:
$domain = "myDomain" $password = "myPassword!" | ConvertTo-SecureString -asPlainText -Force $username = "$domain\myUserAccount"
$credential = New-Object System.Management.Automation.PSCredential($username,$password)
Set-DnsClientServerAddress -InterfaceIndex $ethIdx -ServerAddresses $serverIP
Add-Computer -DomainName $domain -Credential $credential -restart
Note that if I run PowerShell on its own in a powershell script file, then it works. It hangs only if the same script commands is added to bicep and run it as inline script.
Bicep template is standard template that build basic Windows 10 VM and minimum code.
Any help is appreciated.