Delete user profile using Powershell

2019-09-15 02:57发布

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条回答
贪生不怕死
2楼-- · 2019-09-15 03:42

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

查看更多
登录 后发表回答