Purpose
The purpose of this document is to outline the steps that PowerShell Universal takes when starting up.
Process
1. Insert current product version and install date in database
Updates the database with a record about the current product version and install date in the database. This is helpful for auditing when an update has taken place. A notification will be present in the admin console once it is loaded.
Performance counters have to have been previously installed by the PowerShell Universal MSI or by hand. PowerShell Universal will initialize the counters to ensure that can be accessed quickly by the platform.
3. Register default secret management vaults
Default secret vaults are registered. This includes the BuiltInLocalVault, PSUSecretStore and the Database.
4. Starts internal processing services
Internal services are activated to service requests from other features of the system. This includes starting internal gRPC channels to allow for communication of cmdlets across -Integrated mode.
5. Caches app tokens
App tokens are read from the database and cached in memory. This ensures fast performance when accessing APIs with these app tokens. Changes to app tokens invalidate the cache.
6. Loads configuration for authentication methods from appsettings.json
Loads any authentication methods from appsettings.json, environment variables or command line options. These are read-only in the admin console and management API. They will take precedence over authentication methods defined in authentication.ps1.
7. Clean up orphaned jobs, terminals and user sessions
Any jobs, terminals or user sessions that are currently marked as active are set to failed or terminated. This is only required when the service is not stopped gracefully and these features are still active.
8. Load existing configuration data from the repository folder
Loads configuration data from the .universal folder. This will load most of the features of PowerShell Universal. Before the configuration files are run, the initialize.ps1 file is run.
The order of files are of v4.2.9:
- initialize.ps1
- Custom configuration file
- loggingTarget.ps1
- variable.ps1
- translations
- accessControls.ps1
- tag.ps1
- settings.ps1
- middleware.ps1
- licenses.ps1
- roles.ps1
- environments.ps1
- folders
- scripts.ps1
- authenticationMethods.ps1
- endpointDocs.ps1
- computerGroups.ps1
- endpoints.ps1
- schedules.ps1
- publishedFolders.ps1
- rateLimitRules.ps1
- triggers.ps1
- terminals.ps1
- loginPage.ps1
- pages
- modules
- dashboards.ps1
- eventHubs.ps1
If git is configured, PowerShell Universal will pull configuration files from the remote repository and store them locally.
10. Update or load new configuration data from the repository folder.
If the repository folder is empty and new files are added, step 8 will be re-run with the new configuration files. If there were files locally and new changes are present, only the updated files will be reconfigured.
11. Schedules internal background jobs
Internal background jobs are schedules. These include:
- Git sync
- Heartbeat
- Health Check
- Update Check
12. Enable auto reload
If auto-reload is enabled (it is by default), then a file system watcher will be started to begin watching for changes to the repository folder. Any changes will invoke the configuration system.
13. Create default admin if no credentials exist.
If no credentials or identities exist, the default admin account will be created.
14. Reset admin account, if command specified
If the ResetAdminAccount setting is specified in appsettings.json, an environment variable or via command line arguments, the default admin account will be reset.
15. Trigger server started event
The server started trigger will run.
16. Set computer online and uptime
The computer is set to online, and the uptime is updated. At this point, the admin console will no longer display the loading page.