Im trying to create a interactive menu in powershell. Now i want to know if its possible to get the menu options to come out of a text file:
function GetMenu { Clear-Host Write-Ascii -fore green "Berechtigungen" "" "1)Root Folder" "2)Sub Folder" "3)Delete Folder" "4)Add User" "" "x) Exit" "" $MenuSelection = Read-Host "Choose Option" GetSubMenu } GetMenu ########################################### function GetSubMenu { write-host "" switch -wildcard ($MenuSelection) { "1" { function GetSubMenuRoot { write-host "" switch -wildcard ($MenuSelectionRoot) { "1" { } "2" { } "3" { } "x" { Clear-Host; exit} default{Clear-Host;GetMenuRoot} } } function GetMenuRoot { Clear-Host Write-Ascii -fore green "RootFolder" "" "1)(From TextFile)" "2)(From TextFile)" "3)(From TextFile)" "" "x) Exit" "" $MenuSelectionRoot = Read-Host "Wähle Option" GetSubMenuRoot } GetMenuRoot } "2" { } "3" { } "4" { } "x" { Clear-Host; exit} default{Clear-Host;GetMenu} } }
The Text file looks like this:
Org;Share;
Sales;\srvSales\Sales$
IT;\srvIT\IT$
CEO;\srvCEO\CEO$\
(from textfile) should now be:
1)Salse
2)IT
3)CEO
As menu options
Sorry english isn't my first language if something is unclear please ask.
https://stackoverflow.com/questions/66816627/powershell-interactive-menu-menu-options-from-text-file March 26, 2021 at 08:06PM
没有评论:
发表评论