如何从 Windows 10 计算机中完全删除用户配置文件? [英] How to remove user profile completely from the Windows 10 computer?

查看:350
本文介绍了如何从 Windows 10 计算机中完全删除用户配置文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过 powershell 删除 Windows 10 计算机中的本地用户.

I want to remove local user in windows 10 computer through powershell.

我试过命令

Get-WMIObject -class Win32_UserProfile | Where {((!$_.Special) -and ($_.LocalPath -eq "C:\\Users\\$user")  -and ($_.LocalPath -ne "C:\\Users\\UpdatusUser"))} | Remove-WmiObject

以上命令成功删除本地用户.但是它不能删除C:\Users\$user\AppData

The Above command removes local user sucessfully. But it can't delete C:\Users\$user\AppData

是否有任何解决方法/黑客可以删除用户/AppData 文件夹.

Is there any workaround/hack to remove user/AppData folder.

我也尝试在成功删除用户后删除文件夹,但出现错误.

I have also tried removing folder after successful deletion of user, but I am getting an error.

错误:请求中指定的标签与重新分析点中存在的标签不匹配

对于错误参考,我尝试了一些解决该错误消息的解决方法,但没有奏效.但是如果我做 shift+delete (手动)它会成功删除.

For error reference I tried some workaround on that error message none worked. But if I do shift+delete (Manually) It will delete sucessfully.

我用来删除的命令如下

Remove-Item C:\User\$user -Force -Recurse

我以管理员身份运行 PowerShell.

I am running PowerShell as Administrator.

提前致谢.

推荐答案

使用 cmd.

cmd /c rmdir /s /q c:\users\user

Powershell 无法处理目录中的坏链接.卸载那个糟糕的Office"应用程序.问题出在 AppData\Local\Packages\Microsoft.MicrosoftOfficeHub_8wekyb3d8bbwe\LocalCache 下.存在具有空链接类型和目标属性的目录连接 (?).

Powershell can't handle bad links in directories. Uninstall that terrible "Office" app. The problem is under AppData\Local\Packages\Microsoft.MicrosoftOfficeHub_8wekyb3d8bbwe\LocalCache. There's directory junctions (?) with null linktype and target properties.

Windows 10 在 1809 版本中存在一个独特的问题,即Office"应用程序在用户配置文件下创建了奇怪的链接文件和目录.WMI 也不能删除配置文件,powershell 也不能删除.

Windows 10 has a unique problem in version 1809 with the "Office" app creating strangely linked files and directories under the user profile. Even WMI can't delete the profile, nor powershell.

哇,什么样的目录结点没有目标或链接类型??但它有一个 ReparsePoint 属性和一个模式,在链接的末尾有一个l".

Wow, what kind of directory junction has no target or linktype?? But it has a ReparsePoint attribute and a mode with an "l" on the end for link.

get-item c:\users\user\AppData\Local\Packages\Microsoft.MicrosoftOfficeHub_8wekyb3d8bbwe\localcache | fl *

PSPath            : Microsoft.PowerShell.Core\FileSystem::C:\users\user\AppData\Local\Packages\Microsoft.MicrosoftOfficeHub_8wekyb3d8bbwe\localcache
PSParentPath      : Microsoft.PowerShell.Core\FileSystem::C:\users\user\AppData\Local\Packages\Microsoft.MicrosoftOfficeHub_8wekyb3d8bbwe
PSChildName       : localcache
PSDrive           : C
PSProvider        : Microsoft.PowerShell.Core\FileSystem
PSIsContainer     : True
Mode              : d----l
BaseName          : localcache
Target            : {}
LinkType          :
Name              : localcache
FullName          : C:\users\user\AppData\Local\Packages\Microsoft.MicrosoftOfficeHub_8wekyb3d8bbwe\localcache
Parent            : Microsoft.MicrosoftOfficeHub_8wekyb3d8bbwe
Exists            : True
Root              : C:\
Extension         :
CreationTime      : 8/1/2019 3:29:02 PM
CreationTimeUtc   : 8/1/2019 7:29:02 PM
LastAccessTime    : 8/1/2019 3:29:02 PM
LastAccessTimeUtc : 8/1/2019 7:29:02 PM
LastWriteTime     : 8/1/2019 3:29:02 PM
LastWriteTimeUtc  : 8/1/2019 7:29:02 PM
Attributes        : Directory, ReparsePoint

相关错误报告:https://github.com/powershell/powershell/issues/621 我亲眼所见.在文件资源管理器中多次尝试才能完全删除配置文件.

Related bug report: https://github.com/powershell/powershell/issues/621 I've seen this myself. It takes multiple attempts in file explorer to completely delete the profile.

假设我以这种方式删除个人资料:

Say I delete a profile this way:

Get-CimInstance win32_userprofile | where localpath -match user$ | Remove-CimInstance

遗留了几个文件夹.他们来了.Remove-item 表示是一个 NTFS 连接点.使用 Force 参数删除或修改此对象."Remove-item -force 表示请求中指定的标签与重新分析点中存在的标签不匹配"

Several folders get left over. Here they are. Remove-item says "is an NTFS junction point. Use the Force parameter to delete or modify this object." Remove-item -force says "There is a mismatch between the tag specified in the request and the tag present in the reparse point"

C:\Users\user\AppData\Local\Packages\Microsoft.MicrosoftOfficeHub_8wekyb3d8bbwe\LocalCache
C:\Users\user\AppData\Local\Packages\Microsoft.MicrosoftOfficeHub_8wekyb3d8bbwe\LocalCache\Local
C:\Users\user\AppData\Local\Packages\Microsoft.MicrosoftOfficeHub_8wekyb3d8bbwe\LocalCache\Local\Microsoft
C:\Users\user\AppData\Local\Packages\Microsoft.MicrosoftOfficeHub_8wekyb3d8bbwe\LocalCache\Local\Microsoft\CLR_v4.0
C:\Users\user\AppData\Local\Packages\Microsoft.MicrosoftOfficeHub_8wekyb3d8bbwe\LocalCache\Local\Microsoft\CLR_v4.0\UsageLogs
C:\Users\user\AppData\Local\Packages\Microsoft.MicrosoftOfficeHub_8wekyb3d8bbwe\LocalCache\LocalLow
C:\Users\user\AppData\Local\Packages\Microsoft.MicrosoftOfficeHub_8wekyb3d8bbwe\LocalCache\LocalLow\Microsoft
C:\Users\user\AppData\Local\Packages\Microsoft.MicrosoftOfficeHub_8wekyb3d8bbwe\LocalCache\LocalLow\Microsoft\CryptnetUrlCache
C:\Users\user\AppData\Local\Packages\Microsoft.MicrosoftOfficeHub_8wekyb3d8bbwe\LocalCache\LocalLow\Microsoft\CryptnetUrlCache\Content
C:\Users\user\AppData\Local\Packages\Microsoft.MicrosoftOfficeHub_8wekyb3d8bbwe\LocalCache\LocalLow\Microsoft\CryptnetUrlCache\MetaData

这篇关于如何从 Windows 10 计算机中完全删除用户配置文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆