Invoke-PowerShellCode

Executes native PowerShell code within a PPB script so that the start, end, and result of the code block is logged in the package's log file.


Settings:

  • Command
    Select the cmdlet to execute from the drop-down list. You can also narrow down the set of displayed commands by typing parts of the cmdlet you are looking for. Optionally, you can specify additional arguments or use the "..." button to open a generic dialog for the command and specify the required parameters there.
  • Script
    If you want to run more than one PowerShell command, enable the Script radio button and enter your desired code in the text box. You can also enlarge the entire dialog to have more screen estate to enter and review your code.
  • Log as
    Specifies the name under which the executing command or code block is logged in the log file.
  • Result variable
    Name of a variable in which the result of the code is stored.


The same command settings can optionally be specified in the "Uninstalling" tab of the command dialog. If anything is entered there, the corresponding code will be executed as part of the uninstallation of a package containing that command.


Example:

The following example uses the Get-Service cmdlet to get the service with the display name "Windows Update" and stores the object in the _ReturnCode variable. The code is logged in the logfile under the name "Get-WindowsUpdate-Service".


Corresponds to DSM eScript command:

  • ---


See also: