0 votes

I am setting up a custom command to decomission users, part of the process before the AD groups are removed I want it to export a list of the groups to a network location. I can do it easily enough in powershell when specifying the user, but trying to use the %SAMAccountName% isn't working. Below is the small script I have so far to do it, can you please advise if anything is missing?

Import-Module Adaxes

$ADusername = "%SAMAccountName%"
$filedestinaton = "*file path*"

Get-admPrincipalGroupMembership $ADusername | select name | Export-Csv $filedestinaton-$ADusername.csv

I am currently getting an error "The command can be executed via an Adaxes service only." I have a security role which is allowed to run this custom command which I have added my account to, so i believe i have permission to run it.

by (400 points)


Can you provide details on how you execute the Custom Command? Do you run it manually (via the Web Interface or the Administration Console), or as a part of some other script, Custom Command, Business Rule or Scheduled Task? Is the command enabled or disabled? To check this, right-click the command and select Properties.


Right now it is it's own custom command as I wanted to just test the file logging part by itself. However I would like it to be part of a custom command that can be run manually via the web interface, and also part of a scheduled task that will run based on a users end date. While I have been testing I have been running it manually via the administration console by either the "run script" button inside the action, or by going through the "active directory" in adaxes and right clicking on the user I want to run it on -> "All tasks" -> Custom command. The command is currently enabled.

1 Answer

0 votes
by (216k points)
selected by
Best answer


The thing is that the Get-AdmPrincipalGroupMembership cmdlet can be executed via an Adaxes service only. Thus, you need to specify an adaxes service via the -AdaxesService parameter, for example:

Get-AdmPrincipalGroupMembership $ADusername -AdaxesService localhost | select name | Export-Csv $filedestinaton-$ADusername.csv

Related questions

0 votes
1 answer

We just busted our licence limit of 400, but we are only 320 employees. All the extras are either service accounts, external contractors accounts or old user accounts ... is reinstated on the 'managed accounts' list? Thank you for the guidance, Louis

asked Apr 11, 2022 by lw.fa (130 points)
0 votes
1 answer

Hello, Similar to exporting the members of a group to a csv file: https://www.adaxes.com/script-repository/export-group-members-to-csv-file-s184.htm I am looking to ... would like to include the memberof csv report in the email as well. Thanks in advance!

asked Feb 7 by JonnyBGood (20 points)
0 votes
0 answers

I am trying to find a way to create Groups based off an OU and a list of options (check boxes) within the portal For example: Select the Target OU to add groups ... 3 - Remote Administrators Option 3 - Remote Developers Option 4 - Readers Option 4 - Writers

asked Sep 11, 2020 by dknapp (100 points)
0 votes
1 answer

Currently, when I disable a user account in Adaxes, the group memberships of the user remain intact. I'd like to automate the removal of group memberships such as distribution ... a list of groups/DL that the user was previously in and removed from. Thanks!

asked Nov 3, 2021 by jayden.ang (20 points)
0 votes
1 answer

Is there a way to get the name of the user who approved a request and supply that to a step inside of a custom command? For example, HR submits a status change for an employee. ... and pass it as a param in a custom command that is called in one of the steps?

asked May 12, 2021 by davfount90 (20 points)
3,231 questions
2,932 answers
535,367 users