forked from ericcase/IFT220_Lab2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdomain.ps1
More file actions
38 lines (32 loc) · 2.01 KB
/
Copy pathdomain.ps1
File metadata and controls
38 lines (32 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Build a new DC in a new Forest
# Assumption: new machine uses DHCP
#This is a test, we are testing again--please stand by for future order.
# Change from DHCP to static IP using the same IP
# Get the name of the network adapter
$nicname = Get-NetAdapter | select -ExpandProperty "name"
# Get current IP Address, Prefix Length (subnet mask), and gateway
$ipaddress = Get-NetIPAddress -InterfaceAlias $nicname -AddressFamily IPv4 | select -ExpandProperty "IPAddress"
$prefixlength = Get-NetIPAddress -InterfaceAlias $nicname -AddressFamily IPv4 | select -ExpandProperty "PrefixLength"
$gateway = Get-NetIPConfiguration -InterfaceAlias $nicname | select -ExpandProperty "IPv4DefaultGateway" | select -ExpandProperty "NextHop"
# Set the current IP address as static
Remove-NetIPAddress -InterfaceAlias $nicname -AddressFamily IPv4 -Confirm:$false
Remove-NetRoute -InterfaceAlias $nicname -AddressFamily IPv4 -Confirm:$false
New-NetIPAddress -InterfaceAlias $nicname -IPAddress $ipaddress -AddressFamily IPv4 -PrefixLength $prefixlength -DefaultGateway $gateway
# Set the DNS address to ourselves
Set-DnsClientServerAddress -InterfaceAlias $nicname -ServerAddresses $ipaddress
# Make sure the timezone is set correctly
Get-TimeZone | select -ExpandProperty "DisplayName"
Write-Host -ForegroundColor yellow "Is that the correct timezone?"
$Readhost = Read-Host -Prompt ("y | n ")
Switch ($ReadHost)
{
Y {Write-Host "Okay, moving on."}
N {Write-Host -ForegroundColor yellow "Use the GUI to set the timezone. Press Enter when the timezone is set."; Read-Host}
Default {Write-Host -ForegroundColor yellow "Use the GUI to set the timezone. Press Enter when the timezone is set."; Read-Host}
}
# Install the AD Services
Write-Host -ForegroundColor yellow "What's the domain name going to be? It should be ad.<your ASU email prefix>.lan"
$domainname = Read-Host -Prompt (" ")
Install-WindowsFeature AD-Domain-Services -IncludeManagementTools | Out-Null
Install-ADDSForest -DomainName $domainname
# the machine will now reboot