From c1d3c82c353465cccba93b38ddfa0c16a926968e Mon Sep 17 00:00:00 2001 From: Yorick Barbanneau Date: Wed, 28 Mar 2018 21:08:20 +0200 Subject: [PATCH] Better output for users hive mount --- cleanW10.ps1 | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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"