Fix Corrupted User's Profiles with PowerShell

By Michael J. Thomas

Troubleshooting a user's profile is sometimes hard to pin point out where the problem is and that is why a lot of us techs will use the technique of re-profiling the user's profile and copying just their data back. To do this process of re-profiling a user manually, I will demonstrate this process with a user account named Ed. I would do the following steps to fix his corrupted profile:
  1. Logoff Ed
  2. Login with an Admin Account
  3. Rename C:\Users\Ed to C:\Users\Ed.old 
  4. Edit the Registry HKLM:\Software\Microsoft\Windows NT\CurrentVersion\ProfileListNow\SID and find Ed's SID and rename it to the SID.old. 
  5. Logoff Admin Account
  6. Login Ed to Create a New Profile for him.
  7. Copy Ed's Data from Ed.Old Folder to his New User Profile.
I automated the process by creating a PowerShell Script that can fix it remotely. The script renames the user's profile to user.old, backups the user's registry key to windows temp folder, and rename's the SID in the registry to SID.old . The only thing I did not include in this script is to copy the user's data over to their new profile when they log back in. Don't worry, I will include that in a future version.
I hope you enjoy this weeks PowerShell Weekly Script!

<# .Synopsis Invoke-Reprofile is used to reprofile a remote users profile. Author: Michael J. Thomas Created: 06/29/2019 Modified: 06/29/2019 Notes: WinRM must be Configured on Remote Computers and Remote Users must be Logged off. I have other functions for doing that. Not included with this example at this time. .DESCRIPTION Invoke-Reprofile renames the UserName to UserName.old in Users Folder, Backup User SID in Registry to Windows Temp Folder, and Renamed SID to SID.Old in ProfileList. If user profile is messed up on multiple systems, use this on multiple computers. .EXAMPLE Invoke-Reprofile -ComputerName "Computer01" -UserName "User01" .EXAMPLE Invoke-Reprofile -ComputerName "Computer01" -UserName "User01","User02" .EXAMPLE Invoke-Reprofile -ComputerName "Computer01","Computer02" -UserName "User01" .EXAMPLE Invoke-Reprofile -ComputerName "Computer01","Computer02" -UserName "User01","User02" #> function Invoke-ReProfile { [CmdletBinding()] Param ( [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$true, Position=0)] [string[]] $ComputerName, [string[]] $UserName ) Begin { Write-Host "Invoking ReProfile Process on $ComputerName" } Process { Try{ Invoke-Command -ComputerName $ComputerName -ScriptBlock{ $SID = (New-Object System.Security.Principal.NTAccount($Using:UserName)).Translate([System.Security.Principal.SecurityIdentifier]).Value $TimeStamp = Get-Date -format yyyy-MM-dd-mm-ss-ff Rename-Item -path "$env:SystemDrive\Users\$Using:UserName" -newName "$Using:UserName.old" -Force -ErrorAction Stop Reg Export "Hkey_local_Machine\Software\Microsoft\Windows NT\CurrentVersion\ProfileList\$SID" $env:windir\temp\$Using:UserName$TimeStamp.reg Rename-Item -Path "HKLM:\Software\Microsoft\Windows NT\CurrentVersion\ProfileList\$SID" -NewName "$($SID).old" -Force -ErrorAction Stop #Option for Removing The User Registry Key #Remove-Item -Path "HKLM:\Software\Microsoft\Windows NT\CurrentVersion\ProfileList\$SID" -Force -Confirm:$false -Recurse } -ErrorAction Stop } Catch{ Write-Host $_.Exception.Message -ForegroundColor Red } } End { Write-Host "Completed Changing $UserName.old in Users Folder, Backup Registry to Windows Temp Folder, and Renamed Users SID in Registry ProfileList to SID.Old" -ForegroundColor Green Write-Host "Please have user login and copy their data from the $UserName.old Folder" -ForegroundColor Green } }
>_ Get-PowerShellWeekly Follow us by Email


  1. If you suppose that low stakes aren't really giving you the excitement you need from taking part in}, then maybe it's time to think about upgrading to the next stage of stakes. While many UK roulette on-line casinos accept PayPal deposits and withdrawals, not all do. If may be} looking for a roulette casino that accepts PayPal, check out at|try} our list of the most effective roulette sites by sort. You will discover our top-rated PayPal roulette website for UK casino players within the itemizing. The Martingale strategy is the most well-liked of all on-line roulette playing methods. The Martingale is a progressive betting system that can be utilized on even-money 토토사이트 bets.


Post a Comment

Popular posts from this blog


Install Admin Pack on Remote Computer