Starting with CloudPanel 3.2.302.0 you can now execute your own powershell scripts after certain actions such as adding a new company, adding a new user or even deleting a user. This is done by reading a certain powershell script located in the C:\Program Files (x86)\Know More IT\CloudPanel\Content\powershell directory.
This feature also allows you to pass certain variables from CloudPanel to the powershell script. Each action may contain different variables that are valid only for that action.
CloudPanel currently has five actions that are available to execute a custom powershell script after:
The following parameters are available but some may not be available for all actions:
CloudPanel will read your powershell script and inject the parameters listed below. The parameters are case sensitive and do not have to be used if you don’t want to.
If a powershell script fails, then CloudPanel will revert the changes it made but NOT the changes your powershell script made. For example if you create a new company and the script fails, then CloudPanel will clean up and remove the company it just created but the actions by your custom powershell script will remain.
Below are blank example scripts showing how you can use parameters from CloudPanel when it gets executed.
This is triggered each time a new company is created. Available parameters:
Variable | Description |
---|---|
$CompanyCode | The unique code for the new company you just created |
$CompanyName | The company name of the company you just created |
$CompanyDistinguishedName | The distinguished name of the company in Active Directory |
$DomainName | The domain name used when creating the company |
$Reference | The value from the reference field |
[CmdletBinding()]
Param (
[Parameter(Mandatory=$true)]
[string]$CompanyCode,
[Parameter(Mandatory=$false)]
[string]$CompanyName,
[Parameter(Mandatory=$false)]
[string]$CompanyDistinguishedName,
[Parameter(Mandatory=$false)]
[string]$Reference,
[Parameter(Mandatory=$true)]
[string]$DomainName,
)
This is triggered each time a company is updated or deleted. Available parameters:
Variable | Description |
---|---|
$CompanyCode | The unique code for the new company you just created |
$CompanyName | The company name of the company you just created |
$CompanyDistinguishedName | The distinguished name of the company in Active Directory |
$Reference | The value from the reference field |
[CmdletBinding()]
Param (
[Parameter(Mandatory=$true)]
[string]$CompanyCode,
[Parameter(Mandatory=$false)]
[string]$CompanyName,
[Parameter(Mandatory=$false)]
[string]$CompanyDistinguishedName,
[Parameter(Mandatory=$false)]
[string]$Reference
)
This is triggered each time a user is added. Available parameters:
Variable | Description |
---|---|
$CompanyCode | The unique code for the new company you just created |
$CompanyName | The company name of the company you just created |
$CompanyDistinguishedName | The distinguished name of the company in Active Directory |
$Reference | The value from the reference field |
$UserPrincipalName | The new user’s UserPrincipalName |
$SamAccountName | The new user’s sAMAccountName |
$UserDistinguishedName | The new user’s distinguished name |
$FirstName | The new user’s first name |
$LastName | The new user’s last name |
$DisplayName | The new user’s display name |
$Password | The new user’s password |
[CmdletBinding()]
Param (
[Parameter(Mandatory=$true)]
[string]$CompanyCode,
[Parameter(Mandatory=$false)]
[string]$CompanyName,
[Parameter(Mandatory=$false)]
[string]$CompanyDistinguishedName,
[Parameter(Mandatory=$false)]
[string]$Reference,
[Parameter(Mandatory=$true)]
[string]$UserPrincipalName,
[Parameter(Mandatory=$true)]
[string]$SamAccountName,
[Parameter(Mandatory=$false)]
[string]$UserDistinguishedName,
[Parameter(Mandatory=$false)]
[string]$FirstName,
[Parameter(Mandatory=$false)]
[string]$LastName,
[Parameter(Mandatory=$false)]
[string]$DisplayName,
[Parameter(Mandatory=$false)]
[System.Management.Automation.PSCredential]$Password
)
This is triggered each time a user is deleted. Available parameters:
Variable | Description |
---|---|
$CompanyCode | The unique code for the new company you just created |
$UserPrincipalName | The new user’s UserPrincipalName |
$SamAccountName | The new user’s sAMAccountName |
$UserDistinguishedName | The new user’s distinguished name |
[CmdletBinding()]
Param (
[Parameter(Mandatory=$true)]
[string]$CompanyCode,
[Parameter(Mandatory=$true)]
[string]$UserPrincipalName,
[Parameter(Mandatory=$true)]
[string]$SamAccountName,
[Parameter(Mandatory=$false)]
[string]$UserDistinguishedName
)
This is triggered each time a user's password is changed. Available parameters:
Variable | Description |
---|---|
$CompanyCode | The unique code for the company |
$CompanyName | The name of the company |
$Reference | The reference for the company |
$UserGuid | The user’s GUID in Active Directory |
$UserPrincipalName | The user’s UserPrincipalName |
$SamAccountName | The user’s sAMAccountName |
$UserDistinguishedName | The user’s distinguished name |
$FirstName | The user’s first name |
$LastName | The user’s last name |
$DisplayName | The user’s display name |
$Password | The new password that was just set |
[CmdletBinding()]
Param (
[Parameter(Mandatory=$true)]
[string]$CompanyCode,
[Parameter(Mandatory=$false)]
[string]$CompanyName,
[Parameter(Mandatory=$false)]
[string]$CompanyDistinguishedName,
[Parameter(Mandatory=$false)]
[string]$Reference,
[Parameter(Mandatory=$true)]
[string]$UserPrincipalName,
[Parameter(Mandatory=$true)]
[string]$SamAccountName,
[Parameter(Mandatory=$false)]
[string]$UserDistinguishedName,
[Parameter(Mandatory=$false)]
[string]$FirstName,
[Parameter(Mandatory=$false)]
[string]$LastName,
[Parameter(Mandatory=$false)]
[string]$DisplayName,
[Parameter(Mandatory=$false)]
[System.Management.Automation.PSCredential]$Password
)