-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstall-ArgusAD.ps1
More file actions
107 lines (91 loc) · 4.59 KB
/
Copy pathInstall-ArgusAD.ps1
File metadata and controls
107 lines (91 loc) · 4.59 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#
# Install-ArgusAD.ps1
# Installation script for Argus-AD
#
# Copyright (c) 2025 MottaSec
#
# Check if running as administrator
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if (-not $isAdmin) {
Write-Host "Please run this script as Administrator." -ForegroundColor Red
exit
}
Write-Host "===============================================================" -ForegroundColor Cyan
Write-Host " Argus-AD Installation" -ForegroundColor Cyan
Write-Host " by MottaSec" -ForegroundColor Cyan
Write-Host "===============================================================" -ForegroundColor Cyan
Write-Host ""
# Check PowerShell version
$psVersion = $PSVersionTable.PSVersion
Write-Host "[*] Checking PowerShell version..." -ForegroundColor Cyan
if ($psVersion.Major -lt 5 -or ($psVersion.Major -eq 5 -and $psVersion.Minor -lt 1)) {
Write-Host "[!] PowerShell 5.1 or later is required. Current version: $($psVersion.ToString())" -ForegroundColor Red
exit
}
Write-Host "[+] PowerShell version $($psVersion.ToString()) is supported." -ForegroundColor Green
# Check for ActiveDirectory module
Write-Host "[*] Checking for ActiveDirectory module..." -ForegroundColor Cyan
if (-not (Get-Module -ListAvailable -Name ActiveDirectory)) {
Write-Host "[!] ActiveDirectory module not found. Installing..." -ForegroundColor Yellow
try {
# Check if RSAT is installed
$rsatStatus = Get-WindowsCapability -Name Rsat.ActiveDirectory* -Online
if ($rsatStatus.State -ne "Installed") {
Write-Host "[*] Installing Remote Server Administration Tools (RSAT) for Active Directory..." -ForegroundColor Cyan
Add-WindowsCapability -Name Rsat.ActiveDirectory.DS-LDS.Tools~~~~0.0.1.0 -Online
if ($LASTEXITCODE -ne 0) {
throw "Failed to install RSAT tools"
}
Write-Host "[+] RSAT tools installed successfully." -ForegroundColor Green
}
else {
Write-Host "[+] RSAT tools are already installed." -ForegroundColor Green
}
}
catch {
Write-Host "[!] Failed to install ActiveDirectory module. Please install RSAT tools manually." -ForegroundColor Red
Write-Host " More information: https://docs.microsoft.com/en-us/troubleshoot/windows-server/system-management-components/remote-server-administration-tools" -ForegroundColor Yellow
exit
}
}
else {
Write-Host "[+] ActiveDirectory module is available." -ForegroundColor Green
}
# Create module directory if it doesn't exist
$modulePath = "$env:ProgramFiles\WindowsPowerShell\Modules\MottaSec-ArgusAD"
if (-not (Test-Path -Path $modulePath)) {
Write-Host "[*] Creating module directory..." -ForegroundColor Cyan
New-Item -ItemType Directory -Path $modulePath -Force | Out-Null
Write-Host "[+] Module directory created at $modulePath" -ForegroundColor Green
}
else {
Write-Host "[*] Module directory already exists. Updating..." -ForegroundColor Cyan
}
# Copy files to module directory
Write-Host "[*] Copying files to module directory..." -ForegroundColor Cyan
Copy-Item -Path ".\src\*" -Destination $modulePath -Recurse -Force
Write-Host "[+] Files copied successfully." -ForegroundColor Green
# Create reports directory if it doesn't exist
$reportsPath = "$modulePath\reports"
if (-not (Test-Path -Path $reportsPath)) {
Write-Host "[*] Creating reports directory..." -ForegroundColor Cyan
New-Item -ItemType Directory -Path $reportsPath -Force | Out-Null
Write-Host "[+] Reports directory created." -ForegroundColor Green
}
# Import the module to verify installation
Write-Host "[*] Verifying installation..." -ForegroundColor Cyan
Import-Module -Name MottaSec-ArgusAD -Force
if (Get-Command -Name Invoke-ArgusAD -ErrorAction SilentlyContinue) {
Write-Host "[+] Argus-AD installed successfully!" -ForegroundColor Green
Write-Host ""
Write-Host "You can now run Argus-AD using the command: Invoke-ArgusAD" -ForegroundColor White
Write-Host ""
Write-Host "For more information, visit: https://github.com/MottaSec/Argus-AD" -ForegroundColor White
}
else {
Write-Host "[!] Installation verification failed. Please check for errors." -ForegroundColor Red
}
Write-Host ""
Write-Host "===============================================================" -ForegroundColor Cyan
Write-Host " Installation Complete - Thank You!" -ForegroundColor Cyan
Write-Host "===============================================================" -ForegroundColor Cyan