IAdmScriptCondition

The IAdmScriptCondition interface represents the If PowerShell script returns true condition.

Inheritance: IAdmCondition

Methods

  • Method

  • Description

  • CanRunAs()

  • Validates whether the specified user credentials can be used to run the script.

  • RunAs()

  • Sets the credentials to run the script as.

Properties

  • Property

  • Description

  • ScriptDescription

  • Gets or sets a short description of the script.

  • Script

  • Gets or sets the text of the PowerShell script that will be executed by the condition.

  • RunAsUsername

  • Gets the username of the account used to launch the script.

  • PowerShellInstalled

  • Gets a value indicating whether Windows PowerShell is installed on the computer where the Adaxes service is running.

Details

CanRunAs()

Validates whether the specified user credentials can be used to run the script. If the credentials cannot be used, the method throws an exception.

void CanRunAs(string username, string password)

RunAs()

Sets the credentials to be used to run the script.

void RunAs(string username, string password)

Remarks

If both parameters are set to null, the script will be executed using the credentials of the Adaxes service account.


ScriptDescription

Gets or sets a short description of the script.

  • Type:
  • string
  • Access:
  • Read/Write

Script

Gets or sets the text of the PowerShell script that will be executed by the condition. You can use value references in the script text (e.g. %username%). Before executing the script, Adaxes will replace the value references with the corresponding property values of the directory object targeted by the script.

  • Type:
  • string
  • Access:
  • Read/Write

Examples

The following code sample creates a condition that returns true if the script returns true.

PowerShell
# The $actionSet variable refers to an action set in a
# business rule, custom command, or scheduled task.

# Create condition.
$condition = $actionSet.Conditions.CreateEx("adm-ScriptCondition")
$scriptCondition = $condition.GetCondition()
$scriptCondition.ScriptDescription = "My script"
$scriptCondition.Script = 
@"
$Context.ConditionIsMet = $Context.TargetObject.IsAccountLocked
"@

# Save changes.
$condition.SetCondition($operationResultCondition)
$condition.SetInfo()
$actionSet.Conditions.Add($condition)
C#
// The actionSet variable refers to an action set in a
// business rule, custom command, or scheduled task.

// Create condition.
IAdmBusinessRuleCondition condition = (IAdmBusinessRuleCondition)actionSet.Conditions.CreateEx(
    "adm-ScriptCondition");
IAdmScriptCondition scriptCondition = 
    (IAdmScriptCondition)condition.GetCondition();
scriptCondition.ScriptDescription = "My Script";
scriptCondition.Script = 
    "$Context.ConditionIsMet = $Context.TargetObject.IsAccountLocked";

// Save changes.
condition.SetCondition(operationResultCondition);
condition.SetInfo();
actionSet.Conditions.Add(condition);

RunAsUsername

Gets the username of the account that will run the script.

  • Type:
  • string
  • Access:
  • Read-only

PowerShellInstalled

Gets a value indicating whether Windows PowerShell is installed on the computer where the Adaxes service is running.

  • Type:
  • bool
  • Access:
  • Read-only

Requirements

Minimum required version: 2012.1

See also