DELPROF.exe (2003 Server Resource Kit - download)

Delete windows user profiles. Does not work with Windows 7 or later.

Syntax
      DELPROF [options days]

Key
   /Q      Quiet, no confirmation.

   /I      Ignore errors and continue deleting.

   /P      Prompts for confirmation before deleting each profile.

   /C:\\computer_name
           Delete profiles on a remote computer.

   /D:Number_of_days
           Only delete profiles that have been inactive for
           'X' Number of days (or greater)

   /R      Delete roaming profile cache only

Alternatives

In the Windows 10 GUI right-click My Computer ➞ Properties ➞ Advanced System Settings ➞ User Profiles ➞ account ➞ Delete

List local profiles:

Get-CimInstance -ClassName Win32_UserProfile -Filter "Special=False AND Loaded=False" | Select SID,localpath

Delete a user profile on a remote machine with PowerShell [via adamtheautomator.com]:

PS C:\> Get-CimInstance -ComputerName 'workstation64' -Class Win32_UserProfile | Where-Object { $_.LocalPath.split('\')[-1] -eq 'User64' } | Remove-CimInstance

The LocalPath of the profile will normally end in the username but if a user account is renamed the path will not update and will retain the old name.

Delete a local user profile by first selecting it in gridview:

#requires -RunAsAdministrator

Get-CimInstance -ClassName Win32_UserProfile -Filter "Special=False AND Loaded=False" |
    Add-Member -MemberType ScriptProperty -Name UserName -Value {
     (New-Object System.Security.Principal.SecurityIdentifier($this.Sid)).Translate([System.Security.Principal.NTAccount]).Value
      } -PassThru |
    Out-GridView -Title "Select User Profile" -OutputMode Single |
    ForEach-Object {
        # uncomment the line below to actually remove the selected user profile
        #$_.Delete()
    }

Helge Klein’s Delprof2, Delprof2 is syntax compatible with the original Delprof by Microsoft but does have issues with UWP (Windows Store) apps on Windows 10.
To run Delprof2 on a remote PC (with PowerShell):

PS> Invoke-command -computername 'workstation64' -scriptblock {& "C:\utils\delprof2.exe" '/q'}

“The best way to destroy the capitalist system is to debauch the currency” ~ John Keynes

Related commands

WMI/PowerShell script to delete user profiles - Idera.
Delprof2 - Delete Profiles Utility (Helge Klein).
DELTREE - Delete a folder and all subfolders.
RD - Delete folders or entire folder trees.


 
Copyright © 1999-2025 windevcluster.com
Some rights reserved