Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
workflow Invoke-AsWorkflow
{
<#
.EXTERNALHELP Microsoft.PowerShell.Workflow.ServiceCore.dll-help.xml
#>
[CmdletBinding(DefaultParameterSetName='Command', HelpUri='http://go.microsoft.com/fwlink/?LinkId=238267')]
param(
[Parameter(Mandatory=$true,ParameterSetName="Command")]
[ValidateNotNullOrEmpty()]
[String]$CommandName,
[Parameter(ParameterSetName="Command")]
[HashTable]$Parameter,
[Parameter(Mandatory=$true,ParameterSetName="Expression")]
[String]$Expression
)
if($CommandName)
{
if($Parameter)
{
InlineScript {& $using:CommandName @using:Parameter}
}
else
{
InlineScript {& $using:CommandName}
}
}
else
{
Invoke-Expression -Command $Expression
}
}
Export-ModuleMember -Function Invoke-AsWorkflow
# SIG # Begin signature block
# MIIXXAYJKoZIhvcNAQcCoIIXTTCCF0kCAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB
# gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR
# AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUzJaIaO3GcY2hTd2xEiigTV1b
# 2aWgghIxMIIEYDCCA0ygAwIBAgIKLqsR3FD/XJ3LwDAJBgUrDgMCHQUAMHAxKzAp
# BgNVBAsTIkNvcHlyaWdodCAoYykgMTk5NyBNaWNyb3NvZnQgQ29ycC4xHjAcBgNV
# BAsTFU1pY3Jvc29mdCBDb3Jwb3JhdGlvbjEhMB8GA1UEAxMYTWljcm9zb2Z0IFJv
# b3QgQXV0aG9yaXR5MB4XDTA3MDgyMjIyMzEwMloXDTEyMDgyNTA3MDAwMFoweTEL
# MAkGA1UEBhMCVVMxEzARBgNVBAgTCldhc2hpbmd0b24xEDAOBgNVBAcTB1JlZG1v
# bmQxHjAcBgNVBAoTFU1pY3Jvc29mdCBDb3Jwb3JhdGlvbjEjMCEGA1UEAxMaTWlj
# cm9zb2Z0IENvZGUgU2lnbmluZyBQ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uGt+tVuG0kZjjoRexkG1aVkiOn4KOKqoTASd1bX5wDv8qmSVVF3fg+Dw9D2ylr
# 8uy83cKYSI5/L21PvRNhlqv+hS6pjk+wCa0I+k9gODgf8IcdI6tu5EujjSZZROiY
# 9H4kS0S4emY/66/ubqw9Zs+cftbXgrzYxcGkiEv1ZUM=
# SIG # End signature block
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment