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.
相关问题
- How to Debug/Register a Permanent WMI Event Which
- How can I do variable substitution in a here-strin
- How to use a default value with parameter sets in
- Does powershell have a method_missing()?
- Invoking Mirth Connect CLI with Powershell script
相关文章
- 在vscode如何用code runner打开独立的控制台窗口,以及设置好调试模式时窗口的编码?
- C#调用PowerShell的问题
- EscapeDataString having differing behaviour betwee
- PowerShell Change owner of files and folders
- Command line escaping single quote for PowerShell
- Is there a simple way to pass specific *named* Pow
- How do I access an element with xpath with a names
- How to 'Grant Permissions' Using Azure Act
Get-WMIObject
can retrieve objects from remote computers with no problem, and not only does theWin32_UserProfile
class have a (poorly documented)delete()
method, aWin32_UserProfile
object can be passed toRemove-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