Better output for users hive mount

This commit is contained in:
Yorick Barbanneau 2018-03-28 21:08:20 +02:00
parent 7c6aed89e3
commit c1d3c82c35

View file

@ -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"