0 votes

Hello,

I try to update user properties per Powershell with "Custom commands".
Code below generates following error.

Operation is not valid due to the current state of the object.

Import-Module Adaxes

$identity = "%distinguishedName%"
$domain = $Context.GetObjectDomain("%distinguishedName%")

Set-AdmUser -Identity $identity -Server $domain -EmployeeID "A123456" -AdaxesService localhost

regards
Helmut

by (510 points)

1 Answer

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

Hello Helmut,

We would like to mention, that using the Set-AdmUser cmdlet is not the best way to update user properties. First of all, you can use the Update the User action in your Custom Command. If, you perform the update using a script, this can be easily done using the predefined $Context variable. For example, the following code sample sets the EmployeeID of the user on which the Custom Command is executed to A123456:

$Context.TargetObject.Put("employeeID", "A123456")
$Context.TargetObject.SetInfo()

As for the error message, it can occur because the Custom Command is executed in a Business Rule triggering Before Creating a User. If you execute a Custom Command with the provided script on an existing user, it should work just fine. If that is not how the command is executed, please, provide us with a detailed description of the workflow that includes the Custom Command and results into the error. Screenshots would be very helpful. You can post them here or send to our email support[at]adaxes.com.

0

Hello,

$Context.TargetObject.Put("employeeID", "A123456")  
$Context.TargetObject.SetInfo()  

works fine, thanks.

We have a multi-domain environment, and I get the error in all domans - even in the domain where the adaxes server resides.

With the code below in a normal Powershell-ISE, I get error message below.

$identity = "CN=Test User,OU=SMB,OU=Users,OU=AccAdm,OU=Admin,DC=acs,DC=local"
Get-AdmUser -Identity $identity -Server "acs.local" -AdaxesService localhost
Get-AdmUser : Unable to cast transparent proxy to type 'Softerra.Adaxes.Interop.Adsi.IADs'.  
At C:\\Admin\\Adaxes\\Tets.ps1:12 char:1  
+ Get-AdmUser -Identity $identity -Server "acs.local" -AdaxesService lo ...  
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
 + CategoryInfo : NotSpecified: (:) \[Get-AdmUser\], InvalidCastException  
 + FullyQualifiedErrorId : Softerra:Adaxes:PowerShellModule:Commands:GetAdmUserCommand:ProcessRecord,Softerra.Adaxes.PowerShellModule.Commands.GetAdmUserCommand  

regards Helmut

0

Hello,

works fine, thanks.

Thank you for the confirmation.

With the code below in a normal Powershell-ISE, I get error message below.

For troubleshooting purposes, navigate to folder C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Softerra.Adaxes.Adsi on the computer where you run the script and post here or send us (support[at]adaxes.com) a screenshot of the folder contents. Please, make sure that full names of folders are included. We need something like the following:

Also, please, check which folders located in the Softerra.Adaxes.Adsi folder contain files and provide us with the folder names (e.g. v4.0_3.9.15631.0__43a637781bd9a3c2).

Related questions

0 votes
1 answer

Trying to set the primary proxy when doing a name change on an email address.

asked Jul 13, 2023 by mightycabal (1.0k points)
0 votes
1 answer

I'm currently running a SQL SPROC from within powershell, getting a value, and attempting to assign that value to an AD attribute. Everything goes fine getting the value, but ... avoid calling PS from within PS to load the module and run the command. Thanks!

asked Feb 3, 2017 by gmadd13 (50 points)
0 votes
1 answer

Is Set-AdmUser supposed to trigger a User Update Business rule? I have a business rule that is supposed to run after a user is updated, but it doesnt appear that ... to Set-AdmUser, that it triggers the business rule afterwards. Is this working as intended?

asked Dec 12, 2014 by chazlander (120 points)
0 votes
1 answer

This is the logic I ham useing. $criteria = New-AdmCriteria -Type "User" -Expression {customAttributeBoolean6 -eq $true} $usersC = Get-AdmUser -Filter $criteria -properties * - ... there a better way to get the list of users into this variable? error;

asked Dec 14, 2023 by mightycabal (1.0k points)
0 votes
1 answer

Hi According to your SDK for Get-AdmUser, you can use criteria for filtering if the adaxes service is specified, can you please give an example of how this is done? I've tried ... is ObjectTypes {user} but I can't find a way to expand the results. Thanks Matt

asked Aug 10, 2023 by chappers77 (2.0k points)
3,589 questions
3,278 answers
8,303 comments
548,105 users