TUTOS.EU

Effacer les clées de registre en .bak

Script pour effacer toutes les clées de registre utilisateurs en .bak

write-host "`n`n`n"
write-host "  _____              _                 _       ______  "
write-host " / ___ \            | |               | |     (_____ \ "
write-host "| |   | |_   _ _   _| | ____ ____   _ | | ____ _____) )"
write-host "| |   | ( \ / ) | | | |/ _  |  _ \ / || |/ _  |_____ ( "
write-host "| |___| |) X (| |_| | ( ( | | | | ( (_| ( (/ /      | |"
write-host " \_____/(_/ \_)\__  |_|\_||_|_| |_|\____|\____)     |_|"
write-host "              (____/                                   "
write-host "`n"
write-host "`t`t   *****************"
write-host "`t`t  *******************"
write-host "`t`t *********************"
write-host "`n"
write-host "Début du nettoyage `n"
cd hklm:\software\microsoft\'windows nt'\currentversion\profilelist
$tablo=@()
$nom = "neutral"
$i = 0
$tablo = get-childitem | where-object {$_.name -like '*.bak'}
if ($tablo -eq $null) {
    write-host "Il n'y a pas de .bak sur ce serveur, trop de la balle Mec!!!"
    write-host "Du coup je rentre en Jamaique Mec"
    exit
}
else {
    foreach ($_ in $tablo) {
        $x = $i+1   
        write-output "Clé de registre .bak n° $x"
        write-output "Chemin et nom d'origine :"
        write-output $_.name
        $ind = ($_.name).lastindexof('\') + 1
        $nom = ($_.name).substring($ind)
        write-output "`n `r"
        write-output "Chemin de l'User :"
        $temp = get-itemproperty -path .\$nom -name ProfileImagePath | format-list -property profileimagepath
        write-output $temp
        write-output "`n"
        write-output "Effacement de la clé :"   
        write-output $nom
        remove-item -path $nom -recurse
        $i+=$x
        write-output "`n`n`r"
    }
}
write-host "Fin du nettoyage"
write-host "`n`n`n"
write-host "`t`t *********************"
write-host "`t`t  *******************"
write-host "`t`t   *****************"
Lien vers le fichier : cliquez ici Copier le code

2