Hop*_*00b 20 windows powershell active-directory
我正在使用 PowerShell v2.0 的 Windows 7 工作站工作,并尝试从启用LostAndFound了Active Directory 回收站的 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
Run Code Online (Sandbox Code Playgroud)
我尝试过的任何东西似乎都不起作用,而且我已经尝试了很多。关于这一点,我在下面尝试过。
首先,使用简单的一行 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
Run Code Online (Sandbox Code Playgroud)
然后,同样的事情,而是引用 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
Run Code Online (Sandbox Code Playgroud)
然后,首先将值读入变量。(同时尝试使用 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
Run Code Online (Sandbox Code Playgroud)
然后我想我可以忍受必须调用 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.
Run Code Online (Sandbox Code Playgroud)
然后我说要让它自动化,我只需右键单击并通过 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
Run Code Online (Sandbox Code Playgroud)
转义整个\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
Run Code Online (Sandbox Code Playgroud)
\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
Run Code Online (Sandbox Code Playgroud)
然后我想我应该确定这个 \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
Run Code Online (Sandbox Code Playgroud)
据我交谈过的微软支持工程师……以及他向我升级的微软工程师……以及他们的经理所说,简短的答案是,摆脱这个被诅咒的对象的唯一方法就是对之前的内容进行权威恢复。该对象在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
Run Code Online (Sandbox Code Playgroud)
我们无法恢复该对象以使系统(安全帐户管理器)设置此属性,因为它处于部分恢复状态,并且如果没有该属性的有效值,我们无法删除它(或修改它)。
然而,由于这个案例对我来说太有趣了,我无法简单地放弃,所以我将探索一段时间,看看我是否能想出解决这个问题的方法,或者至少扩展我的知识AD在尝试中多了一点。击败打印机故障排除......坦率地说,事实证明,计算机告诉我“WILL_NOT_PERFORM”是我无法抗拒的挑战。
哦,是的,你会表演,该死!
| 归档时间: |
|
| 查看次数: |
16056 次 |
| 最近记录: |