< Back

Invoke-JCCommand

Thu Jan 16, 2020 9:02 am

NAME Invoke-JCCommand



SYNOPSIS

Triggers a JumpCloud Command to run by calling the trigger associated with the Command.





SYNTAX

Invoke-JCCommand [-trigger] <System.String> [-NumberOfVariables <System.Int32>] -Variable1_name <System.String>

-Variable1_value <System.String> -Variable2_name <System.String> -Variable2_value <System.String>

[<CommonParameters>]





DESCRIPTION

In order to use the Invoke-JCCommand the target JumpCloud command must have the Launch Event set to Event type:

'Run on Trigger (webhook)' within the JumpCloud admin console. When a JumpCloud command is set with this value the

'launchType' which is queryable using the command Get-JCCommand will be set to 'trigger'.





PARAMETERS

-NumberOfVariables <System.Int32>

Denotes the number of variables you wish to send to the JumpCloud command. This parameter creates two dynamic

parameters for each variable added. -Variable_1Name = the variable name -Variable1_Value = the value to pass.

See EXAMPLE 2 above for full syntax.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Variable1_name <System.String>

Enter a variable name



Required? true

Position? named

Default value None

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-Variable1_value <System.String>

Enter the Variables value



Required? true

Position? named

Default value None

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-Variable2_name <System.String>

Enter a variable name



Required? true

Position? named

Default value None

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-Variable2_value <System.String>

Enter the Variables value



Required? true

Position? named

Default value None

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-trigger <System.String>

When creating a JumpCloud command that can be run via the Invoke-JCCommand function the command must be

configured for 'Launch Event - Event type: Run on Trigger (webhook)' During command configuration a 'Trigger

Name' is required. The value of this trigger name is what must be populated when using the Invoke-JCCommand

function. To find all JumpCloud Command triggers run: PS C:\\> Get-JCCommand | Where-Object launchType -EQ

'trigger' | Select-Object name, trigger



You can leverage the pipeline and Parameter Binding to populate the -trigger Parameter. This is shown in

EXAMPLES 2 and 3.



Required? true

Position? 0

Default value None

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS

System.String







OUTPUTS

System.Object







NOTES









-------------------------- Example 1 --------------------------



Invoke-JCCommand -trigger 'GetJCAgentLog'



Runs the command with a trigger of 'GetJCAgentLog' on all associated systems associated with this JumpCloud

command.

-------------------------- Example 2 --------------------------



Invoke-JCCommand -trigger 'InstallApp' -NumberOfVariables 1 -Variable1_name 'URL' -Variable1_value

'www.pathtoinstallfile.com'



Runs the command with a trigger of 'GetJCAgentLog' and passes the variable 'URL' with value

'www.pathtoinstallfile.com' to the JumpCloud command.

-------------------------- Example 3 --------------------------



Get-JCCommand | Where-Object launchType -EQ 'trigger' | Invoke-JCCommand



Runs all JumpCloud commands that can be run by the Invoke-JCCommand by passing the -Trigger Parameter over the

pipeline using Parameter Binding.

-------------------------- Example 4 --------------------------



Get-JCCommand | Where-Object trigger -Like '*NewMacInstall*' | Invoke-JCCommand



Runs all JumpCloud commands with a trigger that matches the expression -like ' NewMacInstall '. Use this Example

to run multiple commands that have a common trigger naming convention.



RELATED LINKS

Online Version: https://github.com/TheJumpCloud/support ... -JCCommand