Exception calling "InvokeSet" with "2" argument(s): "Unknown error (0x80005000)"

0

I've scoured the entire first 3 pages of google for this with no help that has worked

I'm trying to remotely update the Home and profile location in the Remote Desktop Services tab in Active Directory Users and Computers.

Here's my code:

Invoke-Command -ComputerName $DomainController -Credential $Credentials -ScriptBlock{   
    $User = [ADSI] "LDAP://CN=Paul Beenis,OU=Staff,DC=domain,DC=local"
    $User.psbase.Invokeset("TerminalServicesProfilePath","\\server\_Profile\pbeenis")
    $user.psbase.InvokeSet("TerminalServicesHomeDrive", "P:")
    $User.psbase.Invokeset("TerminalServicesHomeDirectory","\\server\_Home\pbeenis")
    $User.setinfo()
}

Here is the exception:

Exception calling "InvokeSet" with "2" argument(s): "Unknown error (0x80005000)"
+ CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
+ PSComputerName        : DC03

Exception calling "InvokeSet" with "2" argument(s): "Unknown error (0x80005000)"
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException
    + PSComputerName        : DC03

Exception calling "InvokeSet" with "2" argument(s): "Unknown error (0x80005000)"
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException
    + PSComputerName        : DC03

The following exception occurred while retrieving member "setinfo": "Unknown error (0x80005000)"
    + CategoryInfo          : NotSpecified: (:) [], ExtendedTypeSystemException
    + FullyQualifiedErrorId : CatchFromBaseGetMember
    + PSComputerName        : DC03

Things that have worked:

  • RDP into $DomainController and entering the commands into a local Powershell session
  • Briefly using Enter-PSsession in the middle of my script, sending the 4 commands, the exit-pssession. However, this is unreliable and doesn't seem to work more than 1 time.

Things that have NOT worked:

  • Suggestions on google tell you to copy tsuserex.dll and tsuserex.dll.mui from a windows 2012 server, paste it into your c:\windows\system32 and c:\windows\system32\en-us (respectively), then use regsvr32 command to register the DLL. This DID NOT work, I tried this with 3 different servers.
powershell
active-directory
asked on Stack Overflow Sep 13, 2018 by Dylan Grove

1 Answer

1

The answer to this problem is that I'm an idiot.

This code is correct

$User = [ADSI] "LDAP://$using:FullUserPath"
$User.psbase.Invokeset("TerminalServicesProfilePath","$using:ProfileLocation")
$user.psbase.InvokeSet("TerminalServicesHomeDrive", "$using:HomeDrive")
$User.psbase.invokeset("TerminalServicesHomeDirectory","$using:HomeLocation")
$User.setinfo()

However, my variables were incorrect (Which no one could have known by looking that this question.) I was assigning $FullUserPath before $DisplayName

$FullUserPath        = "CN=$DisplayName,$UserPath"
$DisplayName         = ($FirstName+" "+$LastName).ToString()

If you are receiving this error and you have followed the steps in my question under "Things that have NOT Worked" This means your variables were incorrect. Do a write-host on all of your variables and ensure they are good

Shoutout to @Jordan for pointing out that my variables could be wrong.

answered on Stack Overflow Sep 14, 2018 by Dylan Grove

User contributions licensed under CC BY-SA 3.0