我是新来的这个位置,并且发现它是需要严肃清洁的AD结构。 计算机帐户数量是员工数量的两倍,甚至不考虑服务器。 我希望能够知道哪些仍然有效,哪些可以删除而不会造成影响。
我从Joeware,OldCompfind了这个工具,它看起来非常方便,但我想我只是需要更多的了解它在看什么…当它search超过90天的计算机时,是否意味着它已经是90自插入networking以来的几天? 其原因是,我不希望无意中将一台笔记本电脑从可能在架子上的现场办公室分离出来,认为这是一台“旧”的电脑,而现在只是没有插入和使用电脑。 也许这是不值得担心的可能发生的罕见机会,但…
无论如何,如果有人知道任何其他方式,或者有一个很好的例子来说明如何做到这一点,我将不胜感激。 最终的结果是我只想能够摆脱不再使用的计算机帐户。 谢谢。
Oldcmp是众所周知的,它会做的很好,第一次,偶尔清理。
如果随着时间的推移,你想要一个自动化的过程,你可以使用Powershell(强烈推荐)为此写一个自动化的过程。 例如,我们当前的脚本执行以下操作:
lastLogonTimeStamp使用get-ADcomputer查找旧帐户 另外,如果我们不想删除它,我们使用帐户上的ProtectFromAccidentialDeletion标志。
没有任何方法可以区分已经不存在的机器和已经不存在的机器,因此使用OldComp进行清理并处理一次性当他们出现时
为什么不是PowerShell?
$Computers = ([ADSISearcher]"(&(objectCategory=computer)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))").FindAll() $Computers = $Computers | ForEach { $_.Path } $Age = $(Get-Date).AddDays(-90) $StaleComputerAccounts = @() $NeverUsedComputerAccounts = @() ForEach ($Computer in $Computers) { $ComputerObj = [ADSI]$Computer if ($ComputerObj.lastLogon) { $LastLogon = [DateTime]::FromFileTime($ComputerObj.ConvertLargeIntegerToInt64($ComputerObj.lastlogon[0])) if ( $LastLogon -lt $Age ) { $StaleComputerAccounts += $Computer } } else { $NeverUsedComputerAccounts += $Computer } }
你应该得到一个$StaleComputerAccounts和$NeverUsedComputerAccounts的列表,然后你可以用更多的PowerShell来操作。 我喜欢做这样的事情:
$TargetOU = "OU=Computers,OU=Disabled,OU=,DC=CONTOSO,DC=com" $OUObj = [ADSI]"LDAP://$TargetOU" ForEach ($Computer in $StaleComputerAccounts) { $ComputerObj = [ADSI]$Computer $ComputerObj.PSBase.MoveTo($OUObj) $ComputerObj.InvokeSet("accountDisabled", $True) $ComputerObj.SetInfo() }
没有什么不可思议的方式来区分不正确退役的计算机(没有人在离线时将其从Active Directory中删除)以及坐在某个执行人员桌上的笔记本电脑。 如果您想要谨慎行事,您可以closures帐户并像我一样将其发送到特定的OU。