0 votes

We've the following script we want to use in Adaxes to create as part of user creation, to ask if the user will need a AWS workspace, then asks employeetype for different WS directory, and then computetype to create workspace.

How can I include this as a form based checkmarks or drop-down menus selectable by our helpdesk, the script works when I test it on the Adaxes host-

 param(
     [Parameter(Mandatory=$true)]
     [string]$userName,

     [Parameter(Mandatory=$true)]
     [ValidateSet('Contractor','Salary')]
     [string]$employeeType,

     [Parameter(Mandatory=$true)]
     [ValidateSet('Power','PowerPro')]
     [string]$computeType

 )
$Creds = (Use-STSRole -RoleArn "arn:aws:iam::*******424:role/ws_adaxes" -RoleSessionName adaxes).Credentials

if ( $employeeType -like 'Employee' )
{
    $directoryId = 'd-*******07a'
} elseif ($employeeType -like 'Contractor')
{
    $directoryId = 'd-******d2'
}

if ( $computeType -like 'Power' )
{
    $bundleId = 'wsb-drh4m5c2r'
} elseif ($computeType -like 'PowerPro')
{
    $bundleId = 'wsb-f5g1109b5'
}

$newWorkspaceOut = New-WKSWorkspace -Workspace @{"BundleID" = "$bundleId"; "DirectoryId" = "$directoryId"; "UserName" = "$userName"; "RootVolumeEncryptionEnabled" = $TRUE; "UserVolumeEncryptionEnabled" = $TRUE; "VolumeEncryptionKey"= "alias/aws/workspaces"; "WorkspaceProperties"=@{"RunningMode"="AUTO_STOP"}} -Credential $creds

if($newWorkspaceOut.FailedRequests)
{
   $Context.LogMessage("Failed to create workspace.", "Error")
   $Context.LogMessage($newWorkspaceOut.FailedRequests.errorMessage, "Error")
   exit(-1)
}
else
{
  $Context.LogMessage("Created workspace", "Information")
}
by (20 points)

1 Answer

0 votes
by (294k points)

Hello,

It can only be done using properties on the user creation form. The following tutorial should be helpful: https://www.adaxes.com/help/CustomizeFormsForUserCreationAndEditing. For example, you can use Adaxes custom attributes (e.g. CustomAttribtueText1, CustomAttribtueBoolean1, etc.). They work similar to AD ones in Adaxes and are not available outside the software. Your script can then be executed in a business rule triggering After creating a user. To obtain the attribute values in the script, you can use value references.

0

This script was just an example, I've other PS scripts that accepts parameters which would looks like this - \script.ps1 -parameter1 value -parameter2 value

Is there better article with screenshots how we can relate parameters between PS script and Adaxes, and not necessarily a AD property or parameter?

Thanks!

0

Hello,

Unfortunately, there are no such articles. At the same time, whenever it is not a custom command parameter and not a custom command parameter value it is something custom requested externally. In such cases the approaches used in Windows PowerShell should work just fine in Adaxes scripts.

Related questions

0 votes
1 answer

We have several scripts that use the following action: $commandID = "{b4b66610-be71-403a-a6b7-8bcf51d200ef}" $user.executecustomCommand($commandID) is there syntax that allows ... is there another way to pass parameters to a custom command through scripting?

asked Jul 11, 2019 by ggallaway (300 points)
0 votes
1 answer

I have a number of custom Powershell scripts that add users to Teams, groups, etc. I re-use these scripts dozens of times for different conditions and only change one ... possible to convert this script to a custom command and pass parameters to it instead?

asked 5 days ago by cwyant-hfg (40 points)
0 votes
1 answer

Hello, I'm trying to execute a custom command through a Powershell script, but I'm struggling to pass multiple values to an AD Object Picker parameter. ... , $NULL, $NULL, 0) $obj.ExecuteCustomCommand($command.CommandID, $commandArguments) Thanks in advance!

asked Nov 24, 2021 by KelseaIT (320 points)
0 votes
1 answer

Hi, I followed this example: https://www.adaxes.com/sdk/IAdmTop6.html, but because the Custom Command is disabled, I get the following error message: System.Management.Automation ... if I enable the Custom Command. I am using Adaxes 2018.2 Best Regards Martin

asked Feb 19, 2020 by Martin (150 points)
0 votes
1 answer

Is there a way to configure a Custom Command parameter to accept multiple values so I can then add them to a multi value attribute such as adm-CustomAttributeObjectMultiValue1 ... in my specific case I'm looking to use a directory object picker parameter

asked Nov 27 by AM (50 points)
3,588 questions
3,277 answers
8,303 comments
548,086 users