Quantcast
Channel: Directory Services forum
Viewing all articles
Browse latest Browse all 31638

Promote a 2012 DC using PowerShell 3.0 workflow hangs on Install-ADDSForest

$
0
0

Hi,

seeing the value in PowerShell 3.0 workflow for machine / classroom installation I am trying to automate the entire installation of a SharePoint 2013 machine. First steps include making the server a domain controller.

To promote the domain controller  I make use of the ADDSDeployment module / Install-ADDSForest command. When used in a normal, non-workflow, PowerShell session the command works just fine. However, when running this command in a workflow that continues after a reboot the command seems to hang. I also found that debugging a workflow, well, is rather difficult :)

First, my sample script configures the computer name. Next it reboots. The workflow will be continueing with the installion of the AD-Domain-Services feature. Right after that I call Install-ADDSForest. You can find the full script below.

For getting the workflow to auto-continue after the reboot I have used two approaches. I have tried to use the RunOnce registry key to fire up PowerShell. This would be my preferred approach as you can see the PowerShell window running before the Explorer shell loads. The second approach involves the scheduled task trigger as described on Technet in the PowerShell workflow section. Either way, the promotion command is stuck. I have left it running overnight, after which the workflow still wasn't done.

Here's my awesomeness:

workflow Install-Wingtip{InlineScript{
        $Computer =Get-WmiObjectWin32_ComputerSystem
        $Computer.Rename("WingtipDC")|Out-Null}#Get ready for reboot#Either use the RunOnce key combined with auto-login#Set-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\RunOnce" `-Name "ConfigureServer" -Value "powershell -executionPolicy Unrestricted -Command Import-Module PSWorkflow; Get-Job | Resume-Job -Wait; Get-Job | Wait-Job"#Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name "DefaultUserName" -Value "Administrator"#Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name "DefaultPassword" -Value "pass@word1" #Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name "AutoAdminLogon" -Value "1" #Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name "AutoLogonCount" -Value "1" # Or use a -AtStartup trigger
    $Trigger =New-ScheduledTaskTrigger-AtStartupRegister-ScheduledJob-NameResumeWorkflow-Trigger $Trigger -ScriptBlock{Import-ModulePSWorkflow;Get-Job-StateSuspended|Resume-Job}Restart-Computer-WaitInlineScript{Import-ModuleServerManagerInstall-WindowsFeature AD-Domain-Services}InlineScript{Import-ModuleADDSDeploymentInstall-ADDSForest`
            -DomainName "Wingtip.com" `-DomainNetbiosName"Wingtip"`
            -SafeModeAdministratorPassword (ConvertTo-SecureString -String "pass@word1" -AsPlainText -Force) `-NoDnsOnNetwork`
            -InstallDns `-DomainModeWin2008R2`
            -ForestMode Win2008R2 `-NoRebootOnCompletion`
            -Confirm:$false
    }
    Write-Output -InputObject "Done creating domain controller"
}

Perhaps anyone has tried something similar? I cannot be the only one looking at promoting a DC through workflow I guess!

Thanks,

Wouter


Viewing all articles
Browse latest Browse all 31638

Trending Articles



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