Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/danamw/powershell-tuneup
PowerShell scripts and snips for the learning curve.
https://github.com/danamw/powershell-tuneup
ansi console-menu hints menu modules powershell powershell-core powershell-modules powershell-scripts ps1 read-host-pause scripts
Last synced: 26 days ago
JSON representation
PowerShell scripts and snips for the learning curve.
- Host: GitHub
- URL: https://github.com/danamw/powershell-tuneup
- Owner: DanaMW
- License: mit
- Created: 2018-07-26T07:16:26.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-09-09T08:32:49.000Z (about 2 months ago)
- Last Synced: 2024-09-28T04:22:17.566Z (about 1 month ago)
- Topics: ansi, console-menu, hints, menu, modules, powershell, powershell-core, powershell-modules, powershell-scripts, ps1, read-host-pause, scripts
- Language: PowerShell
- Homepage: https://danamw.github.io
- Size: 66.7 MB
- Stars: 21
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Repository Information
For help and/or information on my PowerShell setup head to the Development tab on my site: . You will also always find me (*recess*) on IRC at `irc.dal.net` or `irc.libera.chat` in room #StrangeScript. My discord server is
Another note: Windows positioning does not work on the new tabbed Windows Terminal yet. But I am working on including it in all the scripts. (or disabling if detected) Not to long. Also proudest of my script Put-Pause.ps1 (below). This is something Powershell should have built in.---
## PowerShell-TuneUp - Or as I like to say - I Love PowerShell
## My Profile Functions
```
Import-Module posh-git;
Import-Module oh-my-posh;
Import-Module Get-ChildItemColor;
Import-Module -Name PSReadline;
Import-Module PsGet;
Add-WindowsPSModulePath;
function Test-Administrator {
$user = [Security.Principal.WindowsIdentity]::GetCurrent()
(New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
}
function Resolve-Error ($ErrorRecord = $Error[0]) {
$ErrorRecord | Format-List * -Force
$ErrorRecord.InvocationInfo | Format-List *
$Exception = $ErrorRecord.Exception
for ($i = 0; $Exception; $i++, ($Exception = $Exception.InnerException)) {
$Exception | Format-List * -Force
"$i" * 80
}
}
function Write-Color($message = "") {
[string]$pipedMessage = @($Input)
if (!$message) {
if ( $pipedMessage ) {
$message = $pipedMessage
}
}
if ( $message ) {
$colors = @("black", "blue", "cyan", "darkblue", "darkcyan", "darkgray", "darkgreen", "darkmagenta", "darkred", "darkyellow", "gray", "green", "magenta", "red", "white", "yellow");
$defaultFGColor = $host.UI.RawUI.ForegroundColor
$CurrentColor = $defaultFGColor
$message = $message.split("~")
foreach ( $string in $message ) {
if ( $colors -contains $string.Tolower() -and $CurrentColor -eq $defaultFGColor ) { $CurrentColor = $string }
else {
write-host -NoNewLine -f $CurrentColor $string
$CurrentColor = $defaultFGColor
}
}
write-host
}
}
function Write-ColorPrompt($message = "") {
[string]$pipedMessage = @($Input)
if (!$message) {
if ( $pipedMessage ) {
$message = $pipedMessage
}
}
if ( $message ) {
$colors = @("black", "blue", "cyan", "darkblue", "darkcyan", "darkgray", "darkgreen", "darkmagenta", "darkred", "darkyellow", "gray", "green", "magenta", "red", "white", "yellow");
$defaultFGColor = $host.UI.RawUI.ForegroundColor
$CurrentColor = $defaultFGColor
$message = $message.split("~")
foreach ( $string in $message ) {
if ( $colors -contains $string.Tolower() -and $CurrentColor -eq $defaultFGColor ) { $CurrentColor = $string }
else {
write-host -NoNewLine -f $CurrentColor $string
$CurrentColor = $defaultFGColor
}
}
write-host -NoNewline
}
}
Function Get-SmallVer {
$MyVer = $PSVersiontable | Select-Object -property PSVERSION | Format-Table -HideTableheader | Out-String -NoNewLine
return WC "~darkcyan~[~~darkyellow~PowerShell $PSEdition $MyVer~~darkcyan~]~~white~ ~"
}
Set-Alias ghost Run-Ghost.ps1;
Set-Alias count countThis.ps1;
Set-Alias say Write-Host;
Set-Alias sayout Write-Output;
Set-Alias re Resolve-Error;
Set-Alias ge Get-Error;
Set-Alias l Get-ChildItemColor -option AllScope;
Set-Alias ls Get-ChildItemColorFormatWide -option AllScope;
Set-Alias la Get-Files.ps1;
Set-Alias cc D:\bin\ccleaner\ccleaner64.exe;
Set-Alias whois "D:\bin\wscc\SysInternals Suite\WhoIs64.exe";
Set-Alias wc Write-Color;
Set-Alias wcp Write-ColorPrompt;
Set-Alias ClearRecycle Clear-RecycleBin;
Set-Alias ssh-agent "D:\bin\git\usr\bin\ssh-agent.exe";
Set-Alias ssh-add "D:\bin\git\usr\bin\ssh-add.exe";
Set-Alias wget Invoke-WebRequest;
Set-Alias mods Get-InstalledModule;
Set-Variable -Name BASE -Value D:\bin -Scope Global;
Set-Variable -Name ShellSpec -Value 'C:\Program Files\PowerShell\7\pwsh.exe' -Scope Global;
$agent_is_running = Get-Process | Where-Object { $_.ProcessName -like "ssh-agent*" };
if (!($agent_is_running)) { Start-SshAgent -Quiet; };
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete;
$host.privatedata.ProgressForegroundColor = "white";
$host.privatedata.ProgressBackgroundColor = "red";
# $host.UI.RawUI.BackgroundColor = “Black”;
$Host.UI.RawUI.ForegroundColor = “Gray”;
$Global:GetChildItemColorVerticalSpace = 0;
$Env:POWERSHELL_UPDATECHECK = 'GA';
# $ErrorView = 'CategoryView';
$Errorview = 'ConciseView';
D:\bin\repair-netloc.ps1;
WC "~darkcyan~[~~darkyellow~PowerShell Core~~darkcyan~][~~red~Profile.ps1~~darkcyan~]~~white~: Loaded all Functions and Aliases~";
```---
## BinMenu
I Still Use This Menu Every Day (09-05-24)
Bin Menu is a simple console based menu that reads in what EXE's are in the base sub-folders and which _PS1's are in the base and lists them on a menu for you. Comes with a Settings Manager script that's deals with the BinMenu.json settings and Adds. You can add your own entries to the end of the program menu list if you want up to 100. There is a toggle to show the add entries or not. Edit the json put the bin_ files in your base folder and run it. It will automatically run you through creating the INI it uses to store the Program Menu file list in. Have fun I did. And it works I use it EVERY day. (Structure of my bin folder is c:\bin is in my path and contains all my ps1 scripts. Then in all the sub folders of bin are all my programs I use that are portable. The list in the picture below sums it up.) See more extensive description in the readme in the folder. For Updates check the description in the readme in the BinMenu folder. The second image is the Scripts option (e) on the menu.
A couple notes to save you some hair pulling. You need to edit the BinMenu.lnk since BinMenu uses it to reload. It will crash out if it is not the right folder. Also if BinMenu says it is missing the ini but you know it is there run BinMenu settings manager and set the script base. Thats the normal place to look for that problem if you have created the ini already.
- Usage: `BINMENU`
---
## Write-Color (WC) and Write-ColorPrompt (WCP)
- Usage: `WC "~red~Word 1~ ~green~Word 2~"`
---
## MiniMenu
- Usage: `MiniMenu`
---
## Nano
- Usage: `nano Filename.txt`
- Usage: `nano C:\Windows\Filename.txt`---
## Check-Prof
- Usage: `Check-Prof`
---
## Convert-Script
- Usage: `Convert-Script -INFILE FullPathToFileToRead -OUTFILE FullPathToFileToWrite`
- Usage: `Convert-Script FullPathToFileToRead FullPathToFileToWrite`---
## Imageto64
- Usage: `IMAGETO64 -Path FullPathToImageFile -OutFile OptionalFullPathForTextFileOut`
---
## Clearlogs
- Usage: `CLEARLOGS`
- Usage: `CLEARLOGS -LOUD 1`
- Usage: `CLEARLOGS -SILENT 1`
- Usage: `CLEARLOGS -HIDDEN 1`---
## countThis
It simply gives a count of characters between quotes
- Usage: `countThis "anything you want a count of."`
---
## Cycle-Background
- Usage: `Cycle-background`
---
## Get-Files
- Usage: `GET-FILES normal_filesearch_parameters`
- Usage: `GET-FILES .` or `GET-FILES` (Displays current folder)---
## Get-SysInfo
- Usage: `GET-SYSINFO`
---
## Put-Input
- Usage: `Put-Input`
- Usage: `Put-Input "Any text you want on the dialog:"`
- Usage: `$ans = Put-Input "What is your answer this this question?"`---
## Put-Pause
- Usage: `Put-Pause -Prompt -Max -Default -Echo `
- Usage: `Put-Pause -Prompt "[Make A Selection]: "`
- Usage: `$a = Put-Pause -Prompt "Do you seem interested? (Y/N): " -Default "N"`
- Color Usage: `Put-Pause -Prompt "~white~Clear the Screen?~ ~cyan~(~~white~Y~~cyan~/~~white~N~~cyan~)~~white~:~ "`
- Color Usage: `Put-Pause -Prompt "~white~Clear the Screen?~ ~cyan~(~~white~Y~~cyan~/~~white~N~~cyan~)~~white~:~ " -Max 0`---
## Put-Vivaldi
I use Vivaldi browser sometimes because it, like Firefox, can have a custom user interface. My only beef was that they update it a lot and I would have to edit the files and copy over the custom css to add my changes every time they did. Well this script does the changes for me. You will only need to edit the top two folders in the script once. Add your custom css and your Vivaldi install base folder then just run it.
- Usage: `Put-Vivaldi`
---
## Put-WinSize (Formally Set-WinSize)
- Usage: Paste into your script file as a function and call to it.
---
## Put-Winposition
*I call this* This will set a named window to the desired position.
- Usage: `Put-WinPosition -WinName String -WinX Int32 -WinY Int32`
Optionally
- Usage: `Put-WinPosition -WinName String -WinX Int32 -WinY Int32 -Width Int32 -height Int32`---
## Discord Stuff
Here is where I put any Discord related PowerShell script stuff.
---
- Usage: `GOOGLE somethingtosearch` (Searches ALL normally.)
- Usage: `GOOGLE IMAGE somethingtosearch`
- Usage: `GOOGLE VIDEO somethingtosearch`
- Usage: `GOOGLE NEWS somethingtosearch`---
## Remove-Empty
- Usage: `REMOVE-EMPTY FullPathToFileToProcess`
---
## Remove-WindowsApps
- Usage: `REMOVE-WINDOWSAPPS`
---
## ASAY and NOTIFY
*I call this* This now uses BurntToast from the PowerShellGallery
- Usage: `NOTIFY or ASAY message to send to output`
- Usage: `NOTIFY or ASAY "message to send, include punctuation, to output"`
- Usage: Linux: Without Quotes do notify message to send to output or asay message to send to output---
## Search
- Usage: `SEARCH SearchPhrase BasePathToStartIn` (The star is added automatically)
---
## Edit-Config
This is my generic read and write to json files as config files.
- Usage: `Edit-Config -Confile [string] -Count [string] -Read [string] -Write [string] -Section [string] -SValue [string] -BValue [bool] -Sub [int]`
---
## Edit-SiteHost
- Usage: `Edit-SiteHost Add address`
- Usage: `Edit-SiteHost Remove address`
- Usage: `Edit-SiteHost View`---
## Env (environment)
- Usage: `ENV` (Does all variables)
- Usage: `ENV VaribleToSearch` (Without quotes)
- Usage: `ENV 'VaribleToSearch'` (With single quote)(Works on variable drive)---
## Ver (Version)
I was missing the sort of version program I wanted so here it is. Just type VER.
- Usage: `VER`
---
## Reboot
- Usage: `REBOOT STOP` or `REBOOT SHUTDOWN`
- Usage: `REBOOT` Gives you the option to type Y to reboot. Anything else no reboot.
- Usage: `REBOOT RESTART` or `REBOOT REBOOT`---
- Usage: `REPORT -In "D:\Software\_Games" -Out "D:\Downloads\Games.Txt"`
---
## Run-CheckDisk- Usage: `RUN-CHECKDISK`
---
## Repair-windows
- Usage: `REPAIR-WINDOWS` (Runs Menu)
- Usage: `REPAIR-WINDOWS SCAN`
- Usage: `REPAIR-WINDOWS Check`
- Usage: `REPAIR-WINDOWS Image`
- Usage: `REPAIR-WINDOWS REPAIR`
- Usage: `REPAIR-WINDOWS RESET`