Better output for users hive mount
This commit is contained in:
parent
7c6aed89e3
commit
c1d3c82c35
1 changed files with 11 additions and 3 deletions
14
cleanW10.ps1
14
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}
|
$script:users += @{name = $_.name;'sid' = $_.SID.Value; 'was_mounted' = $false; 'directory' = $current_user_path}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Write-Host "Mount users registry hives :"
|
||||||
$script:users | foreach {
|
$script:users | foreach {
|
||||||
|
Write-Host -NoNewline "`tMount $($_.name) hive : "
|
||||||
if ( -not (Test-Path "HKU:\$($_.sid)") ) {
|
if ( -not (Test-Path "HKU:\$($_.sid)") ) {
|
||||||
Write-Host "$($_.name) not mounted"
|
try {
|
||||||
reg load "HKU\$($_.sid)" "$($_.directory)\NTUSER.DAT"
|
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 {
|
else {
|
||||||
Write-Host "$($_.name) mounted"
|
|
||||||
$_.was_mounted = $true
|
$_.was_mounted = $true
|
||||||
|
Write-Host -ForegroundColor Yellow "Already mounted"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Write-Host "Folder to process : $module"
|
Write-Host "Folder to process : $module"
|
||||||
|
|
Reference in a new issue