Benutzer-Werkzeuge

Webseiten-Werkzeuge


windows:registry:script

Windows Registry per Skript für mehrere Benutzer abändern

Bitte ändere und kommentiere die Zeile Benutzer_Zum_Testen aus um das Skript nur auf einen Usernamen zu testen

# Define the registry key and its value
$registryKey = "Software\SEPPmail\OutlookAddIn"
$registryValueName = "SMEncryptSelected"
$registryValueData = "0x1"
 
 
# Get all user profiles on the system
$userProfiles = Get-WmiObject Win32_UserProfile | Where-Object { $_.Special -eq $false }
 
# Get the SID of the currently logged-in user
$currentUserID = [System.Security.Principal.WindowsIdentity]::GetCurrent().User.Value
 
# Iterate through each user profile and add the registry key
foreach ($userProfile in $userProfiles) {
    # Check if the user profile is a special profile (e.g., default user)
    if ($userProfile.Special -eq $false) {
        # Get the SID of the user
        $userSID = $userProfile.SID
 
 
        # Check if the current user's SID matches the looped user's SID
 
        $userRegistryPath = "Registry::\HKEY_USERS\$userSID\$registryKey"
        $username = [System.IO.Path]::GetFileName($userProfile.LocalPath)
        #echo $userProfile
 
        #echo $userSID
        #echo $userRegistryPath
        # Check if the registry key already exists for the user
        #if ($username -eq "Benutzer_Zum_Testen") {
            if ((Test-Path $userRegistryPath)) {
                $valueData =  (Get-ItemProperty -Path $userRegistryPath -Name $registryValueName).$registryValueName
                echo " $username -> $valueData"
                Set-ItemProperty -Path $userRegistryPath -Name $registryValueName -Value $registryValueData
 
            }
        #}
 
        # Break out of the loop since we found and processed the current user
 
 
    }
}
windows/registry/script.txt · Zuletzt geändert: 2024/01/17 09:27 von max

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki