Skip to content

Apply tweaks to all users instead of only current user by using a for-each loop #3602

@TheBeardofKnowledge

Description

@TheBeardofKnowledge

⚙️ Issue Checklist

  • I have read the guidelines.
  • I checked for duplicate issues.
  • I searched for existing discussions.
  • I checked for an existing pull request that addresses this request.

❓ Is your feature request related to a problem?

Apply optimizations to all users instead of HKCU:
Update the script to do a for-each loop and apply the tweaks to each user that logs on, example:

💡 Describe the solution you'd like

Define the registry path for HKEY_USERS

$registryPath = "HKU:"

Get all subkeys under HKEY_USERS

$subKeys = Get-ChildItem -Path $registryPath

Loop through each subkey

foreach ($subKey in $subKeys) {
# Display the subkey name (SID)
Write-Host "SubKey (SID): $($subKey.PSChildName)"

# Check if the subkey has a specific value (e.g., Environment variables)
$envKeyPath = "$($subKey.PSPath)\Environment"
if (Test-Path $envKeyPath) {
    $envValues = Get-ItemProperty -Path $envKeyPath
    Write-Host "Environment Variables:"
    $envValues.PSObject.Properties | ForEach-Object {
        Write-Host "  $($_.Name): $($_.Value)"
    }
} else {
    Write-Host "No Environment Variables found for this user."
}

Write-Host "-----------------------------------"

}

🔄 Describe alternatives you've considered

No response

🖼️ Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions