PowerShell ADSI查询导致0x80020006(DISP_E_UNKNOWNNAME))“

时间:2015-07-03 11:53:14

标签: .net powershell exception

下面的某些AD用户TS主目录的查询导致connection.Open();。我的代码出了什么问题?试图告诉我的这个例外是什么?

DotNetException

输出:

$userObject = Get-ADUser someUser -Properties *
$userObject.userParameters

$adsiObject = [adsi]"LDAP://$($userObject.DistinguishedName)"
$adsiObject.PSBase.InvokeGet("TerminalServicesHomeDirectory"); 

因此属性 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 存在并保存数据。

1 个答案:

答案 0 :(得分:2)

我自己想通了。未注册库tsuserex.dll,它提供导出以读取userParameters BLOB。

How to read msTSProfilePath, msTSHomeDrive and msTSHomeDirectory properties from AD (VB.NET)