Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/IdLE.Core/IdLE.Core.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
'New-IdlePlanObject',
'Invoke-IdlePlanObject',
'Export-IdlePlanObject',
'New-IdleAuthSessionBroker'
'New-IdleAuthSessionBroker',
'Invoke-IdleProviderMethod',
Comment thread
blindzero marked this conversation as resolved.
'Test-IdleProviderMethodParameter'
)
CmdletsToExport = @()
AliasesToExport = @()
Expand Down
4 changes: 3 additions & 1 deletion src/IdLE.Core/IdLE.Core.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,7 @@ Export-ModuleMember -Function @(
'New-IdlePlanObject',
'Invoke-IdlePlanObject',
'Export-IdlePlanObject',
'New-IdleAuthSessionBroker'
'New-IdleAuthSessionBroker',
'Invoke-IdleProviderMethod',
'Test-IdleProviderMethodParameter'
) -Alias @()
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,49 @@
# Handles auth session acquisition, parameter detection, and backwards-compatible fallback.

function Invoke-IdleProviderMethod {
<#
.SYNOPSIS
Invokes a provider method with optional AuthSession support.

.DESCRIPTION
This is a foundational helper for step implementations that need to invoke
provider methods with proper authentication handling.

Key features:
- Acquires auth sessions via Context.AcquireAuthSession when With.AuthSessionName is present
- Detects whether provider methods support AuthSession parameter (backwards compatible)
- Passes AuthSession to provider methods that support it
- Validates provider existence and method implementation

.PARAMETER Context
Execution context created by IdLE.Core. Must contain Providers hashtable and
AcquireAuthSession method.

.PARAMETER With
Step configuration hashtable. May contain:
- AuthSessionName (string): Name of auth session to acquire
- AuthSessionOptions (hashtable): Optional session selection options

.PARAMETER ProviderAlias
Key to look up the provider in Context.Providers.

.PARAMETER MethodName
Name of the provider method to invoke.

.PARAMETER MethodArguments
Array of arguments to pass to the provider method (excluding AuthSession).

.OUTPUTS
Object returned by the provider method.

.EXAMPLE
$result = Invoke-IdleProviderMethod `
-Context $Context `
-With @{ AuthSessionName = 'ExchangeOnline' } `
-ProviderAlias 'ExchangeOnline' `
-MethodName 'EnsureMailboxType' `
-MethodArguments @('user@contoso.com', 'Shared')
#>
[CmdletBinding()]
param(
[Parameter(Mandatory)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,40 @@
# Supports ScriptMethod (AST inspection) and compiled methods (reflection).

function Test-IdleProviderMethodParameter {
<#
.SYNOPSIS
Tests whether a provider method supports a given parameter.

.DESCRIPTION
This is a foundational helper that inspects provider method signatures to determine
if they accept a specific parameter (e.g., AuthSession).

Supports:
- ScriptMethod (AST inspection via PowerShell parser)
- Compiled methods (reflection-based inspection)

Used by Invoke-IdleProviderMethod to detect backwards-compatible method signatures.

.PARAMETER ProviderMethod
PSMethodInfo object representing the provider method to inspect.

.PARAMETER ParameterName
Name of the parameter to check for (e.g., 'AuthSession').

.OUTPUTS
Boolean. True if the method accepts the specified parameter, False otherwise.

.EXAMPLE
$provider = [pscustomobject]@{}
$provider | Add-Member -MemberType ScriptMethod -Name MyMethod -Value {
param($Arg1, $AuthSession)
# ...
}

$method = $provider.PSObject.Methods['MyMethod']
Test-IdleProviderMethodParameter -ProviderMethod $method -ParameterName 'AuthSession'
# Returns: True
#>
[CmdletBinding()]
[OutputType([bool])]
param(
Expand Down
2 changes: 2 additions & 0 deletions src/IdLE.Steps.Common/IdLE.Steps.Common.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
Description = 'Common built-in steps for IdLE.'
PowerShellVersion = '7.0'

RequiredModules = @('IdLE.Core')

FunctionsToExport = @(
'Get-IdleStepMetadataCatalog',
'Invoke-IdleStepEmitEvent',
Expand Down
4 changes: 2 additions & 2 deletions src/IdLE.Steps.Common/Public/Get-IdleStepMetadataCatalog.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function Get-IdleStepMetadataCatalog {
<#
.SYNOPSIS
Returns metadata for built-in IdLE step types.
Returns metadata for common built-in IdLE step types.

.DESCRIPTION
This function provides a metadata catalog mapping Step.Type to metadata objects.
Expand All @@ -16,7 +16,7 @@ function Get-IdleStepMetadataCatalog {
.EXAMPLE
$metadata = Get-IdleStepMetadataCatalog
$metadata['IdLE.Step.DisableIdentity'].RequiredCapabilities
# Returns: @('IdLE.Identity.Disable', 'IdLE.Identity.Read')
# Returns: @('IdLE.Identity.Disable')
#>
[CmdletBinding()]
param()
Expand Down
1 change: 1 addition & 0 deletions src/IdLE.Steps.DirectorySync/IdLE.Steps.DirectorySync.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
PowerShellVersion = '7.0'

RequiredModules = @(
'IdLE.Core',
'IdLE.Steps.Common'
)

Expand Down
2 changes: 1 addition & 1 deletion src/IdLE.Steps.Mailbox/IdLE.Steps.Mailbox.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Description = 'Provider-agnostic mailbox step pack for IdLE.'
PowerShellVersion = '7.0'

RequiredModules = @('IdLE.Steps.Common')
RequiredModules = @('IdLE.Core', 'IdLE.Steps.Common')

FunctionsToExport = @(
'Get-IdleStepMetadataCatalog',
Expand Down
Loading