0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

MicrosoftEdge_シンプル化_設定ツール(PowerShellのみで動作)

0
Last updated at Posted at 2026-10-13

0. はじめに

これで右上の(無印)Copilotアイコン とも1発でアリーヴェデルチおさらばです!
MicrosoftEdge_シンプル化_設定ツール.avif

MicrosoftEdge_シンプル化_設定ツール.png

パスワードマネージャのOFFや、閉じるときに閲覧データをクリア(全選択)なども行っているので、
ご利用時はお好みに合わせて変更してください。

これもバイブコーディング(Gemini3.8Flash)ですが、
「今のレジストリの値などを取得しておいて!→いまシンプル化の設定完了したよ確認して!」などLLMと人類との共同作業になっております。

※ちなみにGeminiはいまいちPowerShellがちょっと不得意っぽい感じですよね?
でも3.1Proや3.5Flashの時よりも格段に良くなっているとは思いますが。

1. 実際のコード

※MicrosoftEdge バージョン 155.0.4283.45 (公式ビルド) (64 ビット) で動作確認済み

MicrosoftEdge_シンプル化_設定ツール.cmd
@echo off
setlocal
chcp 65001 >nul
title Edge シンプル化・プライバシー設定(ユーザー設定)

set "PS_TMP=%TEMP%\edge_setup_%RANDOM%.ps1"
powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "$f=$false; Get-Content -LiteralPath '%~f0' -Encoding UTF8 | ForEach-Object { if ($f) { $_ } elseif ($_ -match '^# === POWERSHELL ===') { $f=$true; $_ } } | Set-Content -LiteralPath '%PS_TMP%' -Encoding UTF8"
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "%PS_TMP%"
set "EXIT_CODE=%ERRORLEVEL%"
del "%PS_TMP%" 2>nul

echo.
pause
exit /b %EXIT_CODE%

# === POWERSHELL ===
# Edgeをシンプルなページ構成にする(ユーザー設定版・PowerShellのみで動作)

Write-Host "========================================================" -ForegroundColor Cyan
Write-Host " Microsoft Edge シンプル化 設定ツール" -ForegroundColor Cyan
Write-Host " (純粋なユーザープロファイル設定 / PowerShell版)" -ForegroundColor Cyan
Write-Host "========================================================`n" -ForegroundColor Cyan

Write-Host " [1] シンプル化を【有効化】する" -ForegroundColor White
Write-Host "     ・新しいタブ: コンテンツ・フィード非表示 / 天気・挨拶非表示 / 背景無地" -ForegroundColor Gray
Write-Host "     ・起動時: 白紙ページ(about:blank)を開く" -ForegroundColor Gray
Write-Host "     ・ツールバー: Copilotボタン非表示 / サイドバー非表示" -ForegroundColor Gray
Write-Host "     ・プライバシー: パスワード保存確認OFF / 終了時に閲覧データ全消去" -ForegroundColor Gray
Write-Host "     ・その他: ダウンロード先確認ON / ショッピング機能OFF" -ForegroundColor Gray
Write-Host ""
Write-Host " [2] シンプル化を【無効化】する(標準・既定設定に戻す)" -ForegroundColor White
Write-Host "     ・新しいタブ: コンテンツ・フィード表示 / 天気・挨拶表示 / 背景画像ON" -ForegroundColor Gray
Write-Host "     ・起動時: 新しいタブ ページを開く(既定)" -ForegroundColor Gray
Write-Host "     ・ツールバー: Copilotボタン表示 / サイドバー表示" -ForegroundColor Gray
Write-Host "     ・プライバシー: パスワード保存確認ON / 終了時の閲覧データ消去OFF" -ForegroundColor Gray
Write-Host "     ・その他: ダウンロード先確認OFF / ショッピング機能ON" -ForegroundColor Gray
Write-Host ""
Write-Host " [0] 終了する(何もしない)" -ForegroundColor White
Write-Host "========================================================" -ForegroundColor Cyan

$choice = ""
while ($true) {
    $choice = (Read-Host "処理番号を入力してください (1: 有効化 / 2: 無効化 / 0: 終了)").Trim()
    if ($choice -in @('0', '1', '2')) {
        break
    }
    Write-Host "無効な入力です。0, 1, 2 のいずれかを入力してください。" -ForegroundColor Red
}

if ($choice -eq '0') {
    Write-Host "`n処理をキャンセルしました。終了します。" -ForegroundColor Yellow
    exit 0
}

Write-Host ""

# 1. Edge が起動中の場合は終了(起動したままだと設定ファイルが上書きされるため)
$edgeProcesses = Get-Process -Name msedge -ErrorAction SilentlyContinue
if ($edgeProcesses) {
    Write-Host "[確認] 実行中の Microsoft Edge を終了しています..." -ForegroundColor Yellow
    Stop-Process -Name msedge -Force -ErrorAction SilentlyContinue
    Start-Sleep -Seconds 2
    if (Get-Process -Name msedge -ErrorAction SilentlyContinue) {
        taskkill /F /IM msedge.exe >$null 2>&1
        Start-Sleep -Seconds 1
    }
}

# 2. Edge の Preferences ファイルパスを取得
$PrefPath = "$env:LOCALAPPDATA\Microsoft\Edge\User Data\Default\Preferences"
if (-not (Test-Path -LiteralPath $PrefPath)) {
    Write-Error "Edgeのユーザープロファイルが見つかりません: $PrefPath"
    Write-Host "※Edge を一度も起動していない場合は、一度起動してから再実行してください。" -ForegroundColor Yellow
    exit 1
}

# 3. Preferences(JSON設定)を更新・削除するヘルパー関数
function Set-JsonProp {
    param(
        [Parameter(Mandatory = $true)] $Target,
        [Parameter(Mandatory = $true)] [string] $Name,
        $Value
    )
    if ($Target.PSObject.Properties[$Name]) {
        $Target.$Name = $Value
    } else {
        $Target | Add-Member -MemberType NoteProperty -Name $Name -Value $Value -Force
    }
}

function Remove-JsonProp {
    param(
        [Parameter(Mandatory = $true)] $Target,
        [Parameter(Mandatory = $true)] [string] $Name
    )
    if ($Target.PSObject.Properties[$Name]) {
        $Target.PSObject.Properties.Remove($Name)
    }
}

function Ensure-JsonObj {
    param(
        [Parameter(Mandatory = $true)] $Target,
        [Parameter(Mandatory = $true)] [string] $Name
    )
    if (-not $Target.PSObject.Properties[$Name] -or $null -eq $Target.$Name -or $Target.$Name -isnot [System.Management.Automation.PSCustomObject]) {
        $newObj = [PSCustomObject]@{}
        Set-JsonProp $Target $Name $newObj
        return $newObj
    }
    return $Target.$Name
}

# 4. Preferences の読み込みと設定の適用
$success = $false
try {
    # バックアップを作成
    Copy-Item -LiteralPath $PrefPath -Destination ($PrefPath + ".bak") -Force

    $jsonContent = [System.IO.File]::ReadAllText($PrefPath, [System.Text.Encoding]::UTF8)
    $d = $jsonContent | ConvertFrom-Json

    if ($choice -eq '1') {
        Write-Host "[適用中] Edgeのシンプル化・プライバシー設定を有効化しています..." -ForegroundColor Cyan

        # (1) 新しいタブ ページ(NTP)のシンプル化(カスタムモードでコンテンツ・フィード・天気を完全オフ)
        $ntp = Ensure-JsonObj $d 'ntp'
        Set-JsonProp $ntp 'layout_mode' 3                                         # Custom(3:Custom / プリセットのfocusedだと見出しフィードや天気が強制表示されるためCustomで完全OFF)
        Set-JsonProp $ntp 'news_feed_display' 'off'                               # コンテンツ・フィードの表示完全オフ
        Set-JsonProp $ntp 'background_image_type' 'off'                           # 背景画像・動画をオフ
        Set-JsonProp $ntp 'show_image_of_day' $false                              # 日替わり画像をオフ
        $bg = [PSCustomObject]@{ provider = 'NoBackground'; userSelected = $true }
        Set-JsonProp $ntp 'background_image' $bg
        Set-JsonProp $ntp 'enable_widgets_region' $false                           # ウィジェット領域をオフ
        Set-JsonProp $ntp 'show_weather' $false                                    # 天気をオフ
        Set-JsonProp $ntp 'show_greeting' $false                                   # 挨拶・天気をオフ(画面の「天気を表示」トグル)
        Set-JsonProp $ntp 'quick_links_options' 0                                 # クイックリンク(トップサイト)をオフ
        Set-JsonProp $ntp 'hide_default_top_sites' $true                           # 既定のトップサイトを非表示
        Set-JsonProp $ntp 'num_personal_suggestions' 0                            # おすすめ・ニュース候補をオフ
        Set-JsonProp $ntp 'topsites_open_in_new_tab' $false

        # Edge の UI 選択履歴(record_user_choices)にオフ設定を明示
        $now = [long]((Get-Date).ToUniversalTime() - [datetime]'1970-01-01').TotalMilliseconds
        $userChoices = @(
            [PSCustomObject]@{ setting = "layout_mode"; source = "ntp"; timestamp = $now; value = 3 },
            [PSCustomObject]@{ setting = "ntp.news_feed_display"; source = "ntp"; timestamp = $now; value = "off" },
            [PSCustomObject]@{ setting = "quick_links_options"; source = "ntp"; timestamp = $now; value = "off" },
            [PSCustomObject]@{ setting = "tscollapsed"; source = "updatePrefTSCollapsed"; timestamp = $now; value = 0 },
            [PSCustomObject]@{ setting = "search_history"; source = "ntp"; timestamp = $now; value = $false },
            [PSCustomObject]@{ setting = "current_location_enabled"; source = "ntp"; timestamp = $now; value = $false },
            [PSCustomObject]@{ setting = "ntp.show_greeting"; source = "ntp"; timestamp = $now; value = $false },
            [PSCustomObject]@{ setting = "show_greeting"; source = "ntp"; timestamp = $now; value = $false }
        )
        Set-JsonProp $ntp 'record_user_choices' $userChoices

        # user_nurturing のフィード履歴もオフ(to = 0)に更新
        if ($ntp.user_nurturing) {
            foreach ($item in $ntp.user_nurturing) {
                if ($item.key -eq 'layoutHistory' -and $item.value -and $item.value.userLayoutHistory) {
                    $item.value.userLayoutHistory.to = 0
                    $item.value.userLayoutHistory.time = $now
                }
                if ($item.key -eq 'tscollapsed_to_off' -and $item.value) {
                    $item.value.selectedQuickLinksDisplaySetting = 'off'
                }
            }
        }

        # (2) 起動時に特定のページ(about:blank)を開く
        $session = Ensure-JsonObj $d 'session'
        Set-JsonProp $session 'restore_on_startup' 4
        Set-JsonProp $session 'startup_urls' ([string[]]@('about:blank'))

        # (3) ツールバーの Copilot ボタンおよびサイドバーの非表示
        $browser = Ensure-JsonObj $d 'browser'
        Set-JsonProp $browser 'show_discover_toolbar_button' $false                # Copilotボタン非表示
        Set-JsonProp $browser 'show_toolbar_edge_generic_sidebar_button' $false   # サイドバー非表示

        # (4) パスワードマネージャー無効化(「保存するように依頼する」をOFF)
        Set-JsonProp $d 'credentials_enable_service' $false
        $profile = Ensure-JsonObj $d 'profile'
        Set-JsonProp $profile 'password_manager_enabled' $false

        # (5) 閉じるときに閲覧データをクリア(全項目ON)
        # ※Edge の設定画面は browser.clear_data_on_exit を参照するため両方に適用
        $clear_data = Ensure-JsonObj $browser 'clear_data_on_exit'
        Set-JsonProp $clear_data 'browsing_history' $true                          # 閲覧の履歴
        Set-JsonProp $clear_data 'download_history' $true                          # ダウンロードの履歴
        Set-JsonProp $clear_data 'cookies' $true                                   # Cookieおよびその他のサイトデータ
        Set-JsonProp $clear_data 'cache' $true                                     # キャッシュされた画像とファイル
        Set-JsonProp $clear_data 'site_settings' $true                             # サイトのアクセス許可
        Set-JsonProp $clear_data 'passwords' $true                                 # パスワード
        Set-JsonProp $clear_data 'form_data' $true                                 # オートフィル フォーム データ
        Set-JsonProp $clear_data 'hosted_apps_data' $true                          # ホストされたアプリのデータ

        $root_clear_data = Ensure-JsonObj $d 'clear_data_on_exit'
        Set-JsonProp $root_clear_data 'browsing_history' $true
        Set-JsonProp $root_clear_data 'download_history' $true
        Set-JsonProp $root_clear_data 'cookies' $true
        Set-JsonProp $root_clear_data 'cache' $true
        Set-JsonProp $root_clear_data 'site_settings' $true
        Set-JsonProp $root_clear_data 'passwords' $true
        Set-JsonProp $root_clear_data 'form_data' $true
        Set-JsonProp $root_clear_data 'hosted_apps_data' $true

        # (6) ダウンロードする前に各ファイルの保存先を確認する(有効化)
        $download = Ensure-JsonObj $d 'download'
        Set-JsonProp $download 'prompt_for_download' $true

        # (7) ショッピング機能(クーポン等)の無効化
        $shopping = Ensure-JsonObj $d 'shopping'
        Set-JsonProp $shopping 'contextual_features_enabled' $false
        Set-JsonProp $shopping 'rdx_mode_enabled' $false

    } elseif ($choice -eq '2') {
        # ========================================================
        # 無効化(シンプル化を解除 / 標準設定に戻す)
        # ========================================================
        Write-Host "[適用中] Edgeのシンプル化を無効化し、標準設定に戻しています..." -ForegroundColor Cyan

        # (1) 新しいタブ ページ(NTP)の標準化
        $ntp = Ensure-JsonObj $d 'ntp'
        Set-JsonProp $ntp 'layout_mode' 1                                         # Inspirational(イメージ・標準 / 1:Inspirational)
        Set-JsonProp $ntp 'news_feed_display' 'always'                            # ニュースフィード常時表示
        Set-JsonProp $ntp 'background_image_type' 'imageAndVideo'                 # 背景画像標準(日替わり画像・動画)
        Set-JsonProp $ntp 'show_image_of_day' $true                               # 日替わり画像ON
        Remove-JsonProp $ntp 'background_image'                                   # NoBackground設定を削除
        Set-JsonProp $ntp 'enable_widgets_region' $true                            # ウィジェットON
        Set-JsonProp $ntp 'show_weather' $true                                     # 天気ON
        Set-JsonProp $ntp 'show_greeting' $true                                    # 挨拶・天気ON
        Set-JsonProp $ntp 'quick_links_options' 1                                  # クイックリンク(1行表示)
        Set-JsonProp $ntp 'hide_default_top_sites' $false                          # トップサイト表示
        Set-JsonProp $ntp 'num_personal_suggestions' 1                             # おすすめON
        Set-JsonProp $ntp 'topsites_open_in_new_tab' $true

        # Edge の UI 選択履歴(record_user_choices)に標準設定を明示
        $now = [long]((Get-Date).ToUniversalTime() - [datetime]'1970-01-01').TotalMilliseconds
        $userChoices = @(
            [PSCustomObject]@{ setting = "layout_mode"; source = "ntp"; timestamp = $now; value = 1 },
            [PSCustomObject]@{ setting = "ntp.news_feed_display"; source = "ntp"; timestamp = $now; value = "always" },
            [PSCustomObject]@{ setting = "quick_links_options"; source = "ntp"; timestamp = $now; value = "onerow" },
            [PSCustomObject]@{ setting = "ntp.show_greeting"; source = "ntp"; timestamp = $now; value = $true },
            [PSCustomObject]@{ setting = "show_greeting"; source = "ntp"; timestamp = $now; value = $true }
        )
        Set-JsonProp $ntp 'record_user_choices' $userChoices

        # (2) 起動時設定を標準に戻す(新しいタブを開く)
        $session = Ensure-JsonObj $d 'session'
        Set-JsonProp $session 'restore_on_startup' 5                              # 新しいタブ ページを開く(既定)
        Set-JsonProp $session 'startup_urls' ([string[]]@())

        # (3) ツールバーを標準に戻す
        $browser = Ensure-JsonObj $d 'browser'
        Set-JsonProp $browser 'show_discover_toolbar_button' $true                 # Copilotボタン表示
        Set-JsonProp $browser 'show_toolbar_edge_generic_sidebar_button' $true    # サイドバー表示

        # (4) パスワードマネージャー有効化(「保存するように依頼する」をON)
        Set-JsonProp $d 'credentials_enable_service' $true
        $profile = Ensure-JsonObj $d 'profile'
        Set-JsonProp $profile 'password_manager_enabled' $true

        # (5) 閉じるときに閲覧データをクリアを無効化(全項目OFF)
        $clear_data = Ensure-JsonObj $browser 'clear_data_on_exit'
        Set-JsonProp $clear_data 'browsing_history' $false
        Set-JsonProp $clear_data 'download_history' $false
        Set-JsonProp $clear_data 'cookies' $false
        Set-JsonProp $clear_data 'cache' $false
        Set-JsonProp $clear_data 'site_settings' $false
        Set-JsonProp $clear_data 'passwords' $false
        Set-JsonProp $clear_data 'form_data' $false
        Set-JsonProp $clear_data 'hosted_apps_data' $false

        $root_clear_data = Ensure-JsonObj $d 'clear_data_on_exit'
        Set-JsonProp $root_clear_data 'browsing_history' $false
        Set-JsonProp $root_clear_data 'download_history' $false
        Set-JsonProp $root_clear_data 'cookies' $false
        Set-JsonProp $root_clear_data 'cache' $false
        Set-JsonProp $root_clear_data 'site_settings' $false
        Set-JsonProp $root_clear_data 'passwords' $false
        Set-JsonProp $root_clear_data 'form_data' $false
        Set-JsonProp $root_clear_data 'hosted_apps_data' $false

        # (6) ダウンロードする前に各ファイルの保存先を確認する(無効化)
        $download = Ensure-JsonObj $d 'download'
        Set-JsonProp $download 'prompt_for_download' $false

        # (7) ショッピング機能(クーポン等)の有効化
        $shopping = Ensure-JsonObj $d 'shopping'
        Set-JsonProp $shopping 'contextual_features_enabled' $true
        Set-JsonProp $shopping 'rdx_mode_enabled' $true
    }

    # JSON を UTF-8(BOMなし)で保存
    $utf8NoBom = New-Object System.Text.UTF8Encoding($false)
    $newJson = $d | ConvertTo-Json -Depth 100
    [System.IO.File]::WriteAllText($PrefPath, $newJson, $utf8NoBom)

    # ntp.msn.com の IndexedDB キャッシュをクリア(古いフィード・天気表示キャッシュの持ち越しを防止)
    $idb = "$env:LOCALAPPDATA\Microsoft\Edge\User Data\Default\IndexedDB\https_ntp.msn.com_0.indexeddb.leveldb"
    if (Test-Path $idb) {
        Remove-Item -Path $idb -Recurse -Force -ErrorAction SilentlyContinue
    }

    $success = $true
} catch {
    Write-Error "Preferences の更新中にエラーが発生しました: $_"
    $success = $false
}

# 5. 以前のレジストリポリシー(組織管理設定)が残っていれば解除
# これにより「組織によって管理されています」の表示を完全に解除します
$policyPath = "HKCU:\Software\Policies\Microsoft\Edge"
if (Test-Path $policyPath) {
    Remove-Item -Path $policyPath -Recurse -Force -ErrorAction SilentlyContinue
    Write-Host "[解除] 以前のポリシー設定(組織管理)を解除しました。" -ForegroundColor Yellow
}

if ($success) {
    if ($choice -eq '1') {
        Write-Host "[成功] プロファイル Preferences 設定(ユーザー設定)を更新しました。" -ForegroundColor Green
        Write-Host "`n========================================================" -ForegroundColor Green
        Write-Host " 【シンプル化を有効化しました】" -ForegroundColor Green
        Write-Host "========================================================" -ForegroundColor Green
        Write-Host "  ・「組織によって管理されています」のポリシー表示を解除" -ForegroundColor Gray
        Write-Host "  ・新しいタブ: コンテンツ・フィード完全非表示 / 天気・挨拶非表示 / 背景無地" -ForegroundColor Gray
        Write-Host "  ・起動時設定: about:blank(真っ白な画面)を開く" -ForegroundColor Gray
        Write-Host "  ・ツールバー: Copilotボタン非表示 / サイドバー非表示" -ForegroundColor Gray
        Write-Host "  ・パスワード: 保存確認を無効化(OFF)" -ForegroundColor Gray
        Write-Host "  ・終了時クリア: 履歴 / DL履歴 / Cookie / キャッシュ / サイト権限 を全消去(ON)" -ForegroundColor Gray
        Write-Host "  ・ダウンロード: 保存先の事前確認を有効化(ON)" -ForegroundColor Gray
        Write-Host "  ・ショッピング: クーポン・比較機能を無効化(OFF)" -ForegroundColor Gray
        Write-Host "`nEdge を起動してご確認ください!" -ForegroundColor Cyan
    } else {
        Write-Host "[成功] プロファイル Preferences 設定(ユーザー設定)を更新しました。" -ForegroundColor Green
        Write-Host "`n========================================================" -ForegroundColor Green
        Write-Host " 【シンプル化を無効化しました(標準設定に復帰)】" -ForegroundColor Green
        Write-Host "========================================================" -ForegroundColor Green
        Write-Host "  ・「組織によって管理されています」のポリシー表示を解除" -ForegroundColor Gray
        Write-Host "  ・新しいタブ: コンテンツ・フィード表示 / 天気・挨拶表示 / 背景画像ON" -ForegroundColor Gray
        Write-Host "  ・起動時設定: 新しいタブ ページを開く(既定)" -ForegroundColor Gray
        Write-Host "  ・ツールバー: Copilotボタン表示 / サイドバー表示" -ForegroundColor Gray
        Write-Host "  ・パスワード: 保存確認を有効化(ON)" -ForegroundColor Gray
        Write-Host "  ・終了時クリア: 閲覧データの自動クリアを解除(OFF)" -ForegroundColor Gray
        Write-Host "  ・ダウンロード: 保存先の事前確認を解除(OFF / 既定フォルダに直接保存)" -ForegroundColor Gray
        Write-Host "  ・ショッピング: クーポン・比較機能を有効化(ON)" -ForegroundColor Gray
        Write-Host "`nEdge を起動してご確認ください!" -ForegroundColor Cyan
    }
} else {
    Write-Warning "設定の反映中にエラーが発生しました。"
}

以上です。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?