locked
Powershell workflow install new domain controller issue... RRS feed

  • Question

  • HI, all, 

    I came a cross a small issue with putting variables into the install-addsforest command, it doesn't like it at all in my workflow... I see errors like:

    Install-ADDSForest : Verification of prerequisites for Domain Controller promotion failed. The specified argument 'DataBasePath' was not recognized.

    and

    Install-ADDSForest : Verification of prerequisites for Domain Controller promotion failed. The specified argument 'CreateDNSDelegation' was not recognized.

    The Idea of the script is to create a test domain controller and add a couple of users... 

    ~

    the script 

    ~

    Param(
      [string]$admusr,
      [string]$admpass,
      [string]$usrpass,
      [string]$domainsuffix,
      [string]$domainbio
     )

    Workflow New-ServerSetup {
      Param(
        [Parameter (Mandatory = $true)]
        [string]$adminp,
        [string]$userp,
        [string]$domainsuf,
        [string]$domain
       )

        InlineScript {
          Install-WindowsFeature AD-Domain-Services -IncludeManagementTools
          Import-Module ADDSDeployment

          Install-ADDSForest -CreateDnsDelegation:$false -DatabasePath "C:\\Windows\\NTDS" -DomainMode "7" -DomainName $Using:domainsuf -DomainNetbiosName $Using:domain -ForestMode "7" -InstallDns:$true -LogPath "C:\\Windows\\NTDS" -NoRebootOnCompletion -SysvolPath "C:\\Windows\\SYSVOL" -SafeModeAdministratorPassword ( ConvertTo-SecureString -AsPlainText -Force -String $Using:adminp ) -Force:$true
          }

        Restart-Computer -Wait -Force

        InlineScript {

          New-ADUser -Name "test usr" -GivenName test -Surname usr -SamAccountName test -UserPrincipalName test@$Using:domainsuf -AccountPassword ( ConvertTo-SecureString -AsPlainText -Force -String $Using:userp ) -PassThru | Enable-ADAccount

          New-ADUser -Name “vpn svc” -GivenName vpn -Surname svc -SamAccountName vpn -UserPrincipalName vpn@$Using:domainsuf -AccountPassword ( ConvertTo-SecureString -AsPlainText -Force -String $Using:userp ) -PassThru | Enable-ADAccount
         }

        Unregister-ScheduledJob -Name NewServerSetupResume

      }

    $pwd = ConvertTo-SecureString -AsPlainText -Force -String $admpass
    $cred = New-Object System.Management.Automation.PSCredential($admusr, $pwd)
    $AtStartup = New-JobTrigger -AtStartup
    Register-ScheduledJob -Name NewServerSetupResume `
                          -Credential $cred `
                          -Trigger $AtStartup `
                          -ScriptBlock {Import-Module PSWorkflow; `
                              Get-Job -Name NewSrvSetup -State Suspended `
                              | Resume-Job}

    New-ServerSetup -JobName NewSrvSetup -adminp $admpass -userp $usrpass -domainsuf $domainsuffix -domain $domainbio


    Can someone spot what I am doing wrong here as the two errors above are bogus as the help section says they are valid values... I put in "write host" lines and the values seem to be correct in the the script block... 

    I just can't seem to get it to work properly... 

    Thanks in advance... 

    L


    • Edited by X Eng Wednesday, December 20, 2017 11:02 AM better formatting of script
    Tuesday, December 19, 2017 12:43 PM

All replies

  • Your script is unreadable. Please post it correctly.

    \_(ツ)_/

    Tuesday, December 19, 2017 9:41 PM