none
DCPROMO SCRIPT RRS feed

  • Question

  • i have this script 

    Function CountDown ($stext, $isec) {
        $x = [int]$isec
        $length = $x / 100
        while($x -gt 0) {
          $min = [int](([string]($x/60)).split('.')[0])
          $text = " " + $min + " minutes " + ($x % 60) + " seconds left"
          Write-Progress $stext -status $text -perc ($x/$length)
          start-sleep -s 1
          $x--
          }
        }
    
    Clear-Host
    Write-Host "`n`n`n`n`n`n`n"
    Do {
            Do {
                Write-Host "
                LAB - Acceleration Script
    
                SERVER 1
                -----------------------------------------
                1  =  SERVER1 - Rename and Set IP Addresses
                2  =  SERVER1 - Rename Only
                3  =  SERVER1 - Set IP Addresses Only
                4  =  SERVER1 - DCPROMO Only (Set IP and Rename First)
    
                0  =  Exit
    
                "
                [int]$choice1 = read-host -prompt "Select number & press enter"
                } until ( ($choice1 -ge 0) -and ($choice1 -le 10))
    
            Switch ($choice1) {
                    0 {
                    $ErrorCode = 0
                    }
                    1 {
                        Rename-Computer -NewName server1
                        New-NetIPAddress -InterfaceAlias "Ethernet0" -IPAddress "192.168.1.1" -PrefixLength 24 -AddressFamily IPv4
                        New-NetIPAddress -InterfaceAlias "Ethernet0" -IPAddress "FEC0::1" -PrefixLength 64 -AddressFamily IPv6
                        Set-DnsClientServerAddress -InterfaceAlias "Ethernet0" -ServerAddresses 192.168.1.1,FEC0::1
                        CountDown "Rebooting Computer" 7
                        Restart-Computer -Force
                        }
                    2 {
                        Rename-Computer -NewName server1
                        CountDown "Rebooting Computer" 7
                        Restart-Computer -Force
                        }
                    3 {
                        New-NetIPAddress -InterfaceAlias "Ethernet0" -IPAddress "192.168.1.1" -PrefixLength 24 -AddressFamily IPv4
                        New-NetIPAddress -InterfaceAlias "Ethernet0" -IPAddress "FEC0::1" -PrefixLength 64 -AddressFamily IPv6
                        Set-DnsClientServerAddress -InterfaceAlias "Ethernet0" -ServerAddresses 192.168.1.1,FEC0::1
                        }
                    4 {
                        if ( $env:computername.ToLower() -eq "server1") {
                                    Invoke-Command –ScriptBlock {
                                    Import-Module ServerManager
                                    Add-WindowsFeature -Name AD-Domain-Services -IncludeManagementTools
                                    Write-Host "      [!] Ignore Warnings (Yellow) Text Below      " -BackgroundColor Yellow -ForegroundColor Black
                                    Import-Module ADDSDeployment
                                    Install-ADDSForest `
                                    -CreateDnsDelegation:$false `
                                    -DatabasePath "C:\Windows\NTDS" `
                                    -DomainMode "Win2012" `
                                    -DomainName "server1.local" `
                                    -DomainNetbiosName "server1" `
                                    -ForestMode "Win2012" `
                                    -InstallDns:$true `
                                    -LogPath "C:\Windows\NTDS" `
                                    -NoRebootOnCompletion:$false `
                                    -SysvolPath "C:\Windows\SYSVOL" `
                                    -Force:$true `
                                    -SafeModeAdministratorPassword (ConvertTo-SecureString 'server1' -AsPlainText -Force)
                                    }
                                 } ELSE {
                                    Write-Host "`n          [!] Change Computer Name and Reboot Before DCPromo!          " -BackgroundColor Yellow -ForegroundColor Black
                                    $ErrorCode = 1
                                 }
                        }
                     
                    }
        } Until ($ErrorCode -eq 0)

    now every time i have to do DCPROMO i need to edit the script,

    can i make it be prompt the values ? (for option 1|2|3 and 4 will use the information from the changes or from the server himself?  

    for example option 2

    he will ask for the new name .

    thanks alot 

     


    • Edited by Michael Shvili Sunday, March 20, 2016 12:18 PM
    • Moved by Bill_Stewart Saturday, May 21, 2016 4:10 PM This is not "fix script I found on the Internet for me" forum
    Sunday, March 20, 2016 12:17 PM

All replies