Invoke-PSExpression.ps1
<#PSScriptInfo
.VERSION 1.0 .GUID 4d9af509-ec3f-44c6-b2af-9a9306642b7a .AUTHOR Azure Automation Team .COMPANYNAME Microsoft .COPYRIGHT .TAGS Azure Automation .LICENSEURI .PROJECTURI .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS .EXTERNALSCRIPTDEPENDENCIES .RELEASENOTES #> <# .SYNOPSIS Invokes a PowerShell expression, typically a PowerShell command. .DESCRIPTION This runbook will invoke a PowerShell expression using the PowerShell Invoke-Expression cmdlet. In Azure Automation, this runbook is useful for running a PowerShell command on a hybrid runbook worker. .PARAMETER Expession Required The string that has the name of the PowerShell command to run plus any parameters .EXAMPLE .\Invoke-PSExpression -Expression "Get-Process -ComputerName localhost -Name lsass -Verbose" .NOTES AUTHOR: Azure Automation Team LASTEDIT: 2016-11-8 #> # Returns whatever object(s) the invoked command returns [OutputType([object])] param ( [Parameter(Mandatory=$true)] [string] $Expression ) Invoke-Expression $Expression |