Private/Invoke-EdenCommand.ps1
function Invoke-EdenCommand { <# .SYNOPSIS Calls the script file in the Eden folder. .DESCRIPTION Used to transfer control to the local Eden script. Passes in the Settings object, Logging Prefix and any additional arguments provided to the script. .EXAMPLE PS> Invoke-EdenLocalCommand "SourceControl/Install-ServiceSourceControlTools" $settings $loggingPrefix Calls the Install-ServiceSourceControlTools script file in the './Eden/SourceControl' folder. The $settings object and $loggingPrefix will be passed to the script. .INPUTS None .OUTPUTS Returns the output of the script that is referenced. #> [CmdletBinding()] param( [String] $EdenCommand, [String] $LoggingPrefix, [String] $SettingsName, [Hashtable] $AdditionalArgs ) try { # Write-Verbose "Calling $EdenCommand" if ($SettingsName) { if ($AdditionalArgs) { & $EdenCommand -SettingsName $SettingsName @AdditionalArgs } else { & $EdenCommand -SettingsName $SettingsName } } elseif ($AdditionalArgs) { & $EdenCommand @AdditionalArgs } else { & $EdenCommand } } catch { Write-EdenError "Error invoking the EdenCommand using file: '$EdenCommand'" $LoggingPrefix -SettingsName $SettingsName Write-EdenError "Error Message: '$($_.Exception.Message)'" $LoggingPrefix -SettingsName $SettingsName if ($VerbosePreference -eq "Continue") { Write-Verbose $_.Exception Write-Verbose $_.ScriptStackTrace } throw } } |