Public/New-ExecutionStep.ps1

function New-ExecutionStep {
  [CmdletBinding()]
  param (
    [Parameter(Mandatory = $true)]
    [Alias('StepDescription')]
    [ValidateNotNullOrEmpty()]
    [string]$Description,

    [Parameter(Mandatory = $true)]
    [ValidateNotNull()]
    [scriptblock]$ExecutionAction,

    [Parameter(Mandatory = $false)]
    [scriptblock]$Precondition,
    
    [Parameter(Mandatory = $true)]
    [Alias('ErrorMsg')]
    [ValidateNotNullOrEmpty()]
    [string]$ErrorMessage,
    
    [Parameter(Mandatory = $false)]
    [switch]$TerminalError,
    
    [Parameter(Mandatory = $false)]
    [scriptblock]$RecoverAction
  )

  $ExecutionStep = [ExecutionStep]::new()
  
  $ExecutionStep.Description = $Description
  $ExecutionStep.ExecutionAction = $ExecutionAction
  $ExecutionStep.Precondition = $Precondition
  $ExecutionStep.ErrorMessage = $ErrorMessage
  $ExecutionStep.RecoverAction = $RecoverAction
  $ExecutionStep.TerminalError = $TerminalError.IsPresent

  return $ExecutionStep
}
# SIG # Begin signature block
# MIIPFwYJKoZIhvcNAQcCoIIPCDCCDwQCAQExDzANBglghkgBZQMEAgEFADB5Bgor
# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG
# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCBuwXdOSuQeVh8W
# P4qTqpqWdN6ja+YotdO4/qX81PDZpaCCDBQwggXqMIIE0qADAgECAhBb43g/0Jux
# +D5VsO4a+HT+MA0GCSqGSIb3DQEBCwUAMIGRMQswCQYDVQQGEwJHQjEbMBkGA1UE
# CBMSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHEwdTYWxmb3JkMRowGAYDVQQK
# ExFDT01PRE8gQ0EgTGltaXRlZDE3MDUGA1UEAxMuQ09NT0RPIFJTQSBFeHRlbmRl
# ZCBWYWxpZGF0aW9uIENvZGUgU2lnbmluZyBDQTAeFw0yMTAxMjcwMDAwMD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