Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # fix_chrome_mv2_policy.ps1
- # Define the registry path and value
- $registryPath = "HKLM:\SOFTWARE\Policies\Google\Chrome"
- $registryName = "ExtensionManifestV2Availability"
- $desiredValue = 2
- # Define log path
- $logFolder = "C:\yourFOlderName\logs\registry"
- $logFile = Join-Path $logFolder "policy_log.txt"
- $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
- # Create log folder if it doesn't exist
- if (!(Test-Path -Path $logFolder)) {
- New-Item -ItemType Directory -Path $logFolder -Force | Out-Null
- }
- # Read current registry value (if it exists)
- $currentValue = Get-ItemProperty -Path $registryPath -Name $registryName -ErrorAction SilentlyContinue | Select-Object -ExpandProperty $registryName -ErrorAction SilentlyContinue
- # Check and fix the registry value if needed
- if ($currentValue -ne $desiredValue) {
- New-Item -Path $registryPath -Force | Out-Null
- Set-ItemProperty -Path $registryPath -Name $registryName -Value $desiredValue -Type DWord
- $logMessage = "$timestamp - Registry value was incorrect or missing. Set to $desiredValue."
- } else {
- $logMessage = "$timestamp - Registry value already correct. No action taken."
- }
- # Write the result to the log
- Add-Content -Path $logFile -Value $logMessage
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement