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