AD Lookup employeeType property issue

claires74644296
Tera Contributor

Hi all,

 

Just wanted to know if anyone else has experienced something similar? I'm trying to update the employeeType property in AD. I've copied the update user action and script, all other properties are updating fine. I'm not coming across any errors when testing the action, but I've been advised by the AD side that it is definitely not updating.

 

I've done a lookup action on the test user to see what that brings back. When I bring back all properties 'employeeType' doesn't exist in the response. When I lookup just the employeeType property (it doesn't say it's invalid), it just brings back an empty array i.e. {}. Not even {"employeeType":""}. 

 

I've not done powershell or customised AD scripts before so I'm guessing I'm missing something simple. Or at least hoping so! If anyone could point me in the right direction I would appreciate it! 

 

This is the relevant section of script:

 

if($Grade){
$Grade = $Grade -replace "%27","'";
$user.employeeType = $Grade;
}

$result = Set-ADUser -Instance $user -Credential $cred -Server $computer;

1 ACCEPTED SOLUTION

J Siva
Tera Sage

Hi @claires74644296 

Try the below script. I just tested out and it's working as expected.

if (test-path env:\SNC_employeeType) {
    $type = $env:SNC_employeeType;
    $sam = $env:SNC_user;
}

Set-ADUser -Identity $sam -Replace @{EmployeeType = $type} -Credential $cred -Server $computer

Flow action:

JSiva_0-1743599218728.png

Regards,
Siva

View solution in original post

4 REPLIES 4

J Siva
Tera Sage

Hi @claires74644296 
Just try the below script. It'll work.

if($Grade){
$Grade = $Grade -replace "%27","'";
$employeeType = $Grade;
}

$result = Set-ADUser -Instance $user -Replace @{employeeType=$employeeType} -Credential $cred -Server $computer 

 

Hope this helps.
Regards,
Siva

Thanks for the help Siva, unfortunately that method doesn't work either. I keep getting this error message when I try that way:

 

An attempt was made to add an object to the directory with a name that is already in use

 

Which is odd seeing as I'm using Replace and not Add 

Let me test it out in my pdi and give you the exact powershell cmdlet

J Siva
Tera Sage

Hi @claires74644296 

Try the below script. I just tested out and it's working as expected.

if (test-path env:\SNC_employeeType) {
    $type = $env:SNC_employeeType;
    $sam = $env:SNC_user;
}

Set-ADUser -Identity $sam -Replace @{EmployeeType = $type} -Credential $cred -Server $computer

Flow action:

JSiva_0-1743599218728.png

Regards,
Siva