InvokeSystems.Common
InvokeSystems common helpers (event log setup and shared utilities).
Overview
- Provides shared helpers used by multiple InvokeSystems modules.
- Supplies event log initialization and admin context checking.
- Target platform: PowerShell 5.1+ on Windows.
Public Functions
| Function | Description |
|---|---|
Initialize-InvEventLogSource | Ensures a Windows Event Log source exists, supports -WhatIf and -DryRun |
Test-InvAdministratorContext | Returns $true if running with administrator privileges |
Usage
# Event log source initialization
Initialize-InvEventLogSource -EventSource 'MyApp'
Initialize-InvEventLogSource -EventSource 'MyApp' -EventLogName 'Application' -WhatIf
Initialize-InvEventLogSource -EventSource 'MyApp' -DryRun
# Admin context check
if (-not (Test-InvAdministratorContext)) {
throw 'This script requires administrator privileges'
}
Dependency Handling
- The module is referenced as a
RequiredModuleby dependent modules. - Module loaders in
InvokeSystems.RestrictedTaskandInvokeSystems.UpdateRepairimport it automatically from a sibling path or from the standard module path if installed. - If the module is missing, importing the dependent module will surface a clear error with the expected path.
Optional Auto-Install Snippet
if (-not (Get-Module -ListAvailable -Name 'InvokeSystems.Common')) {
Install-Module -Name 'InvokeSystems.Common' -Scope CurrentUser -Repository PSGallery -Force -AllowClobber
}
Testing
- Pester v5 tests live in
InvokeSystems.Common/tests/InvokeSystems.Common.Tests.ps1. - Run with:
Invoke-Pester -Path .\InvokeSystems.Common\tests\InvokeSystems.Common.Tests.ps1