├── MenuShell.psd1 ├── MenuShell.psm1 ├── Start-MenuShell.ps1 ├── MenuShell.EzFormat.ps1 ├── MenuShell.Pipeworks.psd1 ├── en-us └── About_MenuShell.help.txt ├── Readme.md └── MenuShell.Format.ps1xml /MenuShell.psd1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/StartAutomating/MenuShell/HEAD/MenuShell.psd1 -------------------------------------------------------------------------------- /MenuShell.psm1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/StartAutomating/MenuShell/HEAD/MenuShell.psm1 -------------------------------------------------------------------------------- /Start-MenuShell.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/StartAutomating/MenuShell/HEAD/Start-MenuShell.ps1 -------------------------------------------------------------------------------- /MenuShell.EzFormat.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/StartAutomating/MenuShell/HEAD/MenuShell.EzFormat.ps1 -------------------------------------------------------------------------------- /MenuShell.Pipeworks.psd1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/StartAutomating/MenuShell/HEAD/MenuShell.Pipeworks.psd1 -------------------------------------------------------------------------------- /en-us/About_MenuShell.help.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/StartAutomating/MenuShell/HEAD/en-us/About_MenuShell.help.txt -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Official Website](http://MenuShell.Start-Automating.com) 4 | 5 | 6 | 7 | 8 | ### MenuShell is a sweet and simple PowerShell module to help you make console menus. 9 | 10 | 11 | Because everyone wants them, and no one wants to make them by hand. 12 | 13 | 14 | To use MenuShell, just use the command Start-MenuShell. To exit menu shell, type exit or quit. 15 | 16 | 17 | Here's a simple demo MenuShell to explore your system: 18 | 19 | 20 | Start-MenuShell -Menu @{ 21 | "Processes" = @{ 22 | "Get" = { Get-Process } 23 | Run = { Start-Process } 24 | } 25 | "Services" = @{ 26 | 27 | } 28 | "Performance" = @{ 29 | "CPU" = { Get-Counter '\Processor(*)\% Processor Time' } 30 | 'Disks' = { Get-Counter '\PhysicalDisk(*)\% Disk Read Time', '\PhysicalDisk(*)\% Disk Write Time', '\PhysicalDisk(*)\% Idle Time', '\PhysicalDisk(*)\% Disk Time' } 31 | 32 | } 33 | "Disks" = @{ 34 | "%Free" = { Get-Counter '\LogicalDisk(*)\% Free Space' } 35 | } 36 | } 37 | 38 | 39 | 40 | MenuShell is built with one simple command (Start-MenuShell) and one formatter. It was written with the help of [EZOut](http://ezout.start-automating.com). 41 | 42 | -------------------------------------------------------------------------------- /MenuShell.Format.ps1xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | MenuShell 6 | 7 | MenuShell 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | $menuShell = $_ 18 | 19 | 20 | Clear-Host 21 | 22 | 23 | 24 | if ($menuShell.Name) { 25 | $host.UI.RawUI.Windowtitle =$menuShell.Name 26 | } 27 | 28 | $menuShell.Menu.GetEnumerator() | 29 | Sort-Object { 30 | $_.Key -replace "[\(\)]","" 31 | } | 32 | ForEach-Object { 33 | if ($menuShell.OptionColor -and $menuShell.OptionColor[$_.Key -replace "[\(\)]",""]) { 34 | Write-Host -ForegroundColor $menuShell.OptionColor[$_.Key -replace "[\(\)]",""] -Object ((" " * 5) + $_.Key) 35 | } else { 36 | Write-Host ((" " * 5) + $_.Key) 37 | } 38 | } 39 | 40 | 41 | if ($menuShell.isnested) { 42 | Write-Host " (B)ack" 43 | } 44 | 45 | 46 | "" 47 | 48 | $invalidChoice = $true 49 | 50 | do { 51 | $choice = Read-Host 52 | $choice = $choice.Trim() 53 | if ($choice -eq 'Exit' -or $choice -eq 'Quit' -or $choice -eq 'Back' -or $choice -eq 'B') { Clear-Host; break } 54 | $ValidChoice = @(@(@($menuShell.Menu.Keys) + '(B)ack') | 55 | Where-Object { 56 | 57 | $choice -eq ($_ -ireplace "[\(\)]",'') -or 58 | ($_ -match "\((.{1,})\)" -and ($choice -eq ($Matches.1))) 59 | }) 60 | 61 | if ($ValidChoice -and $ValidChoice.Count -eq 1) { 62 | if ($ValidChoice -eq 'B' -or $validChoice -eq 'Back') { 63 | Clear-Host 64 | break 65 | } elseif ($menuShell.Menu[$($ValidChoice)] -is [ScriptBlock]) { 66 | 67 | & $menuShell.Menu[$($ValidChoice)] | Out-Host 68 | } elseif ($menuShell.Menu[$($ValidChoice)] -is [Hashtable]){ 69 | $subMenu = New-Object PSObject -Property @{ 70 | Menu = $menuShell.Menu[$($ValidChoice)] 71 | Name = $menuShell.Name 72 | OptionColor = $menuShell.OptionColor 73 | IsNested = $true 74 | } 75 | 76 | $subMenu.pstypenames.clear() 77 | $subMenu.pstypenames.Add('MenuShell') 78 | $subMenu | Out-Host 79 | 80 | } elseif ($menuShell.Menu[$($ValidChoice)] -is [string]) { 81 | Write-Host $menuShell.Menu[$($ValidChoice)] 82 | } 83 | 84 | if ($menu.ExitOnValidSelection) { 85 | $invalidChoice = $false 86 | } else { 87 | 88 | Write-Host 89 | Write-Host 90 | Write-Host 91 | Write-Host 92 | 93 | $menuShell.Menu.GetEnumerator() | 94 | Sort-Object { 95 | $_.Key -replace "[\(\)]","" 96 | } | 97 | ForEach-Object { 98 | if ($menuShell.OptionColor -and $menuShell.OptionColor[$_.Key -replace "[\(\)]",""]) { 99 | Write-Host -ForegroundColor $menuShell.OptionColor[$_.Key -replace "[\(\)]",""] -Object ((" " * 5) + $_.Key) 100 | } else { 101 | Write-Host ((" " * 5) + $_.Key) 102 | } 103 | } 104 | 105 | 106 | if ($menuShell.isnested) { 107 | Write-Host " (B)ack" 108 | } 109 | } 110 | 111 | } 112 | } while ($invalidChoice) 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | --------------------------------------------------------------------------------