I have a script for creating and managing Active Directory users.
After a function has run, I need it to switch back to the RBFTMenu
function.
Is there a way to do this?
EDIT
Menu
function RBFTMenu {
cls
Write-Host 'User Creation
1. Create a Single User
2. Create Multiple Users
_________________________________________________
Active Directory ~ User Management
3. Password Reset
4. Disable/Enable A User Account
_________________________________________________
Exchange ~ User Management
5. Give Full Mailbox Access
q. Quit
'
while (($RBFTSelection = Read-Host -Prompt 'Please Select An Option & Press Enter') -notin 1,2,3,4,5 ,'q') {
Write-Warning "$RBFTSelection is not a valid option"
}
switch ($RBFTSelection) {
1 { New-UserManualRBFT }
2 { New-UserFromCSVRBFT }
3 { PasswordResetRBFT }
4 { DisableEnableUserRBFT }
5 { FullAccessRBFT }
}
}
Example End Of Function
Write-Host " "
Write-Host " "
echo "Press Any Key To Close"
$HOST.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") | Out-Null
$HOST.UI.RawUI.Flushinputbuffer()
}
Assuming that the function returns something by which you can decide which action to take you could invoke it in a loop like this:
while ($true) {
$action = RBFTMenu
switch ($action) {
...
}
}
Edit
Since you handle the actions in your menu function you just need to call your function in a loop:
while ($true) {
RBFTMenu
}
You should add an exit
branch to your switch
statement, though:
switch ($RBFTSelection) {
1 { New-UserManualRBFT }
...
'q' { exit }
}