handle error when edge has never been opened before #82

This commit is contained in:
zoicware
2025-12-16 22:25:53 -05:00
committed by GitHub
parent fcc67f686e
commit 3d8aab5fa1

View File

@@ -275,7 +275,8 @@ function Disable-Registry-Keys {
#powershell core bug where json that has empty strings will error #powershell core bug where json that has empty strings will error
$jsonContent = (Get-Content $config).Replace('""', '"_empty"') | ConvertFrom-Json $jsonContent = (Get-Content $config).Replace('""', '"_empty"') | ConvertFrom-Json
if (($jsonContent.browser | Get-Member -MemberType NoteProperty enabled_labs_experiments) -eq $null) { try {
if (($jsonContent.browser | Get-Member -MemberType NoteProperty enabled_labs_experiments -ErrorAction Stop) -eq $null) {
$jsonContent.browser | Add-Member -MemberType NoteProperty -Name enabled_labs_experiments -Value @() $jsonContent.browser | Add-Member -MemberType NoteProperty -Name enabled_labs_experiments -Value @()
} }
$flags = @( $flags = @(
@@ -299,6 +300,12 @@ function Disable-Registry-Keys {
$newContent = $newContent.replace('"_empty"', '""') $newContent = $newContent.replace('"_empty"', '""')
Set-Content $config -Value $newContent -Encoding UTF8 -Force Set-Content $config -Value $newContent -Encoding UTF8 -Force
} }
catch {
Write-Status -msg 'Edge Browser has never been opened on this machine unable to set flags...' -errorOutput $true
Write-Status -msg 'Open Edge once and run this tweak again' -errorOutput $true
}
}
#disable office ai with group policy #disable office ai with group policy
Reg.exe add 'HKLM\SOFTWARE\Policies\Microsoft\office\16.0\common\ai\training\general' /v 'disabletraining' /t REG_DWORD /d @('1', '0')[$revert] /f *>$null Reg.exe add 'HKLM\SOFTWARE\Policies\Microsoft\office\16.0\common\ai\training\general' /v 'disabletraining' /t REG_DWORD /d @('1', '0')[$revert] /f *>$null