Jump to content
Sign in to follow this  

Pass parameters from LT script to Powershell script

Recommended Posts

Is it possible for me to pass parameters from a LT script to a powershell script? For example, if I had a powershell script that uses Connect-MsolService would there be a way to to enter email/password into LT parameters so they are passed to the powershell script after Connect-MsolService runs?

Share this post

Link to post
Share on other sites

Within your Automate script, use Execute Script, set to Powershell (Powershell Bypass if required,) and then click the square box to the right of the script entry field.  This pops up a larger window where you can paste your Powershell code.

In THIS area, all normal Automate script variables, can be dropped directly into your Powershell code.  It'll expand everything at run time.

Works pretty slick.

Share this post

Link to post
Share on other sites

Function: Execute Script
Script Type: PowerShell Bypass
Script Credentials: Run as Local Agent

in the Script to Execute, this is what I use to convert Automate Variables into PowerShell Variables; in this case PSCredentials:

$CredUser = '%computeruserdomain%'
$CredPass = '%computerpassword%'
$CredPassword = $CredPass | ConvertTo-SecureString -asPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential($CredUser,$CredPassword)

and then use them like you would with any PSCredential:
...} -Credential $Credential

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this