Use PowerShell delete a user profile (step

choubertsprojects

The Best WordPress plugins!

1. WP Reset

2. WP 301 Redirects

3. WP Force SSL

PowerShell is a command-line tool that can be used to automate and simplify tasks in Windows. It allows users of all levels the ability to perform any task from system administration, automation, or troubleshooting on their computer without having to use a GUI interface such as Command Prompt or PowerShell ISE.

The “powershell script to delete user profiles older than 30 days” is a step-by-step guide on how to delete user profiles that are older than 30 days.

Use PowerShell delete a user profile (step

Profiles of Users are a major source of frustration for IT administrators. A Windows IT pro’s existence revolves on Profiles of Users, particularly those who administer virtual desktop environments such as Remote Desktop Services (RDS) or Citrix. In this tutorial, I’ll show you how to vent your frustrations by Profiles of Users Can Be Removed using PowerShell (and discover them).

Administrators of Windows systems must cope with the following issues:

  • user registry hives that have been corrupted
  • documents that must be shared by all Profiles of Users
  • finding out how to resurrect profiles that have been corrupted
  • …and much more

With PowerShell, what was previously a difficult process has become a bit less so. Here are several ways PowerShell may help you manage Windows Profiles of Users.

Creating a List of Profiles of Users

On a single Windows PC, seeing Profiles of Users on the file system is simple. Look in the C:Users directory. However, not only will you not get the complete image if you do this, but it will also be inconvenient owing to probable file system access issues. There is a better approach, which is to use WMI or CIM. A class named Win32 UserProfile exists in CIM. This class holds all of the profiles on a computer, as well as a wealth of additional information that a standard file system folder cannot provide.

The Get-CimInstance cmdlet in PowerShell may be used to retrieve this CIM class.

On the local computer, I’m looking for the initial user profile. Many valuable nuggets of information, such as LastUseTime, SID, and so on, will be visible.

PS C:> Get-CimInstance -ClassName win32_userprofile | Select-Object -First 1 AppDataRoaming : Win32_FolderRedirectionHealth Contacts : Win32_FolderRedirectionHealth Desktop : Win32_FolderRedirectionHealth Documents : Win32_FolderRedirectionHealth Downloads : Win32_FolderRedirectionHealth Favorites : Win32_FolderRedirectionHealth HealthStatus : 3 LastAttemptedProfileDownloadTime : LastAttemptedProfileUploadTime : LastBackgroundRegistryUploadTime : LastDownloadTime : LastUploadTime : LastUseTime : 3/14/2019 3:06:39 PM Links : Win32_FolderRedirectionHealth Loaded : False LocalPath : C:Users.NET v4.5 Classic Music : Win32_FolderRedirectionHealth Pictures : Win32_FolderRedirectionHealth RefCount : RoamingConfigured : False RoamingPath : RoamingPreference : SavedGames : Win32_FolderRedirectionHealth Searches : Win32_FolderRedirectionHealth SID : S-1-5-82-3876422241-1344743610-1729199087-774402673-2621913236 Special : False StartMenu : Win32_FolderRedirectionHealth Status : 0 Videos : Win32_FolderRedirectionHealth PSComputerName :

The Get-CimInstance cmdlet may be used both locally and remotely. You may provide 1, 10, or 100 distinct remote computers using the ComputerName argument, and it will cheerfully query each one.

PS C:> Get-CimInstance -ClassName Win32_UserProfile -ComputerName localhost,WINSRV

Profiles of Users Can Be Removed

You may go one step further and erase those Profiles of Users after you’ve figured out how to enumerate Profiles of Users on PCs.

I can’t count how many times I’ve had to delete Profiles of Users because something got corrupted and I just needed the user to log in again and recreate it. At one time, I would simply have the user log off and remove the C:Users<UserName> folder from the file system. Usually it works, sometimes it didn’t. What I didn’t realize was that I was actually leaving some remnants behind.

The right method to accomplish this is to use CIM to start a removal.

It’s possible to not only examine but also fully erase profiles using the same CIM class you just learned about. This is the same as clicking the Delete button in the Profiles of Users box under System settings.

Profiles of UsersProfiles of Users

To do this, enumerate the Profiles of Users again and this time apply a filter to pick a single user profile to remove. In this case, remove the user profile called UserA. You can do this by using PowerShell’s Where-Object cmdlet and some string manipulation to grab the user folder name from the LocalPath property as shown below.

You may provide the CIM instance to the Remove-CimInstance cmdlet for each item that Get-CimInstance returns after you’ve narrowed down that single profile. The user profile will be deleted from the file system and the registry throughout this operation.

Where-Object

Profiles of Users are a major source of frustration for IT administrators. A Windows IT pro’s existence revolves on Profiles of Users, particularly those who administer virtual desktop environments such as Remote Desktop Services (RDS) or Citrix. In this tutorial, I’ll show you how to vent your frustrations by Profiles of Users Can Be Removed using PowerShell (and discover them).

Administrators of Windows systems must cope with the following issues:

  • user registry hives that have been corrupted
  • documents that must be shared by all Profiles of Users
  • finding out how to resurrect profiles that have been corrupted
  • …and much more

With PowerShell, what was previously a difficult process has become a bit less so. Here are several ways PowerShell may help you manage Windows Profiles of Users.

Creating a List of Profiles of Users

On a single Windows PC, seeing Profiles of Users on the file system is simple. Look in the C:Users directory. However, not only will you not get the complete image if you do this, but it will also be inconvenient owing to probable file system access issues. There is a better approach, which is to use WMI or CIM. A class named Win32 UserProfile exists in CIM. This class holds all of the profiles on a computer, as well as a wealth of additional information that a standard file system folder cannot provide.

The Get-CimInstance cmdlet in PowerShell may be used to retrieve this CIM class.

On the local computer, I’m looking for the initial user profile. Many valuable nuggets of information, such as LastUseTime, SID, and so on, will be visible.

PS C:> Get-CimInstance -ClassName win32_userprofile | Select-Object -First 1 AppDataRoaming : Win32_FolderRedirectionHealth Contacts : Win32_FolderRedirectionHealth Desktop : Win32_FolderRedirectionHealth Documents : Win32_FolderRedirectionHealth Downloads : Win32_FolderRedirectionHealth Favorites : Win32_FolderRedirectionHealth HealthStatus : 3 LastAttemptedProfileDownloadTime : LastAttemptedProfileUploadTime : LastBackgroundRegistryUploadTime : LastDownloadTime : LastUploadTime : LastUseTime : 3/14/2019 3:06:39 PM Links : Win32_FolderRedirectionHealth Loaded : False LocalPath : C:Users.NET v4.5 Classic Music : Win32_FolderRedirectionHealth Pictures : Win32_FolderRedirectionHealth RefCount : RoamingConfigured : False RoamingPath : RoamingPreference : SavedGames : Win32_FolderRedirectionHealth Searches : Win32_FolderRedirectionHealth SID : S-1-5-82-3876422241-1344743610-1729199087-774402673-2621913236 Special : False StartMenu : Win32_FolderRedirectionHealth Status : 0 Videos : Win32_FolderRedirectionHealth PSComputerName :

The Get-CimInstance cmdlet may be used both locally and remotely. You may provide 1, 10, or 100 distinct remote computers using the ComputerName argument, and it will cheerfully query each one.

PS C:> Get-CimInstance -ClassName Win32_UserProfile -ComputerName localhost,WINSRV

Profiles of Users Can Be Removed

You may go one step further and erase those Profiles of Users after you’ve figured out how to enumerate Profiles of Users on PCs.

I can’t count how many times I’ve had to delete Profiles of Users because something got corrupted and I just needed the user to log in again and recreate it. At one time, I would simply have the user log off and remove the C:Users<UserName> folder from the file system. Usually it works, sometimes it didn’t. What I didn’t realize was that I was actually leaving some remnants behind.

The right method to accomplish this is to use CIM to start a removal.

It’s possible to not only examine but also fully erase profiles using the same CIM class you just learned about. This is the same as clicking the Delete button in the Profiles of Users box under System settings.

Profiles of UsersProfiles of Users

To do this, enumerate the Profiles of Users again and this time apply a filter to pick a single user profile to remove. In this case, remove the user profile called UserA. You can do this by using PowerShell’s Where-Object cmdlet and some string manipulation to grab the user folder name from the LocalPath property as shown below.

You may provide the CIM instance to the Remove-CimInstance cmdlet for each item that Get-CimInstance returns after you’ve narrowed down that single profile. The user profile will be deleted from the file system and the registry throughout this operation.

Get-CimInstance -Class Win32_UserProfile | Where-Object { $_.LocalPath.split(”)[-1] -eq ‘UserA’ } | Remove-CimInstance

If you want to utilize Get-CimInstance to expand this to several machines, just use the ComputerName argument.

Where-Object

Profiles of Users are a major source of frustration for IT administrators. A Windows IT pro’s existence revolves on Profiles of Users, particularly those who administer virtual desktop environments such as Remote Desktop Services (RDS) or Citrix. In this tutorial, I’ll show you how to vent your frustrations by Profiles of Users Can Be Removed using PowerShell (and discover them).

Administrators of Windows systems must cope with the following issues:

  • user registry hives that have been corrupted
  • documents that must be shared by all Profiles of Users
  • finding out how to resurrect profiles that have been corrupted
  • …and much more

With PowerShell, what was previously a difficult process has become a bit less so. Here are several ways PowerShell may help you manage Windows Profiles of Users.

Creating a List of Profiles of Users

On a single Windows PC, seeing Profiles of Users on the file system is simple. Look in the C:Users directory. However, not only will you not get the complete image if you do this, but it will also be inconvenient owing to probable file system access issues. There is a better approach, which is to use WMI or CIM. A class named Win32 UserProfile exists in CIM. This class holds all of the profiles on a computer, as well as a wealth of additional information that a standard file system folder cannot provide.

The Get-CimInstance cmdlet in PowerShell may be used to retrieve this CIM class.

On the local computer, I’m looking for the initial user profile. Many valuable nuggets of information, such as LastUseTime, SID, and so on, will be visible.

PS C:> Get-CimInstance -ClassName win32_userprofile | Select-Object -First 1 AppDataRoaming : Win32_FolderRedirectionHealth Contacts : Win32_FolderRedirectionHealth Desktop : Win32_FolderRedirectionHealth Documents : Win32_FolderRedirectionHealth Downloads : Win32_FolderRedirectionHealth Favorites : Win32_FolderRedirectionHealth HealthStatus : 3 LastAttemptedProfileDownloadTime : LastAttemptedProfileUploadTime : LastBackgroundRegistryUploadTime : LastDownloadTime : LastUploadTime : LastUseTime : 3/14/2019 3:06:39 PM Links : Win32_FolderRedirectionHealth Loaded : False LocalPath : C:Users.NET v4.5 Classic Music : Win32_FolderRedirectionHealth Pictures : Win32_FolderRedirectionHealth RefCount : RoamingConfigured : False RoamingPath : RoamingPreference : SavedGames : Win32_FolderRedirectionHealth Searches : Win32_FolderRedirectionHealth SID : S-1-5-82-3876422241-1344743610-1729199087-774402673-2621913236 Special : False StartMenu : Win32_FolderRedirectionHealth Status : 0 Videos : Win32_FolderRedirectionHealth PSComputerName :

The Get-CimInstance cmdlet may be used both locally and remotely. You may provide 1, 10, or 100 distinct remote computers using the ComputerName argument, and it will cheerfully query each one.

PS C:> Get-CimInstance -ClassName Win32_UserProfile -ComputerName localhost,WINSRV

Profiles of Users Can Be Removed

You may go one step further and erase those Profiles of Users after you’ve figured out how to enumerate Profiles of Users on PCs.

I can’t count how many times I’ve had to delete Profiles of Users because something got corrupted and I just needed the user to log in again and recreate it. At one time, I would simply have the user log off and remove the C:Users<UserName> folder from the file system. Usually it works, sometimes it didn’t. What I didn’t realize was that I was actually leaving some remnants behind.

The right method to accomplish this is to use CIM to start a removal.

It’s possible to not only examine but also fully erase profiles using the same CIM class you just learned about. This is the same as clicking the Delete button in the Profiles of Users box under System settings.

Profiles of UsersProfiles of Users

To do this, enumerate the Profiles of Users again and this time apply a filter to pick a single user profile to remove. In this case, remove the user profile called UserA. You can do this by using PowerShell’s Where-Object cmdlet and some string manipulation to grab the user folder name from the LocalPath property as shown below.

You may provide the CIM instance to the Remove-CimInstance cmdlet for each item that Get-CimInstance returns after you’ve narrowed down that single profile. The user profile will be deleted from the file system and the registry throughout this operation.

Where-Object

Profiles of Users are a major source of frustration for IT administrators. A Windows IT pro’s existence revolves on Profiles of Users, particularly those who administer virtual desktop environments such as Remote Desktop Services (RDS) or Citrix. In this tutorial, I’ll show you how to vent your frustrations by Profiles of Users Can Be Removed using PowerShell (and discover them).

Administrators of Windows systems must cope with the following issues:

  • user registry hives that have been corrupted
  • documents that must be shared by all Profiles of Users
  • finding out how to resurrect profiles that have been corrupted
  • …and much more

With PowerShell, what was previously a difficult process has become a bit less so. Here are several ways PowerShell may help you manage Windows Profiles of Users.

Creating a List of Profiles of Users

On a single Windows PC, seeing Profiles of Users on the file system is simple. Look in the C:Users directory. However, not only will you not get the complete image if you do this, but it will also be inconvenient owing to probable file system access issues. There is a better approach, which is to use WMI or CIM. A class named Win32 UserProfile exists in CIM. This class holds all of the profiles on a computer, as well as a wealth of additional information that a standard file system folder cannot provide.

The Get-CimInstance cmdlet in PowerShell may be used to retrieve this CIM class.

On the local computer, I’m looking for the initial user profile. Many valuable nuggets of information, such as LastUseTime, SID, and so on, will be visible.

PS C:> Get-CimInstance -ClassName win32_userprofile | Select-Object -First 1 AppDataRoaming : Win32_FolderRedirectionHealth Contacts : Win32_FolderRedirectionHealth Desktop : Win32_FolderRedirectionHealth Documents : Win32_FolderRedirectionHealth Downloads : Win32_FolderRedirectionHealth Favorites : Win32_FolderRedirectionHealth HealthStatus : 3 LastAttemptedProfileDownloadTime : LastAttemptedProfileUploadTime : LastBackgroundRegistryUploadTime : LastDownloadTime : LastUploadTime : LastUseTime : 3/14/2019 3:06:39 PM Links : Win32_FolderRedirectionHealth Loaded : False LocalPath : C:Users.NET v4.5 Classic Music : Win32_FolderRedirectionHealth Pictures : Win32_FolderRedirectionHealth RefCount : RoamingConfigured : False RoamingPath : RoamingPreference : SavedGames : Win32_FolderRedirectionHealth Searches : Win32_FolderRedirectionHealth SID : S-1-5-82-3876422241-1344743610-1729199087-774402673-2621913236 Special : False StartMenu : Win32_FolderRedirectionHealth Status : 0 Videos : Win32_FolderRedirectionHealth PSComputerName :

The Get-CimInstance cmdlet may be used both locally and remotely. You may provide 1, 10, or 100 distinct remote computers using the ComputerName argument, and it will cheerfully query each one.

PS C:> Get-CimInstance -ClassName Win32_UserProfile -ComputerName localhost,WINSRV

Profiles of Users Can Be Removed

You may go one step further and erase those Profiles of Users after you’ve figured out how to enumerate Profiles of Users on PCs.

I can’t count how many times I’ve had to delete Profiles of Users because something got corrupted and I just needed the user to log in again and recreate it. At one time, I would simply have the user log off and remove the C:Users<UserName> folder from the file system. Usually it works, sometimes it didn’t. What I didn’t realize was that I was actually leaving some remnants behind.

The right method to accomplish this is to use CIM to start a removal.

It’s possible to not only examine but also fully erase profiles using the same CIM class you just learned about. This is the same as clicking the Delete button in the Profiles of Users box under System settings.

Profiles of UsersProfiles of Users

To do this, enumerate the Profiles of Users again and this time apply a filter to pick a single user profile to remove. In this case, remove the user profile called UserA. You can do this by using PowerShell’s Where-Object cmdlet and some string manipulation to grab the user folder name from the LocalPath property as shown below.

You may provide the CIM instance to the Remove-CimInstance cmdlet for each item that Get-CimInstance returns after you’ve narrowed down that single profile. The user profile will be deleted from the file system and the registry throughout this operation.

Get-CimInstance -Class Win32_UserProfile | Where-Object { $_.LocalPath.split(”)[-1] -eq ‘UserA’ } | Remove-CimInstance

If you want to utilize Get-CimInstance to expand this to several machines, just use the ComputerName argument.

Get-CimInstance -ComputerName SRV1,SRV2,SRV3 -Class Win32_UserProfile | Where-Object { $_.LocalPath.split(”)[-1] -eq ‘UserA’ } | Remove-CimInstance

Summary

You’ve now seen an easy way to enumerate and delete Windows Profiles of Users. If you weren’t aware of the CIM class Win32_UserProfile you may have been correlating the C:Users<Username> folder as the profile but you should know to delete the Win32_UserProfile CIM instance now.

You can see there’s much more to the user profile than a simple file system folder. Use CIM the next time you need to query or delete Profiles of Users from Windows computers in your environment.

.LocalPath.split(“)[-1] Get-CimInstance -Class Win32 UserProfile Remove-CimInstance -eq ‘UserA’

If you want to utilize Get-CimInstance to expand this to several machines, just use the ComputerName argument.

Get-CimInstance -ComputerName SRV1,SRV2,SRV3 -Class Win32_UserProfile | Where-Object { $_.LocalPath.split(”)[-1] -eq ‘UserA’ } | Remove-CimInstance

Summary

You’ve now seen an easy way to enumerate and delete Windows Profiles of Users. If you weren’t aware of the CIM class Win32_UserProfile you may have been correlating the C:Users<Username> folder as the profile but you should know to delete the Win32_UserProfile CIM instance now.

You can see there’s much more to the user profile than a simple file system folder. Use CIM the next time you need to query or delete Profiles of Users from Windows computers in your environment.

.LocalPath.split(“)[-1] Get-CimInstance -ComputerName SRV1,SRV2,SRV3 -Class Win32 UserProfile Remove-CimInstance -eq ‘UserA’

Summary

You’ve now seen an easy way to enumerate and delete Windows Profiles of Users. If you weren’t aware of the CIM class Win32_UserProfile you may have been correlating the C:Users<Username> folder as the profile but you should know to delete the Win32_UserProfile CIM instance now.

You can see there’s much more to the user profile than a simple file system folder. Use CIM the next time you need to query or delete Profiles of Users from Windows computers in your environment.

.LocalPath.split(“)[-1] Get-CimInstance -Class Win32 UserProfile Remove-CimInstance -eq ‘UserA’

If you want to utilize Get-CimInstance to expand this to several machines, just use the ComputerName argument.

Where-Object

Profiles of Users are a major source of frustration for IT administrators. A Windows IT pro’s existence revolves on Profiles of Users, particularly those who administer virtual desktop environments such as Remote Desktop Services (RDS) or Citrix. In this tutorial, I’ll show you how to vent your frustrations by Profiles of Users Can Be Removed using PowerShell (and discover them).

Administrators of Windows systems must cope with the following issues:

  • user registry hives that have been corrupted
  • documents that must be shared by all Profiles of Users
  • finding out how to resurrect profiles that have been corrupted
  • …and much more

With PowerShell, what was previously a difficult process has become a bit less so. Here are several ways PowerShell may help you manage Windows Profiles of Users.

Creating a List of Profiles of Users

On a single Windows PC, seeing Profiles of Users on the file system is simple. Look in the C:Users directory. However, not only will you not get the complete image if you do this, but it will also be inconvenient owing to probable file system access issues. There is a better approach, which is to use WMI or CIM. A class named Win32 UserProfile exists in CIM. This class holds all of the profiles on a computer, as well as a wealth of additional information that a standard file system folder cannot provide.

The Get-CimInstance cmdlet in PowerShell may be used to retrieve this CIM class.

On the local computer, I’m looking for the initial user profile. Many valuable nuggets of information, such as LastUseTime, SID, and so on, will be visible.

PS C:> Get-CimInstance -ClassName win32_userprofile | Select-Object -First 1 AppDataRoaming : Win32_FolderRedirectionHealth Contacts : Win32_FolderRedirectionHealth Desktop : Win32_FolderRedirectionHealth Documents : Win32_FolderRedirectionHealth Downloads : Win32_FolderRedirectionHealth Favorites : Win32_FolderRedirectionHealth HealthStatus : 3 LastAttemptedProfileDownloadTime : LastAttemptedProfileUploadTime : LastBackgroundRegistryUploadTime : LastDownloadTime : LastUploadTime : LastUseTime : 3/14/2019 3:06:39 PM Links : Win32_FolderRedirectionHealth Loaded : False LocalPath : C:Users.NET v4.5 Classic Music : Win32_FolderRedirectionHealth Pictures : Win32_FolderRedirectionHealth RefCount : RoamingConfigured : False RoamingPath : RoamingPreference : SavedGames : Win32_FolderRedirectionHealth Searches : Win32_FolderRedirectionHealth SID : S-1-5-82-3876422241-1344743610-1729199087-774402673-2621913236 Special : False StartMenu : Win32_FolderRedirectionHealth Status : 0 Videos : Win32_FolderRedirectionHealth PSComputerName :

The Get-CimInstance cmdlet may be used both locally and remotely. You may provide 1, 10, or 100 distinct remote computers using the ComputerName argument, and it will cheerfully query each one.

PS C:> Get-CimInstance -ClassName Win32_UserProfile -ComputerName localhost,WINSRV

Profiles of Users Can Be Removed

You may go one step further and erase those Profiles of Users after you’ve figured out how to enumerate Profiles of Users on PCs.

I can’t count how many times I’ve had to delete Profiles of Users because something got corrupted and I just needed the user to log in again and recreate it. At one time, I would simply have the user log off and remove the C:Users<UserName> folder from the file system. Usually it works, sometimes it didn’t. What I didn’t realize was that I was actually leaving some remnants behind.

The right method to accomplish this is to use CIM to start a removal.

It’s possible to not only examine but also fully erase profiles using the same CIM class you just learned about. This is the same as clicking the Delete button in the Profiles of Users box under System settings.

Profiles of UsersProfiles of Users

To do this, enumerate the Profiles of Users again and this time apply a filter to pick a single user profile to remove. In this case, remove the user profile called UserA. You can do this by using PowerShell’s Where-Object cmdlet and some string manipulation to grab the user folder name from the LocalPath property as shown below.

You may provide the CIM instance to the Remove-CimInstance cmdlet for each item that Get-CimInstance returns after you’ve narrowed down that single profile. The user profile will be deleted from the file system and the registry throughout this operation.

Where-Object

Profiles of Users are a major source of frustration for IT administrators. A Windows IT pro’s existence revolves on Profiles of Users, particularly those who administer virtual desktop environments such as Remote Desktop Services (RDS) or Citrix. In this tutorial, I’ll show you how to vent your frustrations by Profiles of Users Can Be Removed using PowerShell (and discover them).

Administrators of Windows systems must cope with the following issues:

  • user registry hives that have been corrupted
  • documents that must be shared by all Profiles of Users
  • finding out how to resurrect profiles that have been corrupted
  • …and much more

With PowerShell, what was previously a difficult process has become a bit less so. Here are several ways PowerShell may help you manage Windows Profiles of Users.

Creating a List of Profiles of Users

On a single Windows PC, seeing Profiles of Users on the file system is simple. Look in the C:Users directory. However, not only will you not get the complete image if you do this, but it will also be inconvenient owing to probable file system access issues. There is a better approach, which is to use WMI or CIM. A class named Win32 UserProfile exists in CIM. This class holds all of the profiles on a computer, as well as a wealth of additional information that a standard file system folder cannot provide.

The Get-CimInstance cmdlet in PowerShell may be used to retrieve this CIM class.

On the local computer, I’m looking for the initial user profile. Many valuable nuggets of information, such as LastUseTime, SID, and so on, will be visible.

PS C:> Get-CimInstance -ClassName win32_userprofile | Select-Object -First 1 AppDataRoaming : Win32_FolderRedirectionHealth Contacts : Win32_FolderRedirectionHealth Desktop : Win32_FolderRedirectionHealth Documents : Win32_FolderRedirectionHealth Downloads : Win32_FolderRedirectionHealth Favorites : Win32_FolderRedirectionHealth HealthStatus : 3 LastAttemptedProfileDownloadTime : LastAttemptedProfileUploadTime : LastBackgroundRegistryUploadTime : LastDownloadTime : LastUploadTime : LastUseTime : 3/14/2019 3:06:39 PM Links : Win32_FolderRedirectionHealth Loaded : False LocalPath : C:Users.NET v4.5 Classic Music : Win32_FolderRedirectionHealth Pictures : Win32_FolderRedirectionHealth RefCount : RoamingConfigured : False RoamingPath : RoamingPreference : SavedGames : Win32_FolderRedirectionHealth Searches : Win32_FolderRedirectionHealth SID : S-1-5-82-3876422241-1344743610-1729199087-774402673-2621913236 Special : False StartMenu : Win32_FolderRedirectionHealth Status : 0 Videos : Win32_FolderRedirectionHealth PSComputerName :

The Get-CimInstance cmdlet may be used both locally and remotely. You may provide 1, 10, or 100 distinct remote computers using the ComputerName argument, and it will cheerfully query each one.

PS C:> Get-CimInstance -ClassName Win32_UserProfile -ComputerName localhost,WINSRV

Profiles of Users Can Be Removed

You may go one step further and erase those Profiles of Users after you’ve figured out how to enumerate Profiles of Users on PCs.

I can’t count how many times I’ve had to delete Profiles of Users because something got corrupted and I just needed the user to log in again and recreate it. At one time, I would simply have the user log off and remove the C:Users<UserName> folder from the file system. Usually it works, sometimes it didn’t. What I didn’t realize was that I was actually leaving some remnants behind.

The right method to accomplish this is to use CIM to start a removal.

It’s possible to not only examine but also fully erase profiles using the same CIM class you just learned about. This is the same as clicking the Delete button in the Profiles of Users box under System settings.

Profiles of UsersProfiles of Users

To do this, enumerate the Profiles of Users again and this time apply a filter to pick a single user profile to remove. In this case, remove the user profile called UserA. You can do this by using PowerShell’s Where-Object cmdlet and some string manipulation to grab the user folder name from the LocalPath property as shown below.

You may provide the CIM instance to the Remove-CimInstance cmdlet for each item that Get-CimInstance returns after you’ve narrowed down that single profile. The user profile will be deleted from the file system and the registry throughout this operation.

Get-CimInstance -Class Win32_UserProfile | Where-Object { $_.LocalPath.split(”)[-1] -eq ‘UserA’ } | Remove-CimInstance

If you want to utilize Get-CimInstance to expand this to several machines, just use the ComputerName argument.

Get-CimInstance -ComputerName SRV1,SRV2,SRV3 -Class Win32_UserProfile | Where-Object { $_.LocalPath.split(”)[-1] -eq ‘UserA’ } | Remove-CimInstance

Summary

You’ve now seen an easy way to enumerate and delete Windows Profiles of Users. If you weren’t aware of the CIM class Win32_UserProfile you may have been correlating the C:Users<Username> folder as the profile but you should know to delete the Win32_UserProfile CIM instance now.

You can see there’s much more to the user profile than a simple file system folder. Use CIM the next time you need to query or delete Profiles of Users from Windows computers in your environment.

.LocalPath.split(“)[-1] Get-CimInstance -Class Win32 UserProfile Remove-CimInstance -eq ‘UserA’

If you want to utilize Get-CimInstance to expand this to several machines, just use the ComputerName argument.

Get-CimInstance -ComputerName SRV1,SRV2,SRV3 -Class Win32_UserProfile | Where-Object { $_.LocalPath.split(”)[-1] -eq ‘UserA’ } | Remove-CimInstance

Summary

You’ve now seen an easy way to enumerate and delete Windows Profiles of Users. If you weren’t aware of the CIM class Win32_UserProfile you may have been correlating the C:Users<Username> folder as the profile but you should know to delete the Win32_UserProfile CIM instance now.

You can see there’s much more to the user profile than a simple file system folder. Use CIM the next time you need to query or delete Profiles of Users from Windows computers in your environment.

.LocalPath.split(“)[-1] Get-CimInstance -ComputerName SRV1,SRV2,SRV3 -Class Win32 UserProfile Remove-CimInstance -eq ‘UserA’

Summary

You’ve now seen an easy way to enumerate and delete Windows Profiles of Users. If you weren’t aware of the CIM class Win32_UserProfile you may have been correlating the C:Users<Username> folder as the profile but you should know to delete the Win32_UserProfile CIM instance now.

You can see there’s much more to the user profile than a simple file system folder. Use CIM the next time you need to query or delete Profiles of Users from Windows computers in your environment.

The “remove-ciminstance win32_userprofile” is a command that can be used to delete a user profile from the Windows registry. It is necessary for any administrator to know this command in order to remove users who have left the company.

Frequently Asked Questions

How do you delete a user in PowerShell?

A: You cannot use PowerShell to delete a user.

How do I force a profile to delete?

A: You need to follow the steps below.
1) Open up your settings menu and scroll down until you see a tab that says Profiles.
2) Click on this profile, then right click and choose delete from the drop-down menu.

How do I delete a user profile?

A: On the left side of your profile, there is an option to delete it.

Related Tags

  • powershell script to delete specific user profiles
  • remove-wmiobject user profile
  • powershell profile removal
  • user profile cleaning script for windows 10
  • batch file to delete user profiles windows 10

Table of Content