Delete user profile using Powershell

笑着哭i 提交于 2019-12-12 05:34:53

问题


I am wondering how I can delete user profile by using Powershell? I know the command of Get-WmiObject Win32_UserProfile which will give me the whole users on the computer. I have 2 variables of $computername and $username. So I wants to use the above command to delete on a remote computer (which is $computername) the profile of $username. How I can do it? Thanks.


回答1:


Get-WMIObject can retrieve objects from remote computers with no problem, and not only does the Win32_UserProfile class have a (poorly documented) delete() method, a Win32_UserProfile object can be passed to Remove-WMIObject. This will, to all appearances, properly clean up the registry and files, and does in fact work on remote computers.

References:
Get-Help Get-WMIObject
Get-Help Remove-WMIObject
Win32_UserProfile: https://msdn.microsoft.com/en-us/library/ee886409(v=vs.85).aspx and https://msdn.microsoft.com/en-us/library/windows/desktop/hh830632(v=vs.85).aspx
My own question on this topic



来源:https://stackoverflow.com/questions/43735767/delete-user-profile-using-powershell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!