The query for some AD users TS Home Directory below, leads to an DotNetException
. What is wrong with my code? And what is this exception trying to tell me?
$userObject = Get-ADUser someUser -Properties *
$userObject.userParameters
$adsiObject = [adsi]"LDAP://$($userObject.DistinguishedName)"
$adsiObject.PSBase.InvokeGet("TerminalServicesHomeDirectory");
Output:
PCtxCfgPresent㔵攱戰ぢCtxCfgFlags1〰て〲〹CtxCallback〰〰〰〰CtxShadow㌰〰〰〰(CtxMaxConnectionTime〰〰〰〰.CtxMaxDisconnectionTime〰〰〰〰CtxMaxIdleTime〰〰〰〰"CtxKeyboardLayout〰〰〰〰*CtxMinEncryptionLevel
CtxWorkDirectory〰 CtxNWLogonServer〰CtxWFHomeDir〰"CtxWFHomeDirDrive〰 CtxWFProfilePath〰"CtxInitialProgram〰"CtxCallbackNumber〰
Exception calling "InvokeGet" with "1" argument(s): "Unknown name. (Exception from HRESULT: 0x80020006 (DISP_E_UNKNOWNNAME))"
At D:\SourceCode\PowerShell\Get-ADTSProperties.ps1:125 char:1
+ $adsiObject.PSBase.InvokeGet("TerminalServicesHomeDirectory");
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
So the attribute userParameters
is there and holds data.
I figured it out by myself. The library tsuserex.dll
was not registered which provides exports to read the userParameters
BLOB.
How to read msTSProfilePath, msTSHomeDrive and msTSHomeDirectory properties from AD (VB.NET)
User contributions licensed under CC BY-SA 3.0