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)
0

Hello,

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.

0

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

Scott,

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 (150 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, 2023 by JonnyBGood (20 points)
0 votes
1 answer

Is there any way to add a warning message when someone tries to add a group member that already is member? Checked config but found nothing related. Added a new member that ... the group and there is no warning, and the logs show that the task was completed.

asked Jul 9 by lramirez (20 points)
0 votes
1 answer

Using the powershell module, I know how to create a scheduled task, and also how to bind to a scheduled task that is already known. I also have used code to try creating ... same time as another. These are all one-time tasks and will be removed once executed.

asked Jan 19 by aweight (60 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)
3,589 questions
3,278 answers
8,303 comments
548,130 users