Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ###Script made by Michel Belanger###
- ##set the ip appdress on net adapter##
- ##Get name adapter and index##
- Get-NetAdapter
- Write-Host ""
- Write-Host ""
- Write-Host ""
- $interfaceIndex = Read-Host "Enter the interfaceindex of the network adapter needed"
- ##enter the prefix length##
- $prefixlength = Read-Host "Enter the prefix length"
- ##command to enter and verify the ipv4 address##
- $serverip = Read-Host "Enter a valid IPV4 for the network adapter card"
- $iparr = $serverip.Split(".")
- If($iparr.Length -ne 4)
- {Write-Host "Enter a valid format xxx.xxx.xxx.xxx" -ForegroundColor Red}
- foreach ($bytes in $iparr)
- {
- if([int]$bytes -lt 0 -or [int]$bytes -gt 255)
- {Write-Host "Value must be between 0 and 255" -ForegroundColor red}
- }
- ##Set the default Gateway##
- $GatewayIP = Read-Host "Enter a valid IPV4 for the default gateway"
- $Gatewayiparr = $GatewayIP.Split(".")
- If($Gatewayiparr.Length -ne 4)
- {Write-Host "Enter a valid format xxx.xxx.xxx.xxx" -ForegroundColor Red}
- foreach ($bytes in $Gatewayiparr)
- {
- if([int]$bytes -lt 0 -or [int]$bytes -gt 255)
- {Write-Host "Value must be between 0 and 255" -ForegroundColor red}
- }
- ##set dns server Adress##
- New-NetIPAddress -InterfaceIndex $interfaceIndex -IPAddress $serverip -PrefixLength $prefixlength -DefaultGateway $GatewayIP
- Set-dnsclientserveraddress -interfaceindex $interfaceIndex -serveraddresses $serverip
- ##Install ADDs Domain Services
- install-windowsfeature -name ad-domain-services
- ##Set a secure string Password##
- $password = Read-Host "Enter your secure password"
- $SecurePassword = convertto-securestring -asplaintext -string $password -Force
- ##Install the new Forest##
- ##Enter the Domain name##
- $DomainName = Read-Host "Enter the domain name"
- ##Remove the .com for the net Bios Name##
- $NetBiosName = $DomainName
- $BiosName = $NetBiosName.Split(".")
- ## Enter the Domain Mode##
- ##$DomainMode = Read-Host "Enter the domain mode"
- #Enter the Forest name##
- ##$ForestMode = Read-Host "Enter the Forest mode"
- ##Enter the DataBase Path##
- $DataBasePath = Read-Host "Enter the database Path"
- ##Enter the Log Path##
- $LogPath = Read-Host "Enter the Log Path"
- ##Enter the SysVol Path##
- $SysVolPath = Read-Host "Enter the SysVol Path"
- install-addsforest -domainname $DomainName -safemodeadministratorpassword $SecurePassword -domainnetbiosname $BiosName[0] -domainmode win2012r2 -forestmode win2012r2 -databasepath $DataBasePath -logpath $LogPath -sysvolpath $SysVolPath -norebootoncompletion -installdns
- ##Command to restart computer##
- Restart-Computer -Confirm
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement