i am new to this so please explain very basic 
I’ve created a PS script by piecing together lots of code from the Community but…Now i ask you guys if u can help me put the last bit togheter. <333.
So can you please help me with the following → if i wanna run this line for example i put in 1 then enter i want to get that Write-Host that says 1 - test script to execute a command in the code how do i mange to make it do that.
<# # ==================================================================================================== # # Script: PoSHMenuTemplate.ps1 # # Version: 1.0.0 # # Author: Calahan, Cory # # Create date: 2013-07-17 # # Description: PowerShell “batch” menu template. # # Comments:
https://stealthfield.wordpress.com # # ==================================================================================================== # #>
Clear-Host
$Host.UI.RawUI.WindowTitle = “PoSH Menu Template”
function loadMainMenu()
{
[bool]$loopMainMenu = $true
while ($loopMainMenu)
{
Clear-Host # Clear the screen.
Write-Host -BackgroundColor darkblue -ForegroundColor White “n
|__ | \ | \ |__ | || | |/| / \ |\ |
|___ |/ |/ |___ | | | |___ | | /~~\ | | t
n”
$runasAlias = [Environment]::UserName
Write-Host -BackgroundColor black -ForegroundColor White “Running as: ----> $runasAlias`n”
Write-Host -BackgroundColor darkgreen -ForegroundColor White “t
---->|Huvud meny|<-----t
tn” Write-Host “
tt
t1 - scripts”
Write-Host “t
tt2 - Meny (2)” Write-Host “
tt
t3 - Meny (3)”
Write-Host “t
tt4 - Meny (4)” Write-Host “
tt
tQ — Avsluta och stängn” Write-Host -BackgroundColor DarkCyan -ForegroundColor Yellow "
obs!: ↴ t" Write-Host -BackgroundColor RED -ForegroundColor White "
Du kör detta på egen risk /mvh edvin:J.t
n"
$mainMenu = Read-Host “t
tcommand to run?” # Get user’s entry.
switch ($mainMenu)
{
1{mainMenuOption1} # Calls function mainMenuOption1()
2{} #To-do: Add.
3{} #To-do: Add.
4{} #To-do: Add.
“q” {
$loopMainMenu = $false
Clear-Host
Write-Host -BackgroundColor DarkCyan -ForegroundColor Yellow “t
tt
tt" Write-Host -BackgroundColor DarkCyan -ForegroundColor Yellow "
tGoodbye!t
tt" Write-Host -BackgroundColor DarkCyan -ForegroundColor Yellow "
tt
tt
t”
sleep -Seconds 1
$Host.UI.RawUI.WindowTitle = “Windows PowerShell” # Set back to standard.
Clear-Host
Exit-PSSession
}
default {
Write-Host -BackgroundColor Red -ForegroundColor White “FEL val för Kommando försök igen.”
sleep -Seconds 1
}
}
}
return
}
function mainMenuOption1()
This section is used for Loading Main Menu Option 1, .
{
[bool]$loopSubMenu = $true
while ($loopSubMenu)
{
$Host.UI.RawUI.WindowTitle = “PoSH Sub Menu 1”
Clear-Host # Clear the screen.
Write-Host -BackgroundColor Black -ForegroundColor White “n
t Undermeny 1 (Scripts)t
n”
Write-Host -BackgroundColor Black -ForegroundColor White “t
tSCRIPTSt
tn” $runasAlias = [Environment]::UserName Write-Host -BackgroundColor Black -ForegroundColor White "Running as: $runasAlias
n"
Write-Host “t
tt1 - test script ” Write-Host “
tt
t2 - Sub Menu 2 - Option 2”
Write-Host “t
tt3 - Sub Menu 3 - Option 3” Write-Host “
tt
tQ — Återvänd till Huvudmenyn” $subMenu = Read-Host “
t`tcommand to run?”
switch ($subMenu)
{
1
{
loadSubMenu1Option1
}
2
{
#loadSubMenu2
}
3
{
#loadSubMenu3
}
q
{
$loopSubMenu = $false
}
default
{
Write-Host -BackgroundColor Red -ForegroundColor White “FEL val för Kommando försök igen.”
sleep -Seconds 1
}
}
}
}
function loadSubMenu1Option1()
{
Repeat Code Block from mainMenuOption1. Continue nesting based on features/selections you want.
}
Start the Menu once loaded:
loadMainMenu
Extras:
if ($clearHost) {Clear-Host}
if ($exitSession) {Exit-PSSession};