PowerShell Registry lesen und schreiben

 

Mit Powershell Registry-Werte lesen oder schreiben.

Registry lesen

$(Get-ItemProperty -Path "HKCU:\Control Panel\International" -Name LocaleName).LocaleName

Registry schreiben

Set-ItemProperty -Path "HKCU:\Control Panel\International" -Name LocaleName -Value "de-DE"

Beispielskript um alle verwendeten Profilordner aus der Registry auszulesen

$profspath="HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\"

$profs=get-childitem $profspath

foreach ($prof in $profs) {
    $(get-itemProperty -path "$($profspath)$($prof.PSChildName)" -name ProfileImagePath).ProfileImagePath
}

bestimmte Einstellungen in allen Benutzerprofilen ändern

$profspath="HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\"

$profs=get-childitem $profspath
If (!(Test-Path "HKU:")){
    New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS
}

foreach ($prof in $profs) {
    $userprops = $(get-itemProperty -path "$($profspath)$($prof.PSChildName)" -name ProfileImagePath )
    if ($($userprops.PSChildName).contains("S-1-5-21") ){
        write-host "$($userprops.ProfileImagePath) = $($userprops.PSChildName)"
        Get-ItemProperty -Path "HKU:\$($userprops.PSChildName)\Control Panel\International" -Name LocaleName
        continue; #if you are sure, remove this line to apply the settings ...   
        Set-ItemProperty -Path "HKU:\$($userprops.PSChildName)\Control Panel\International" -Name LocaleName -Value "en-DE" 
    }
}
positive Bewertung({{pro_count}})
Beitrag bewerten:
{{percentage}} % positiv
negative Bewertung({{con_count}})

DANKE für deine Bewertung!

Fragen / Kommentare