Power Cobra Power shell Mod!
This is a mod for powershell installed by running the installer it adds new commands to powershell and the way it works is the code is added to power shell and powershell recognizes it as actual commands and no script except the installer needs to be ran as after install it works in powershell right away you can see what the new commands are and how they work by typing the new command in powershell "Command-Help" just run the installer and you can integrate it into powershell and you can also uninstall it at any time.
Below is the open source code of the mod and its installer in case you want to rebuild the installer or mod for yourself this code can be used to make your own version of the mod just credit us for the original code :) also use a different name if you publish your version of the mod.
#Below is the code for this developer tags left are for people in the repository to know how the code works
$CustomCommands = @'
function Get-PrivateIP {
ipconfig | Select-String "IPv4 Address"
[console]::Beep(1000, 500)
}
function Get-PublicIP {
Invoke-RestMethod -Uri "https://api.ipify.org"
[console]::Beep(1000, 500)
}
function Debloat-System {
Write-Host "Starting Bloatware Removal..." -ForegroundColor Yellow
$Apps = @("*bing*", "*windowsmaps*", "*getstarted*", "*yourphone*", "*Copilot*")
foreach ($App in $Apps) {
Write-Host "Removing $App..."
Get-AppxPackage $App -AllUsers | Remove-AppxPackage -ErrorAction SilentlyContinue
}
[console]::Beep(1000, 500)
}
function File-Host {
$fileContent = Read-Host -Prompt "enter the text you want added to a text file"
$filePath = Read-Host -Prompt "enter the full path (e.g. C:\temp\test.txt)"
Set-Content -Path $filePath -Value $fileContent -ErrorAction Stop
Write-Host "your text is being written to a file"
[console]::Beep(1000, 500)
}
function Clear-Temp-And-DNS-Cache {
Clear-DnsClientCache
Remove-Item "$env:TEMP\*" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item "C:\Windows\Temp\*" -Recurse -Force -ErrorAction SilentlyContinue
Write-Host "your temp files have been deleted to save disk and your dns cache was flushed"
[console]::Beep(1000, 500)
}
function Command-Help {
[console]::Beep(1000, 500)
Write-Host "Get-PrivateIP (shows you your private ip)" -ForegroundColor Green
Write-Host "Get-PublicIP (shows you your public ip)" -ForegroundColor Cyan
Write-Host "Debloat-System (debloats system)" -ForegroundColor Yellow
Write-Host "File-Host (Writes a specified text to a text file)" -ForegroundColor DarkMagenta
Write-Host "Clear-Temp-And-DNS-Cache (clears your temp and dns cache)" -ForegroundColor Blue
Write-Host "Command-Help (shows commands)" -ForegroundColor DarkRed
Write-Host "Python-Get-Date-And-Time (needs python)"
Write-Host "Get-Python-As-A-Package (installs python)"
[console]::Beep(1000, 500)
}
function Python-Get-Date-And-Time {
[console]::Beep(1000, 500)
python -c "
import datetime
print(f'Fetching moon phase for {datetime.datetime.now()}...')
"
}
function Get-Python-As-A-Package {
[console]::Beep(1000, 500)
Get-AppxPackage Name- *python*
}
function Start-Powershell-With-Elevated-Privleges {
[console]::Beep(1000, 500)
Start-Process powershell -Verb RunAs
}
function Remove-Python-From-Your-Machine {
[console]::Beep(1000, 500)
Get-AppxPackage Name- *python* | Remove-AppxPackage
}
function Create-A-Json-File-Here {
process {
[console]::Beep(1000, 500)
# Read input from pipeline, pass to python, print formatted output
& python -c "import json, sys; data=json.loads(sys.stdin.read()); print(json.dumps(data, indent=4))"
}
}
function Powershell-Example {
[console]::Beep(1000, 500)
winget install --id Microsoft.VCRedist.2015+.x86 --silent --accept-source-agreements --accept-package-agreements
}
'@
# Fixed Profile Path for compatibility with PS2EXE
$ProfilePath = "$Home\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1"
#function for the installation
function Install-Commands {
# Added this to ensure the system allows the profile to run
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force
if (!(Test-Path $ProfilePath)) {
$null = New-Item -Path $ProfilePath -ItemType File -Force
}
$CurrentContent = Get-Content $ProfilePath -Raw
if ($CurrentContent -like "*# BEGIN CUSTOM COMMANDS*") {
Write-Host "Commands are already installed." -ForegroundColor Yellow
} else {
$Block = "`n# BEGIN CUSTOM COMMANDS`n$CustomCommands`n# END CUSTOM COMMANDS`n"
Add-Content -Path $ProfilePath -Value $Block
Write-Host "Successfully installed commands to $ProfilePath" -ForegroundColor Green
Write-Host "Restart PowerShell to use them." -ForegroundColor Cyan
}
}
# Function to Uninstall
function Uninstall-Commands {
if (Test-Path $ProfilePath) {
$Content = Get-Content $ProfilePath -Raw
$Pattern = "(?s)`n# BEGIN CUSTOM COMMANDS.*?# END CUSTOM COMMANDS`n"
$NewContent = $Content -replace $Pattern, ""
Set-Content -Path $ProfilePath -Value $NewContent
Write-Host "Successfully removed commands from profile." -ForegroundColor Green
} else {
Write-Host "Profile not found." -ForegroundColor Red
}
}
Write-Host "This is the installer for the Power Cobra Windows 11 Powershell Mod"
Write-Host "please choose a install option"
Write-Host "press 1 to install"
Write-Host "press 2 to uninstall"
$Choice = Read-Host "please select a option"
if ($Choice -eq "1") { Install-Commands }
elseif ($Choice -eq "2") { Uninstall-Commands }
else { Write-Host "Invalid Selection." }
#devtag
#devtag
#devtag
#devtag
#devtag
#devtag