KB0069 - PowerShell Universal Startup Process

KB0069 - PowerShell Universal Startup Process

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. 

2. On Windows, performance counters initialized

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:
  1. initialize.ps1
  2. Custom configuration file
  3. loggingTarget.ps1
  4. variable.ps1
  5. translations
  6. accessControls.ps1
  7. tag.ps1
  8. settings.ps1
  9. middleware.ps1
  10. licenses.ps1
  11. roles.ps1
  12. environments.ps1
  13. folders
  14. scripts.ps1
  15. authenticationMethods.ps1
  16. endpointDocs.ps1
  17. computerGroups.ps1
  18. endpoints.ps1
  19. schedules.ps1
  20. publishedFolders.ps1
  21. rateLimitRules.ps1
  22. triggers.ps1
  23. terminals.ps1
  24. loginPage.ps1
  25. pages
  26. modules
  27. dashboards.ps1
  28. eventHubs.ps1

9. Synchronize with git, if configured

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: 
  1. Git sync
  2. Heartbeat
  3. Health Check
  4. 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.

    • Related Articles

    • PowerShell Universal Service crashes on startup after an upgrade to 1.4.6

      Version: PowerShell Universal 1.4.6 Issue The PowerShell Universal service will crash with the following error in Event Viewer.  Application: Universal.Server.exe CoreCLR Version: 4.700.19.56402 .NET Core Version: 3.1.0 Description: The process was ...
    • IIS: HTTP Error 502.5 - ANCM Out-Of-Process Startup Failure

      Applies to: PowerShell Universal 1.4 or later When configuring PowerShell Universal to run under IIS, you may be presented with an error that states ANCM Out-Of-Process Startup Failure. This error can be presented for a variety of reasons but the ...
    • KB0011 - Are licenses different between Production, QA and Test/Development servers?

      Update January 24th, 2023 Adam recently summarized the Developer's license per below: The only real limitation on the developer license is that it cannot be accessed remotely. The server is only available on loopback when using the dev license. If ...
    • KB0066 - Get-WMIObject cmdlet not working

      Scope This article applies to any scenario where the Get-WMIObject cmdlet is expected to be available and functioning within a PowerShell Universal instance. Effectively, this article will only apply to instances that run under the Windows operating ...
    • KB0070 - Load Npgsql.dll In PowerShell Universal

      Purpose The purpose of this document is to provide information on how to load Npgsql in PowerShell Universal's integrated environment. Npgql is a library for accessing PostgreSQL databases. Problem Npgsql versions are built against specific versions ...