-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMicrosoft.PowerShell_profile.ps1
More file actions
84 lines (72 loc) · 2.98 KB
/
Copy pathMicrosoft.PowerShell_profile.ps1
File metadata and controls
84 lines (72 loc) · 2.98 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
###############################################################################
# PowerShell Profile - Security Operations & Automation Framework
###############################################################################
# --- Global Environment Variables ---
# Dynamically resolves the user path to avoid hardcoding names
$HOME_DIR = "C:\Users\$env:USERNAME"
$BACKUP_DRIVE = "D:\"
####################
# Navigation Aliases
####################
function source-profile { . $PROFILE; Write-Host "Profile Reloaded." -ForegroundColor Green }
Set-Alias -Name reload -Value source-profile
function home { Set-Location -Path $HOME_DIR }
# Logic: Uses wildcards to find labs even if folder names shift slightly
function lab { Set-Location (Get-Item "$HOME_DIR\Documents\automate*") }
function lab2 { Set-Location (Get-Item "$HOME_DIR\Documents\learn*powershell*lunches*") }
####################
# Security Gated Execution
####################
# Core function to ensure VPN is active before any web-facing traffic
function Start-SecureProcess {
param(
[Parameter(Mandatory)] [string]$ProcessName,
[string]$Arguments = ""
)
$vpn = Get-Process -Name "ProtonVPN.Client" -ErrorAction SilentlyContinue
if ($vpn) {
Write-Host "[SECURE] VPN active. Launching $ProcessName..." -ForegroundColor Yellow
if ($Arguments) {
Start-Process $ProcessName -ArgumentList $Arguments
}
else {
Start-Process $ProcessName
}
}
else {
Write-Warning "[BLOCK] Execution Aborted: ProtonVPN is NOT running. Connect VPN first."
}
}
# Secure Browser Shortcuts
function edge { Start-SecureProcess "msedge.exe" }
function fox { Start-SecureProcess "firefox.exe" }
####################
# Connectivity
####################
# Quick public IP check to verify VPN tunnel location
function myip { (Invoke-RestMethod -Uri "https://icanhazip.com").Trim() }
function ext { myip }
####################
# Process Management (The "Kill-Switch")
####################
# One function to rule them all instead of 10 individual 'kill' functions
function stop-apps {
param(
[string[]]$AppNames = @('msedge', 'chrome', 'brave', 'firefox', 'opera', 'vivaldi', 'code', 'SnagitCapture', 'SnagitEditor', 'Voicemod')
)
foreach ($app in $AppNames) {
if (Get-Process -Name $app -ErrorAction SilentlyContinue) {
Write-Host "Stopping $app..." -ForegroundColor Cyan
Stop-Process -Name $app -Force -ErrorAction SilentlyContinue
}
}
}
# kill swtich shortcuts
function snag1kill { stop-apps SnagitCapture }
function snag2kill { stop-apps SnagitEditor }
###############################################################################
# Local/Private Extensions
# Load sensitive functions from a non-GitHub tracked file if it exists
###############################################################################
$privateProps = "$HOME_DIR\.config\powershell\PrivateProfile.ps1"
if (Test-Path $privateProps) { . $privateProps }