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:
Things that have NOT worked:
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.
User contributions licensed under CC BY-SA 3.0