当从Active Directory中删除用户时,它显示为未知用户。
系统属性 – >高级 – >用户configuration文件 – >设置…
我必须一直手动删除它。
我的领域有超过400个工作站,我的公司的损耗率非常高。 我的系统只包含C盘。 如果这些数据没有被删除,是否会使系统变慢? 有一直在运行的重型软件。 如果我删除它,会对我的performance产生什么影响吗?
你也可以使用一个Powershell脚本来删除用户的configuration文件,这些configuration文件在一定的时间内(比如说30或者90天以上)没有login到工作站。
本质上,你想要使用类似的东西
#Get user names that have logged onto workstation $Users = gwmi win32_networkloginprofile | where {$_.name -match "DomainName\\"} | where {$_.name -notmatch "srvtasksched"} #For each user, delete if they haven't logged into the workstation in over 2 weeks $Users | foreach{ $Name = $_.Name $LastLogon = $_.LastLogon $LogonTime = [System.datetime]::ParseExact($LastLogon.Substring(0, $LastLogon.IndexOf(".")), "yyyyMMddHHmmss", [System.Globalization.DateTimeFormatInfo]::InvariantInfo) if($(Get-Date).Subtract($LogonTime).TotalDays -ge 14) { #User hasn't logged into workstation in over 2 weeks #Get profile path $UserSID = $(New-Object System.Security.Principal.NTAccount($Name)).Translate([System.Security.Principal.SecurityIdentifier]).Value $UserRegKey = GCI 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList' | where {$_.Name -match $UserSID} $ProfilePath = $(Get-ItemProperty $UserRegKey.PSPath -Name ProfileImagePath).ProfileImagePath Write-Host "Deleting User $Name" gwmi win32_userprofile | where {$_.SID -eq $UserSID} | foreach {$_.Delete()} }
我感到慷慨,所以你可以放弃这个脚本,并运行它,更新域名和自上次login以来的天数。
至于远程部分,您希望将您的环境设置为使用PowerShell远程处理,请使用Invoke-Command cmdlet,并将此脚本粘贴到脚本块参数之后
-ScriptBlock {script here}
考虑使用delprof2: http ://helgeklein.com/free-tools/delprof2-user-profile-deletion-tool/
所有需要远程运行的是“远程registry”设置,您可以清除所有当前未使用的configuration文件(或特定年龄的configuration文件),包括registry设置。 我相信在未知的情况下它可以正常工作,但这肯定是我的第一步。 一旦设置了远程registry,您就可以在整个站点上从batch file运行delprof2。