-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSetupServer.ps1
More file actions
73 lines (56 loc) · 2.07 KB
/
SetupServer.ps1
File metadata and controls
73 lines (56 loc) · 2.07 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# SetupServer.ps1
# Author: Ali Muhammad
# Version: 0.3
# Purpose: Automate full Windows Server setup for different organization types.
If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Host "Please run this script as Administrator!" -ForegroundColor Red
Exit
}
try {
$IsDC = Get-ADDomainController -ErrorAction Stop
}
catch {
$IsDC = $null
}
$LogFile = "C:\ServerSetup\SetupLog.txt"
New-Item -Path "C:\ServerSetup" -ItemType Directory -Force | Out-Null
Start-Transcript -Path $LogFile -Force
Write-Host "`n==========================" -ForegroundColor Cyan
Write-Host " Windows Server Setup Tool " -ForegroundColor Green
Write-Host "==========================`n" -ForegroundColor Cyan
if (-not $IsDC) {
# Not a Domain Controller yet → Install AD
if (Test-Path ".\Install-ActiveDirectory.ps1") {
Write-Host "Starting Active Directory Installation..." -ForegroundColor Cyan
. .\Install-ActiveDirectory.ps1
Write-Host "Server will reboot after domain controller promotion." -ForegroundColor Yellow
Restart-Computer -Force
Exit
}
else {
Write-Host "Error: Install-ActiveDirectory.ps1 not found!" -ForegroundColor Red
Exit
}
}
else {
Write-Host "Select the organization type:" -ForegroundColor Yellow
Write-Host "1. School"
Write-Host "2. Small Business"
Write-Host "3. Enterprise"
Write-Host "4. Custom"
$orgChoice = Read-Host "Enter your choice (1-4)"
switch ($orgChoice) {
"1" {
Write-Host "Setting up for: School" -ForegroundColor Green
if (Test-Path ".\School\School-structure.ps1") {
Write-Host "`nCreating School Active Directory Structure..." -ForegroundColor Cyan
. .\School\School-structure.ps1
Write-Host "`nSetup completed successfully!" -ForegroundColor Green
}
else {
Write-Host "Error: School-structure.ps1 not found!" -ForegroundColor Red
Exit
}
}
}
}