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 (279k 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

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 (100 points)
0 votes
1 answer

I would like to know if it is possible to create a field in the web UI under user management to "assign" a machine to a user. I would like to be able to put the ... be moved to "workstation OU. Is there s custome field that can be used to accomplish this?

asked Oct 22, 2020 by copatterson (70 points)
0 votes
1 answer

Dear support, I'm trying to automate network share creations via custom commands. They idea is to create share and groups with command A and schedule ... "ADS_SCOPE_BASE" $scopeItem.Exclude = $False $scopeItem.SetInfo() $task.ActivityScopeItems.Add($scopeItem)

asked Jan 27, 2020 by Dmytro.Rudyi (920 points)
3,434 questions
3,130 answers
7,984 comments
546,323 users