Powershell InvokeSet throws error

I’m working on User Admission RPA with AD account creation and I need to fill RDS path in AD profile like on picture


It is possible with powershell script, we’re using it already few years

$TerminalUser = [ADSI]("LDAP://"+$UserDN)

but when I try to run it from Studio it throws me error (InvokeGet throws same error)

Invoke Power Shell: Exception calling “InvokeSet” with “2” argument(s): “Unknown name. (Exception from HRESULT: 0x80020006 (DISP_E_UNKNOWNNAME))”

@lukas.macas : I’ve not done this using PowerShell commands. it is very easy to update such fields using UiPath activities. Refer this link and let me know if you need any help.

Thanks but this will not works for me.
As I wrote before, when I try to run my Powershell script in Studio it throws me error.

btw You don’t need to set account expiration via ps script.
For account expiration UiPath have activity Set User Expiration Date

@lukas.macas - for your problem statement, you can use “Update object properties” activities from UiPath.ActiveDirectoryDomainServices.activities (download from manage packages) ​and pass “scriptpath” as Single Property
Single property value = as per your requirement

Distinguished name = value from get object Distinguished name activity ( input is username defined in AD)

  1. Use Get Object Distinguished Name activity : Input = username, output = Distinguished name
  2. Use Update Object Properties: input = Distinguished name, single property = script path, single property value = value you want to update.

Try this and let me know if you are facing any issue.

This will not works because TerminalServicesProfilePath is not AD account attribute, because TerminalServicesProfilePath is saved in the Active Directory user object’s UserParameters attribute as a binary blob

I have little complicated solution but better than nothing.

In Studio I have activity StartProcess to run python script with path of powershell script and some inputs in arguments.


import subprocess
import sys

PSScript = sys.argv[1]
UserDN = sys.argv[2]
ProfilePath = sys.argv[3]

subprocess.Popen(r"powershell.exe "+PSScript+" -UserDN '"+UserDN+"' -ProfilePath '"+ProfilePath+"'", shell=True)


  [Parameter(Mandatory=$true)] [string]$UserDN,
  [Parameter(Mandatory=$true)] [string]$ProfilePath


Try {
  $TerminalUser = [ADSI]("LDAP://"+$UserDN)
} Catch { $(ForEach($item in $Error) { $Result += "`n" + $item.Exception.Message }) | Get-Unique }

If(-Not [string]::IsNullOrWhiteSpace($Result)) {
  Set-Clipboard "Failed to add Terminal Services Profile Path '$ProfilePath' for user path 'LDAP://$UserDN' with error $Result"
} Else {
  Set-Clipboard "success"