-
Notifications
You must be signed in to change notification settings - Fork 3
Module Framework
root edited this page Jan 24, 2024
·
2 revisions
AD-PowerAdmin has undergone an entire rework. This tool started with a single purpose, but over time, I kept adding more and more features, eventually turning a simple tool into a monolithic mess. To keep adding features, I needed to create a modular method of loading and managing new functions. I also wanted to enable others to add features without reading through all the tool's code. So, for AD-PowerAdmin to grow, I created a framework for adding functionality.
The core functions of the modular framework are...
- Dynamicly build a main menu based on module-defined options of tools
- Let the user select an option, which runs the a module function.
- Let the user pull a help menu for each option.
- Module-defined unattended jobs that can be run via a scheduled task.
- Module-defined unattended jobs that should be run daliy and run via a scheduled task.
There is an example module you can use as a staring point at the below URL. https://github.com/Brets0150/AD-PowerAdmin/tree/main/Modules_Examples
Here is an overview of how the framework works.
graph TD;
subgraph MSL ["Main Script Loading"]
A[AD-PowerAdmin.ps1]
B[Import .psd1 Files from Modules Folder]
C[Loop Through Modules]
D[Invoke Initialize-Module in Module]
E[Append to $global:Menu]
F[Build Main Menu from $global:Menu]
M[Append $global:UnattendedJobs]
end
subgraph IM["Interactive Mode"]
G[Display Main Menu]
H{{User Selects Option}}
I[Run Function from a Module]
J[Help Option]
K[Output the options content of the functions .DESCRIPTION]
L[Quit]
end
subgraph UM["Unattended Mode"]
Q[Run -JobName MyJob -JobVar1 test]
R[Exit Script]
end
N{-Unattended Mode?}
A --> B
B --> C
C --> D
D -->|For Each| E
F --> D
F -->|All Modules Loaded| N
E --> M
M --> F
G --> H
I --> G
H ---> |Select Option| J & L & I
J --> K
K --> G
N -->|True| Q
N -->|False|G
Q-->R