I am trying to get a menu working that works through multiple selectors and based on the selector that is chosen, I want a specific task to happen for each choice. I have built the following below however, I don’t know how I can achieve what I am looking to do. Essentially for every option selected, I want a txt file to be populated by an ArrayList. So if options 1,2,2,1,1 are selected in that order, I want Powershell to look into the corresponding array lists for those options and extract the values in those arrays and insert them into 1 .txt file on the user’s desktop. Is there anyone that can help guide me in building this, or know of a site where I can pay someone to do it for me? Code below:
Function Menu ($MenuStart, $MenuEnd, $MenuName, $MenuFunctionName, $MenuOption1, $MenuFunction1, $MenuOption2, $MenuFunction2)
{
Write-Host “`n$MenuName`n” -Fore Green;
if($MenuOption1 -ne $null){Write-Host “`t`t$MenuOption1” -Fore Magenta;}
if($MenuOption2 -ne $null){Write-Host “`t`t$MenuOption2” -Fore magenta;}
[int]$MenuOption = Read-Host “`n`t`tPlease select an option”
if(($MenuOption -lt $MenuStart) -or ($MenuOption -gt $MenuEnd))
{
Write-Host “`t`nPlease select one of the options available.`n” -Fore Red;start-Sleep -Seconds 1
Invoke-Expression $MenuFunctionName
}
else
{
if($MenuOption -eq $MenuStart) {Invoke-Expression $MenuFunction1}
if($MenuOption -eq ($MenuStart + "1")) {Invoke-Expression $MenuFunction2}
if($MenuOption -eq ($MenuStart + "2")) {Invoke-Expression $MenuFunction3}
}
}
######################Arrays for Each Category###################
$DefaultGroups = New-Object -TypeName "System.Collections.ArrayList"
$DefaultGroups.Add("TestGroup1 -- Security Group")
$DefaultGroups.Add("TestGroup2 -- Security Group")
$DefaultGroups.Add("TestGroup3 -- Distribution Group")
$NewPerson_SectionB = New-Object -TypeName "System.Collections.ArrayList"
$NewPerson_SectionB.Add("TestGroup4 -- Security Group")
$NewPerson_SectionB.Add("TestGroup5 -- Security Group")
$NewPerson_SectionB.Add("TestGroup6 -- Distribution Group")
$NewPerson_SectionB.Add("TestGroup7 -- Distribution Group")
$NewPerson_SectionC = New-Object -TypeName "System.Collections.ArrayList"
$NewPerson_SectionC.Add("TestGroup8 -- Security Group")
$NewPerson_SectionC_D = New-Object -TypeName "System.Collections.ArrayList"
$NewPerson_SectionC_D.Add("TestGroup9 -- Security Group")
$NewPerson_SectionC_E = New-Object -TypeName "System.Collections.ArrayList"
$NewPerson_SectionC_E.Add("Testgroup10 -- Security Group")
$NewPerson_SectionF = New-Object -TypeName "System.Collections.ArrayList"
$NewPerson_SectionF.Add("TestGroup11-- Organizational Mailbox")
$FinalizedList = New-Object -TypeName "System.Collections.ArrayList"
ExampleOrgMENU_HOME
###ExampleOrgMENU_HOME#####
###############################################################################################################################################################################################################################
function ExampleOrgMENU_HOME
{
Menu 1 2 "Example Organization In-Processing - Baseline Permissions Identifier Tool - Please advise if you are using this tool for In-Processing" ExampleOrgMENU_HOME "1. Yes" In-Processing "2. No" ExampleOrgMENU_HOME
}
##At the is point I want my $FinalizedList array to be populated with my collections from my $defaultgroups array list and continue down to the next question based off of user input##
###############################################################################################################################################################################################################################
##In-Processing Menu##
function In-Processing
{
Menu 1 2 "Please select whether you are a newperson section B or newperson section C" In-Processing "1. newperson section B" new person_section_B "2. newperson section C" newperson_section_C
}
##At the is point I want my $FinalizedList array to have new entries added from my array list dependant on the response of the individual and continue down to the next question based off of user input##
###newperson_section_B Menu##
###############################################################################################################################################################################################################################
function newperson_section_B
{
Menu 1 2 "Please select option 1 to finish this process and continue your document" newperson_section_B "1. Please export my $finalizedlist array output to my desktop on a .txt file named document Groups" Finalize_Function "2. Exit to the beginning of the script" ExampleOrgMENU_HOME
}
##At the is point I want my $FinalizedList array to have new entries added from my array list dependant on the response of the individual and then export the list to a txt file on the userprofile desktop##
###newperson_section_C Menu##
###############################################################################################################################################################################################################################
function newperson_section_C
{
Menu 1 2 "Please select whether you are newperson section C-D or newperson section C-E " newperson_section_C "1. newperson section C-D" newperson_section_C_D "2. newperson section C-E" newperson_section_C_E
}
##At the is point I want my $FinalizedList array to have new entries added from my array list dependant on the response of the individual and then continue to the next menu##
###newperson_section_C_E Menu##
###############################################################################################################################################################################################################################
function newperson_section_C_E
{
Menu 1 2 "Are you going to be a newperson section C-E-F?"newperson_section_C_E "1. Yes" newperson_section_C_E_F "2. No, Please export my $finalizedlist array output to my desktop on a .txt file named document Groups" Finalize_Function
}
##At the is point I want my $FinalizedList array to have new entries added from my array list dependant on the response of the individual and then export the list to a txt file on the userprofile desktop if they select option 2, however if they select option 1 I want to update the $finalized array with the groups neccesary and then continue to the next menu##
##newperson_section_C_D Menu##
###############################################################################################################################################################################################################################
function newperson_section_C_D
{
Menu 1 2 "Please select option 1 to finish this process and continue your document" newperson_section_C_D "1. Please export my $finalizedlist array output to my desktop on a .txt file named document Groups" Finalize_Function "2. Exit to the beginning of the script" ExampleOrgMENU_HOME
}
##At the is point I want my $FinalizedList array to have new entries added from my array list dependant on the response of the individual and then export the list to a txt file on the userprofile desktop if option 1 is selected##
###newperson_section_C_E_F Menu##
###############################################################################################################################################################################################################################
function newperson_section_C_E_F
{
Menu 1 2 "Please select option 1 to finish this process and continue your document" newperson_section_C_E_F "1. Please export my $finalizedlist array output to my desktop on a .txt file named document Groups" Finalize_Function "2. Exit to the beginning of the script" ExampleOrgMENU_HOME
}
##At the is point I want my $FinalizedList array to have new entries added from my array list dependant on the response of the individual and then export the list to a txt file on the userprofile desktop if option 1 is selected##