Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Issues when attempting to create a new 2012 R2 forest through powershell

$
0
0

Hello,

I've been writing  a script to automate the installation of some new servers, however I'm experiencing an issue when I'm coming to create the forest, for some reason the $DomainName and $ADSecPwd variables are not being passed to the Install-ADDSForest function.    The $DomainName and $ADSecPwd variables are defined at the top of the script.

When viewing the variables right before execution I can see that they store the right values, however when executing the code PowerShell throws an exception saying that the DomainName parameter cannot be null.  The same is true for the the SafeModePassword.

If I hard code the domainname and password then it works, but I don't want to do this, as I'm going to use this script n multiple domains.

Another issue I have is that the paths are not being created on the specified 'F:\...' drive, instead they are being created in the default location on the C: drive. 

Below is a copy of the function I'm using.  Anyone have any ideas why this isn't working as expected?

function Install_ADForest ($uri, $localcredentials, $DomainName, $ADSecPwd) {
    Invoke-Command -ConnectionUri $uri -Credential $localCredentials -ScriptBlock {  
                Install-ADDSForest `
                    -DomainMode Win2012R2 `
                    -ForestMode Win2012R2 `
                    -DatabasePath "F:\Windows\NTDS" `
                    -SysvolPath "F:\Windows\SYSVOL" `
                    -LogPath "F:\Windows\Logs" `
                    -NoRebootOnCompletion:$true `
                    -DomainName $DomainName `
                    -SafeModeAdministratorPassword $ADSecPwd
}

Marcus


Viewing all articles
Browse latest Browse all 21975

Trending Articles