Private/Invoke-EdenCommandStandardFlow.ps1
function Invoke-EdenCommandStandardFlow { <# .SYNOPSIS Runs standard flow for calling local script. .DESCRIPTION Calls the standard script provided and prints messages around executing the script. #> [CmdletBinding()] param( # The local script to call. Relative path from the Eden folder. [Parameter(Mandatory=$True)] [String] $LocalCommandPath, # The name of the local or global settins file to pass to the Eden script. [Parameter()] [String] $SettingsName, # The string to display at the end of the logging prefix for the command group. [Parameter(Mandatory=$True)] [String] $CommandGroup, # The message to display as starting, finished, or errored around invoking the command. [Parameter(Mandatory=$True)] [String] $Message, # Passes a hash table to the local command script for custom arguments that it needs. # This set of parameters should be option. The script should prompt the user for the # values if they are not provided. This helps with discovery of the customer parameters. [Parameter(Mandatory=$False)] [Hashtable] $AdditionalArguments ) $location = Get-Location try { $settings = Get-EdenSettings -Name $SettingsName $loggingPrefix = "$($settings.SolutionName) $($settings.ServiceName) $($settings.Name) $($CommandGroup)" $outFile = $null -ne $settings.EdenOutputFile -and ![String]::IsNullOrEmpty($settings.EdenOutputFile) if ($outFile) { Start-Transcript -Path $settings.EdenOutputFile -Force -Append } Write-EdenInfo "Starting: $Message" $loggingPrefix Invoke-EdenLocalCommand $LocalCommandPath $settings $loggingPrefix $AdditionalArguments Write-EdenInfo "Finished: $Message" $loggingPrefix } catch { Write-EdenError "Error: $Message Message: '$($_.Exception.Message)'" $loggingPrefix throw } finally { if ($outFile) { Write-EdenInfo "Stopping transcript." $loggingPrefix Stop-Transcript | Write-Host } Set-Location $location } } |