diff --git a/cleanW10.ps1 b/cleanW10.ps1 index ed86c37..a5397c1 100755 --- a/cleanW10.ps1 +++ b/cleanW10.ps1 @@ -622,14 +622,22 @@ Get-LocalUser | Where-Object { $_.Enabled -eq $true } | foreach { $script:users += @{name = $_.name;'sid' = $_.SID.Value; 'was_mounted' = $false; 'directory' = $current_user_path} } +Write-Host "Mount users registry hives :" $script:users | foreach { + Write-Host -NoNewline "`tMount $($_.name) hive : " if ( -not (Test-Path "HKU:\$($_.sid)") ) { - Write-Host "$($_.name) not mounted" - reg load "HKU\$($_.sid)" "$($_.directory)\NTUSER.DAT" + try { + reg load "HKU\$($_.sid)" "$($_.directory)\NTUSER.DAT" 2>&1 | Out-Null + Write-Host -ForegroundColor Green "done" + } + catch { + Write-Host -ForegroundColor Red "Error`n`t" + Write-host $Error[0].Exeption.Message + } } else { - Write-Host "$($_.name) mounted" $_.was_mounted = $true + Write-Host -ForegroundColor Yellow "Already mounted" } } Write-Host "Folder to process : $module"