Advertisement
GOD3128

reload legacy chrome extensions-automated

Jul 14th, 2025 (edited)
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # fix_chrome_mv2_policy.ps1
  2.  
  3. # Define the registry path and value
  4. $registryPath = "HKLM:\SOFTWARE\Policies\Google\Chrome"
  5. $registryName = "ExtensionManifestV2Availability"
  6. $desiredValue = 2
  7.  
  8. # Define log path
  9. $logFolder = "C:\yourFOlderName\logs\registry"
  10. $logFile = Join-Path $logFolder "policy_log.txt"
  11. $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
  12.  
  13. # Create log folder if it doesn't exist
  14. if (!(Test-Path -Path $logFolder)) {
  15.     New-Item -ItemType Directory -Path $logFolder -Force | Out-Null
  16. }
  17.  
  18. # Read current registry value (if it exists)
  19. $currentValue = Get-ItemProperty -Path $registryPath -Name $registryName -ErrorAction SilentlyContinue | Select-Object -ExpandProperty $registryName -ErrorAction SilentlyContinue
  20.  
  21. # Check and fix the registry value if needed
  22. if ($currentValue -ne $desiredValue) {
  23.     New-Item -Path $registryPath -Force | Out-Null
  24.     Set-ItemProperty -Path $registryPath -Name $registryName -Value $desiredValue -Type DWord
  25.  
  26.     $logMessage = "$timestamp - Registry value was incorrect or missing. Set to $desiredValue."
  27. } else {
  28.     $logMessage = "$timestamp - Registry value already correct. No action taken."
  29. }
  30.  
  31. # Write the result to the log
  32. Add-Content -Path $logFile -Value $logMessage
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement