Skip to content

Commit 73fe4ff

Browse files
committed
Restore latest generic/kickoff.ps1 after history scrub
1 parent 3c16806 commit 73fe4ff

File tree

1 file changed

+146
-0
lines changed

1 file changed

+146
-0
lines changed

generic/kickoff.ps1

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
Set-Location "C:\Users\cyberadmin\Desktop"
2+
3+
# Determine PSVersion once
4+
$pv = $PSVersionTable.PSVersion
5+
Write-Host "⚡Showing PowerShell version..." -ForegroundColor Green
6+
$PSVersionTable | Format-Table -AutoSize
7+
8+
Function Start-MyCommands {
9+
10+
Write-Host "⚡Executing startup tasks..." -ForegroundColor Green
11+
#Ensure PSGallery exists and is trusted
12+
if (-not(Get-PSRepository -Name PSGallery -ErrorAction Continue)) {
13+
Register-PSRepository -Name PSGallery -SourceLocation 'https://www.powershellgallery.com/api/v2' -InstallationPolicy Trusted
14+
} else {
15+
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
16+
}
17+
#Safer execution policy for user scope
18+
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned -Force
19+
20+
Write-Host "⚡Installing ...RSAT-AD-PowerShell" -ForegroundColor Green
21+
Install-WindowsFeature -Name RSAT-AD-PowerShell
22+
23+
Write-Host "⚡Installing ...NuGet provider" -ForegroundColor Green
24+
Install-PackageProvider -Name NuGet -Force -Scope AllUsers
25+
26+
Write-Host "⚡Installing ...PowerShellGet" -ForegroundColor Green
27+
Install-Module -Name PowerShellGet -Force -Scope AllUsers
28+
29+
Write-Host "⚡Installing ...PackageManagement" -ForegroundColor Green
30+
Install-Module -Name PackageManagement -Force -Scope AllUsers -AllowClobber
31+
32+
Write-Host "⚡Installing ...AADInternals" -ForegroundColor Green
33+
Install-Module -Name AADInternals -Scope AllUsers -Force -AllowClobber
34+
35+
Write-Host "⚡Installing ...AADInternals-Endpoints" -ForegroundColor Green
36+
Install-Module -Name 'AADInternals-Endpoints' -Scope AllUsers -Force -AllowClobber
37+
38+
Write-Host "⚡Importing ...AADInternals" -ForegroundColor Green
39+
Import-Module AADInternals
40+
41+
Write-Host "⚡Importing ...AADInternals-Endpoints" -ForegroundColor Green
42+
Import-Module 'AADInternals-Endpoints'
43+
44+
Write-Host "⚡Add-WindowsCapability ...Rsat.ActiveDirectory" -ForegroundColor Green
45+
Add-WindowsCapability -Online -Name Rsat.ActiveDirectory.DS-LDS.Tools~~~~0.0.1.0
46+
47+
Write-Host "⚡Add-WindowsCapability ...Rsat.AD" -ForegroundColor Green
48+
Add-WindowsCapability -Online -Name Rsat.AD.PowerShell~~~~0.0.1.0
49+
50+
Write-Host "⚡Importing ...ActiveDirectory" -ForegroundColor Green
51+
Import-Module ActiveDirectory
52+
53+
Write-Host "⚡Listing Active Directory Module part of RSAT..." -ForegroundColor Green
54+
Get-Module ActiveDirectory -ListAvailable
55+
56+
Write-Host "⚡Showing RSAT version..." -ForegroundColor Green
57+
Get-WindowsCapability -Name 'RSAT.ActiveDirectory*' -Online
58+
59+
Write-Host "⚡Installing ...Az" -ForegroundColor Green
60+
Install-Module -Name Az -Scope AllUsers -AllowClobber -Force
61+
62+
Write-Host "⚡Showing Azure PowerShell version..." -ForegroundColor Green
63+
Get-InstalledModule -Name Az | Format-Table -AutoSize
64+
Start-Sleep -Seconds 2
65+
66+
Write-Host "⚡Installing ...DSInternals" -ForegroundColor Green
67+
Install-Module -Name DSInternals -Scope AllUsers -AllowClobber -Force
68+
69+
Write-Host "⚡Importing ...DSInternals" -ForegroundColor Green
70+
Import-Module -Name DSInternals -ErrorAction Continue
71+
72+
if ($pv.Major -ge 7) {
73+
# PowerShell 7 or later
74+
Write-Host "⚡Running PowerShell $($pv.ToString()) — using PowerShell 7+ path not loading PowerSploit" -ForegroundColor Green
75+
}elseif ($pv.Major -eq 5 -and $pv.Minor -eq 1) {
76+
# Exactly Windows PowerShell 5.1
77+
Write-Host "⚡Running Windows PowerShell $($pv.ToString()) — using 5.1 path - loading PSReflect and PowerSploit" -ForegroundColor Green
78+
79+
#Import PSReflect by absolute path relative to script location
80+
$scriptRoot = if ($PSScriptRoot) {
81+
$PSScriptRoot
82+
} else {
83+
$PWD.Path
84+
}
85+
$psReflectPath = Join-Path -Path $scriptRoot -ChildPath 'PSReflect\PSReflect.psm1'
86+
if (Test-Path $psReflectPath) {
87+
Import-Module -Name $psReflectPath -ErrorAction Continue
88+
Write-Host "⚡PSReflect loaded from $psReflectPath" -ForegroundColor Green
89+
} else {
90+
Write-Host ("⚡PSReflect module not found at: {0}" -f $psReflectPath) -ForegroundColor Yellow
91+
}
92+
93+
#Import PowerView script by full path(dot - source.ps1 or Import-Module only for psm1 / dll)
94+
$powerViewPath = Join-Path -Path $scriptRoot -ChildPath 'PowerSploit\Recon\PowerView.ps1'
95+
if (Test-Path $powerViewPath) {
96+
.$powerViewPath #dot - source a script to import functions into session
97+
Write-Host "⚡PowerView dot-sourced from $powerViewPath" -ForegroundColor Green
98+
} else {
99+
Write-Host ("⚡PowerView module not found at: {0}" -f $powerViewPath) -ForegroundColor Yellow
100+
}
101+
}else{
102+
# Any other PowerShell version
103+
# Write-Host "⚡Running PowerShell $($pv.ToString()) — using fallback path - not loading PowerSploit" -ForegroundColor Yellow
104+
# place fallback code here
105+
}
106+
107+
Write-Host "⚡Installing PSPreworkout" -ForegroundColor Green
108+
Install-Module -Name PSPreworkout -Scope CurrentUser -Force -AllowClobber
109+
110+
Write-Host "⚡Checking for updates" -ForegroundColor Green
111+
Get-ModulesWithUpdate -PassThru
112+
113+
$response = Read-Host "Apply module updates? (Y/N)"
114+
if ($response.ToUpper() -eq 'Y') {
115+
Write-Host "⚡Applying updates" -ForegroundColor Green
116+
Get-InstalledModule | ForEach-Object {
117+
$name = $_.Name
118+
try {
119+
Update-Module -Name $name -Force -ErrorAction Continue
120+
Write-Host "⚡Updated $name" -ForegroundColor Green
121+
} catch {
122+
Write-Host ("⚡Failed {0}: {1}" -f $name, $_.Exception.Message) -ForegroundColor Yellow
123+
}
124+
}
125+
}
126+
127+
if (Get-Command az -ErrorAction SilentlyContinue) {
128+
Write-Host "⚡Installing Azure Automation CLI extension" -ForegroundColor Green
129+
az extension add -n automation
130+
Write-Host "⚡Enables automatic, silent installation of missing CLI extensions when you run a command for the first time" -ForegroundColor Green
131+
az config set extension.use_dynamic_install=yes_without_prompt
132+
} else {
133+
Write-Host "Azure CLI (az) not found; skipping az extension commands" -ForegroundColor Yellow
134+
}
135+
136+
Write-Host "⚡PowerView Runs much better in an older PS - RUN the following..." -ForegroundColor Green
137+
Write-Host "⚡powershell.exe -Version 5.1" -ForegroundColor Green
138+
Write-Host "⚡.\kickoff.ps1" -ForegroundColor Green
139+
Write-Host "⚡ PowerSploit\Recon> . .\PowerView.ps1" -ForegroundColor Green
140+
141+
Get-AzContext
142+
143+
}
144+
Start-MyCommands
145+
146+
Get-Module -Name AADInternals, AADInternals-Endpoints, DSInternals, ActiveDirectory, PSPreworkout, PSReflect, PowerView -ErrorAction SilentlyContinue

0 commit comments

Comments
 (0)