AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 598166
Accepted
HopelessN00b
HopelessN00b
Asked: 2014-05-24 09:57:10 +0800 CST2014-05-24 09:57:10 +0800 CST 2014-05-24 09:57:10 +0800 CST

如何删除这个孤立的 Active Directory 计算机对象(最好使用 PowerShell)?

  • 772

我正在使用 PowerShell v2.0 的 Windows 7 工作站工作,并尝试从启用Active Directory 回收站LostAndFound的 2008 R2 FL 林和域中的容器中删除特定(孤立的?)对象,但没有运气用任何东西。

重要的是,我需要删除这个对象,并且只删除这个对象(而不是删除具有该IsDeleted属性的每个对象,这似乎是我能找到的所有帮助)。

我需要删除它,因为为了解决破坏的信任关系,计算机与域脱节(可能导致对象进入回收站,然后进入LostAndFound容器),我们想给它其原始名称(基于 PC 上的资产标签号)。尝试使用正确名称将计算机重新加入域失败,并显示以下错误消息 ( The specified account does not exist)

在此处输入图像描述

并尝试将其重命名为正确的名称,一旦它已经在域中失败,并显示以下错误消息 ( The account already exists)

在此处输入图像描述

所以实际的 PC 目前正以不正确的名称坐在那里,我需要更正。

但是,尝试删除此 AD 对象会产生错误:The specified account does not exist. 对象的专有名称中有一个\(反斜杠)字符,我认为这是由于它在LostAndFound容器中,我想知道这是否是问题......以及如何解决它。我正在运行我的 shell domain admin,验证了该domain admins组对相关对象具有完全控制和所有权,但似乎无法弄清楚这一点。

有问题的对象(有些编辑):

Get-ADObject "CN=SomeComputer\0ADEL:90a13eaa-c7b0-4258-bebb-87b7aed39ec6,CN=LostAndFound,DC=MyEmployer,DC=prv" -IncludeDeletedObjects -Properties *

accountExpires                  : 9223372036854775807
CanonicalName                   : MyEmployer.prv/LostAndFound/SomeComputer
                                  DEL:90a13eaa-c7b0-4258-bebb-87b7aed39ec6
CN                              : SomeComputer
                                  DEL:90a13eaa-c7b0-4258-bebb-87b7aed39ec6
codePage                        : 0
countryCode                     : 0
Created                         : 12/7/2012 9:25:30 PM
createTimeStamp                 : 12/7/2012 9:25:30 PM
Deleted                         :
Description                     : HP6300
DisplayName                     :
DistinguishedName               : CN=SomeComputer\0ADEL:90a13eaa-c7b0-4258-bebb-87b7aed39ec6,CN=LostAndFound,DC=MyEmployer,DC=
                                  prv
dNSHostName                     : SomeComputer.MyEmployer.prv
dSCorePropagationData           : {5/21/2014 1:40:31 PM, 12/31/1600 7:00:00 PM}
instanceType                    : 4
isCriticalSystemObject          : False
isDeleted                       :
LastKnownParent                 : OU=Workstations,OU=Computers,OU=One of Our Sites,DC=MyEmployer,DC=prv
lastLogonTimestamp              : 130451668084269817
localPolicyFlags                : 0
memberOf                        : {CN=PCMilerComputers,DC=MyEmployer,DC=prv}
Modified                        : 5/21/2014 1:40:54 PM
modifyTimeStamp                 : 5/21/2014 1:40:54 PM
msDS-LastKnownRDN               : SomeComputer
Name                            : SomeComputer
                                  DEL:90a13eaa-c7b0-4258-bebb-87b7aed39ec6
nTSecurityDescriptor            : System.DirectoryServices.ActiveDirectorySecurity
ObjectCategory                  :
ObjectClass                     : computer
ObjectGUID                      : 90a13eaa-c7b0-4258-bebb-87b7aed39ec6
objectSid                       : S-1-5-21-1708945318-605057401-313073093-5882480
operatingSystem                 : Windows 7 Enterprise
operatingSystemServicePack      : Service Pack 1
operatingSystemVersion          : 6.1 (7601)
primaryGroupID                  : 515
ProtectedFromAccidentalDeletion : False
pwdLastSet                      : 130451667147545072
sAMAccountName                  : SomeComputer$
sDRightsEffective               : 15
servicePrincipalName            : {HOST/SomeComputer, HOST/SomeComputer.MyEmployer.prv}
userAccountControl              : 4096
userCertificate                 : [Not included]
uSNChanged                      : 54007434
uSNCreated                      : 5004556
whenChanged                     : 5/21/2014 1:40:44 PM
whenCreated                     : 12/7/2012 9:25:30 PM

我尝试过的任何东西似乎都不起作用,而且我尝试了很多。在那张纸条上,我在下面尝试过。

首先,使用简单的单行 PowerShell cmdlet:


Get-ADObject "CN=SomeComputer\0ADEL:90a13eaa-c7b0-4258-bebb-87b7aed39ec6,CN=LostAndFound,DC=MyEmployer,DC=prv" -IncludeDeletedObjects | Remove-ADObject

Confirm
Are you sure you want to perform this action?
Performing operation "Remove" on Target
"CN=SomeComputer\0ADEL:90a13eaa-c7b0-4258-bebb-87b7aed39ec6,CN=LostAndFound,DC=MyEmployer,DC=prv".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): y
Remove-ADObject : The specified account does not exist
At line:1 char:145
+ Get-ADObject "CN=SomeComputer\0ADEL:90a13eaa-c7b0-4258-bebb-87b7aed39ec6,CN=LostAndFound,DC=MyEmployer,DC=prv" -IncludeDeletedObjects | Remove-ADObject <<<<
    + CategoryInfo          : NotSpecified: (CN=SomeComputer\0ADE...MyEmployer,DC=prv:ADObject) [Remove-ADObject], ADException
    + FullyQualifiedErrorId : The specified account does not exist,Microsoft.ActiveDirectory.Management.Commands.RemoveADObject

然后,同样的事情,而是引用 GUID。


Get-ADObject "90a13eaa-c7b0-4258-bebb-87b7aed39ec6"  -IncludeDeletdObjects | Remove-ADObject

Confirm
Are you sure you want to perform this action?
Performing operation "Remove" on Target
"CN=SomeComputer\0ADEL:90a13eaa-c7b0-4258-bebb-87b7aed39ec6,CN=LostAndFound,DC=MyEmployer,DC=prv".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): y
Remove-ADObject : The specified account does not exist
At line:1 char:94
+ Get-ADObject "90a13eaa-c7b0-4258-bebb-87b7aed39ec6"  -IncludeDeletedObjects | Remove-ADObject <<<<
    + CategoryInfo          : NotSpecified: (CN=SomeComputer\0ADE...MyEmployer,DC=prv:ADObject) [Remove-ADObject], ADException
    + FullyQualifiedErrorId : The specified account does not exist,Microsoft.ActiveDirectory.Management.Commands.RemoveADObject

然后,首先将值读入变量。(尝试同时使用 GUID 和 DN,只显示一个,因为它们产生相同的错误)。


$blah = "90a13eaa-c7b0-4258-bebb-87b7aed39ec6"
Get-ADObject $blah -IncludeDeletedObjects | Remove-ADObject

Confirm
Are you sure you want to perform this action?
Performing operation "Remove" on Target
"CN=SomeComputer\0ADEL:90a13eaa-c7b0-4258-bebb-87b7aed39ec6,CN=LostAndFound,DC=MyEmployer,DC=prv".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): y
Remove-ADObject : The specified account does not exist
At line:1 char:60
+ Get-ADObject $blah -IncludeDeletedObjects | Remove-ADObject <<<<
    + CategoryInfo          : NotSpecified: (CN=SomeComputer\0ADE...MyEmployer,DC=prv:ADObject) [Remove-ADObject], ADException
    + FullyQualifiedErrorId : The specified account does not exist,Microsoft.ActiveDirectory.Management.Commands.RemoveADObject

然后我想我可以忍受不得不调用 DSRM而不是本地调用它。


dsrm "CN=SomeComputer\0ADEL:90a13eaa-c7b0-4258-bebb-87b7aed39ec6,CN=Lost
AndFound,DC=MyEmployer,DC=prv"

Are you sure you wish to delete CN=SomeComputer\0ADEL:90a13eaa-c7b0-4258-bebb-87b7aed39ec6,CN=LostAndFound,DC=MyEmployer,DC=prv
 (Y/N)? y
dsrm failed:CN=SomeComputer\0ADEL:90a13eaa-c7b0-4258-bebb-87b7aed39ec6,CN=LostAndFound,DC=MyEmployer,DC=prv:The specified account does not exist.

然后我说要让它自动化,我只需右键单击并通过 ADSIedit 删除它。

在此处输入图像描述


所以,最后,我吞下我的骄傲,在这里问。 我到底要如何摆脱这个该死的东西? 它显然存在,并且它的存在导致了问题,但我从 Active Directory 中删除它的所有尝试都遇到了谎言、该死的谎言和错误消息。


更新:

根据与 ServerFaulters 的评论、建议和讨论,其他没有奏效的事情:

转义0, 好像\0代表一个空字节。


Get-ADObject "CN=SomeComputer`0ADEL:90a13eaa-c7b0-4258-bebb-87b7aed39ec6,CN=LostAndFound,DC=MyEmployer,DC=prv" -IncludeDeletedObjects | Remove-ADObject

Get-ADObject : No superior reference has been configured for the directory service. The directory service is therefore unable to issue referrals to objects outside this forest
At line:1 char:13
+ Get-ADObject <<<<  "CN=SomeComputer`0ADEL:90a13eaa-c7b0-4258-bebb-87b7aed39ec6,CN=LostAndFound,DC=MyEmployer,DC=prv" -Includ
eDeletedObjects | Remove-ADObject
    + CategoryInfo          : NotSpecified: (CN=SomeComputer ADEL...MyEmployer,DC=prv:ADObject) [Get-ADObject], ADException
    + FullyQualifiedErrorId : No superior reference has been configured for the directory service. The directory service is therefore unable to issue referrals to objects outside this forest,Microsoft.ActiveDirectory.Management.Commands.GetADObject

转义整个\0A,就好像它是回车或换行一样,就像在 DOS 中一样(尝试使用 `n、`r、`n`r 和 `r`n)。所有都返回相同的错误,所以只显示一次。


Get-ADObject "SomeComputer`n`rDEL:90a13eaa-c7b0-4258-bebb-87b7aed39ec6,CN=LostAndFound,DC=MyEmployer,DC=prv" -IncludeDeletedObjects | Remove-ADObject

Get-ADObject : The object name has bad syntax
At line:1 char:13
+ Get-ADObject <<<<  "CN=SomeComputer`n`rDEL:90a13eaa-c7b0-4258-bebb-87b7aed39ec6,CN=LostAndFound,DC=MyEmployer,DC=prv" -IncludeDeletedObjects | Remove-ADObject
    + CategoryInfo          : NotSpecified: (CN=SomeComputer
DEL...MyEmployer,DC=prv:ADObject) [Get-ADObject], ADException
    + FullyQualifiedErrorId : The object name has bad syntax,Microsoft.ActiveDirectory.Management.Commands.GetADObject

\0A将其作为表单提要转义(是的,有点绝望)。


Get-ADObject "CN=SomeComputer`fDEL:90a13eaa-c7b0-4258-bebb-87b7aed39ec6,CN=LostAndFound,DC=MyEmployer,DC=prv" -IncludeDeletedObjects | Remove-ADObject

Get-ADObject : Directory object not found
At line:1 char:13
+ Get-ADObject <<<<  "CN=SomeComputer`fDEL:90a13eaa-c7b0-4258-bebb-87b7aed39ec6,CN=LostAndFound,DC=MyEmployer,DC=prv" -IncludeDeletedObjects | Remove-ADObject
    + CategoryInfo          : ObjectNotFound: (CN=SomeComputer♀DEL:...MyEmployer,DC=prv:ADObject) [Get-ADObject], ADIdentityNotFoundException
    + FullyQualifiedErrorId : Directory object not found,Microsoft.ActiveDirectory.Management.Commands.GetADObject

然后我想我应该确定 \0A字符是否是问题,所以我在 AD 回收站中选择了一个我不关心的对象,其中包含\0A字符串并试图将其吹走。有效。


Get-ADObject -Filter { Name -Like '*DEL:*' } -IncludeDeletedObjects | Remove-ADObject

Confirm
Are you sure you want to perform this action?
Performing operation "Remove" on Target "CN=SomeServer-SomeJackass HP LaserJet 1320
PS\0ADEL:eddb23e7-b8d8-4d00-801f-22d82c169d66,CN=Deleted Objects,DC=MyEmployer,DC=prv".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): y

Confirm
Are you sure you want to perform this action?
Performing operation "Remove" on Target "CN=SomeServer-SomeJackass HP LaserJet 1320 PCL
5e\0ADEL:6e72e78f-f110-492c-ad50-91107f6fbd6a,CN=Deleted Objects,DC=MyEmployer,DC=prv".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): y

windows
  • 3 3 个回答
  • 17697 Views

3 个回答

  • Voted
  1. Best Answer
    HopelessN00b
    2014-06-26T05:48:29+08:002014-06-26T05:48:29+08:00

    根据与我交谈过的微软支持工程师......以及他升级给我的微软工程师......以及他们的经理,简短的回答是,摆脱这个被诅咒的对象的唯一方法是进行权威恢复到以前此对象在LostAndFound容器中的外观。我相信我也可以通过将所有域控制器引导到 LiveCD 并手动编辑 AD 数据库来摆脱它,但是缺少这两个非选项,我坚持下去。


    至于如何以及为什么会这样:

    我们针对该对象运行了一次(以查看其元数据),并且repadmin /showobjmeta能够从对象的isDeleted版本(2有人建议,并且在我看来很可能,在对象恢复之后,但在更改完全复制之前,它与它的父 OU 一起被再次删除,导致恢复失败,并导致它被认为是孤立的至少我们的一些域控制器的对象,将其降落在LostAndFound容器中。

    由于部分还原,它无法还原。 由于对象SAMAccountType为空,它不能被删除(或修改)。

    该SAMAccountType属性是任何用户都无法更改的值,尝试这样做会引发以下错误:

    在此处输入图像描述

    Operation failed. Error code: 0x209a
    Access to the attribute is not permitted because the attribute is owned by the Security Accounts Manager (SAM).
    
    0000209A: SvcErr: DSID-031A1021, problem 5003
    (WILL_NOT_PERFORM), data 0
    

    我们无法恢复对象以让系统(安全帐户管理器)设置此属性,因为它处于部分恢复状态,并且如果没有该属性的有效值,我们无法删除(或修改)它。


    但是,由于这个案例对我来说太有趣了,不能简单地离开,所以我会四处闲逛,看看我是否能想出解决这个问题的方法,或者至少扩展我的知识AD 尝试多一点。击败打印机故障排除...坦率地说,事实证明,一台计算机告诉我“WILL_NOT_PERFORM”是我无法抗拒的挑战。

    哦,是的,你会表演,该死!

    • 3
  2. Tim Ferrill
    2014-05-24T10:51:24+08:002014-05-24T10:51:24+08:00

    根据这篇文章,您可能必须尝试删除特定域控制器上的对象。您可以尝试使用 -Server 参数运行 Get-ADObject,以确定对象是否仅限于特定 DC。然后我会对 Remove-ADObject 做同样的事情。

    • 1
  3. Frank R
    2014-05-29T06:39:44+08:002014-05-29T06:39:44+08:00

    我有一个可能可行的想法,它可能看起来有点简单或与众不同,但如果我没记错的话,这在过去对我来说是孤儿帐户。如果您能确定准确的帐户名称,您正在寻找的系统,无论是用户帐户还是 PC/服务器帐户,请尝试临时创建一个相同类型和相同名称的帐户。所以你本质上是在填补空白,可以这么说,并为系统提供它想要的东西。

    因此,如果它是一个 PC/服务器帐户,请让一台机器使用它正在寻找的确切名称加入回域,但仅用于创建帐户的目的。或者,如果它是一个用户帐户,则重新创建具有完全相同名称的用户帐户等。您可能需要在命令提示符下运行命令 gpupdate /f 以使服务器将新重新创建的帐户与孤立的 OU 重新连接。

    然后继续尝试删除您最初想要删除的孤立 OU。清理完 OU 后,您可以删除为此任务创建的帐户。

    我希望这可以帮助你欢呼

    • 0

相关问题

  • 知道任何适用于 Windows 的快速可编写脚本的 ftp 客户端吗?[关闭]

  • 如果 Windows 服务崩溃,如何自动重新启动它?

  • 无法安排任务(访问被拒绝)

  • 物理机重启时自动重启虚拟机(VMWare)

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve