-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDemo.ps1
More file actions
65 lines (43 loc) · 2.75 KB
/
Demo.ps1
File metadata and controls
65 lines (43 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
$ScriptFullPath = $MyInvocation.MyCommand.Definition
Import-Module '.\SimpleMenu.psm1' -Force
Function InstallService() {
Write-host 'installing service logic here...'
Write-Host 'Congratulations, your service was installed' -ForegroundColor Green
}
Function UninstallService() {
Write-Host 'Uninstalling service... '
Write-Host 'Done.'
throw 'test error'
}
$OptionsMenu = New-SMMenu -Title 'Options' -TitleForegroundColor Red -Items @(
"Enter Powershell prompt" | New-SMMenuItem -Action { Write-host 'Type exit to go back to menu'; $host.enternestedprompt(); $menu.print() }
"Edit this menu" | New-SMMenuItem -Action { powershell_ise.exe "$ScriptFullPath" }
"Display script full path" | New-SMMenuItem -Action { Write-Host $ScriptFullPath -ForegroundColor Yellow }
"Back" | New-SMMenuItem -Key B -Quit
)
#[Console]::InputEncoding =[System.Text.Encoding]::UTF8
#[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
$ErrorActionPreference = [System.Management.Automation.ActionPreference]::Stop
#New-SMMenuItem -Submenu $OptionsMenu -Debug
$Menu = New-SMMenu -Title 'Service manager' -Items @(
"Install Service" | New-SMMenuItem -ID 'Install' -Action { InstallService }
"Uninstall Service" | New-SMMenuItem -Action { UninstallService }
'Empty' | New-SMMenuItem
"Change this menu" | New-SMMenuItem -Id 'ChangeItem' -Action { $_.Title = 'Yay !'; cls; $Menu.Print(); }
"Test Error" | New-SMMenuItem -Key D -Action { Throw 'Unmanaged error' }
"Options" | New-SMMenuItem -key O -submenu $OptionsMenu
"Exit" | New-SMMenuItem -Key RightArrow -Action {} -Quit
) -ActionItems @(
New-SMMenuItem -Key X -Action { Write-Host 'Boo !' -ForegroundColor Red } -Quit -Pause
)
$Board3 = New-SMBoard -Title 'Crypto informations' -DefaultIndex 2 -Items @(
'Options' | New-SMBoardItem -Pages { Invoke-SMMenu -Menu $Menu; $_.NextBoard() }
'Main board' | New-SMBoardItem -Pages { ' Page 1' }, { 'Page 2' }, { 'Page 3' }
'Crypto infos' | New-SMBoardItem -Pages { 'Board 2' }
) -ActionItems @(
'Hidden :)' | New-SMBoardItem -Pages { 'hidden' }, { 'page 2' } -key X
'Hidden :)' | New-SMBoardItem -Pages { 'hidden' } -key y
)
Invoke-SMBoard -Board $Board3
$ErrorActionPreference = [System.Management.Automation.ActionPreference]::Stop
#Invoke-SMMenu -Menu $Menu -lang fr