From 8c19c66c954a9c5a20a502e149f2911d3ba49288 Mon Sep 17 00:00:00 2001 From: zoicware <118035521+zoicware@users.noreply.github.com> Date: Sun, 14 Dec 2025 16:00:35 -0500 Subject: [PATCH] handle empty strings in json file fix #82 --- RemoveWindowsAi.ps1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/RemoveWindowsAi.ps1 b/RemoveWindowsAi.ps1 index 38abcd0..01c617b 100644 --- a/RemoveWindowsAi.ps1 +++ b/RemoveWindowsAi.ps1 @@ -272,7 +272,8 @@ function Disable-Registry-Keys { taskkill.exe /im msedge.exe /f *>$null $config = "$env:LOCALAPPDATA\Microsoft\Edge\User Data\Local State" if (Test-Path $config) { - $jsonContent = Get-Content $config | ConvertFrom-Json + #powershell core bug where json that has empty strings will error + $jsonContent = (Get-Content $config).Replace('""', '"_empty"') | ConvertFrom-Json if (($jsonContent.browser | Get-Member -MemberType NoteProperty enabled_labs_experiments) -eq $null) { $jsonContent.browser | Add-Member -MemberType NoteProperty -Name enabled_labs_experiments -Value @() @@ -282,6 +283,8 @@ function Disable-Registry-Keys { ) $newContent = $jsonContent | ConvertTo-Json -Compress -Depth 10 + #add back the empty strings + $newContent = $newContent.replace('"_empty"', '""') Set-Content $config -Value $newContent -Encoding UTF8 -Force }