Recall Özelliğini Windows11 Sisteminden Söküp Atan PS1 Betiği

Programlama ve Script dilleri konusunda bilgi paylaşım alanıdır.
Cevapla
Kullanıcı avatarı
TRWE_2012
Zettabyte1
Zettabyte1
Mesajlar: 15428
Kayıt: 25 Eyl 2013, 13:38
cinsiyet: Erkek
Teşekkür etti: 2622 kez
Teşekkür edildi: 5494 kez

Recall Özelliğini Windows11 Sisteminden Söküp Atan PS1 Betiği

Mesaj gönderen TRWE_2012 »

Merhabalar

Bu forum konusu ,

Recall özelliğini devre dışı bırakın veya etkinleştirin
https://www.sordum.net/91057/recall-oze ... nlestirin/

makale'den hareket edilerek oluşturulmuştur.

Betiğin mantığı aşağıdaki tablo'da özetlenmiştir.
Resim
Ekran Görüntüsü , Sistem : Windows11.24H2.R7019 x64 Home
Resim
Manage-Recall_v3.ps1 Betiğinin İçeriği :

Kod: Tümünü seç

[CmdletBinding(SupportsShouldProcess)]
param(
    [Parameter(Mandatory)]
    [ValidateSet('Disable','Enable','Status')]
    [string]$Action
)

# ------------------------------------------------------------
# Yönetici kontrolü
# ------------------------------------------------------------
$principal = New-Object Security.Principal.WindowsPrincipal(
    [Security.Principal.WindowsIdentity]::GetCurrent()
)

if (-not $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
    throw 'Bu betik yönetici olarak çalıştırılmalıdır.'
}

# ------------------------------------------------------------
# Windows build kontrolü
# ------------------------------------------------------------
$os = Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion'
$build = [int]$os.CurrentBuildNumber

Write-Host "Windows Build: $build" -ForegroundColor Cyan

if ($build -lt 26100) {
    Write-Warning 'Bu sistem Windows 11 24H2 (26100+) değil. Recall özelliği mevcut olmayabilir.'
}

# ------------------------------------------------------------
# Politika yolu
# ------------------------------------------------------------
$PolicyPath = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsAI'

function Ensure-Path {
    param([string]$Path)

    if (-not (Test-Path $Path)) {
        New-Item -Path $Path -Force | Out-Null
    }
}

# ------------------------------------------------------------
# DISM üzerinden gerçek Recall durumunu oku
# ------------------------------------------------------------
function Get-RecallFeatureState {
    try {
        $output = dism /online /get-featureinfo /featurename:Recall 2>$null

        if ($LASTEXITCODE -ne 0) {
            return 'Unknown'
        }

        $stateLine = $output | Where-Object { $_ -match 'State\s*:' }

        if ($stateLine -match 'Disabled with Payload Removed') {
            return 'DisabledWithPayloadRemoved'
        }
        elseif ($stateLine -match 'Disabled') {
            return 'Disabled'
        }
        elseif ($stateLine -match 'Enabled') {
            return 'Enabled'
        }

        return 'Unknown'
    }
    catch {
        return 'Unknown'
    }
}

# ------------------------------------------------------------
# Politika durumunu oku
# ------------------------------------------------------------
function Get-RecallStatus {
    if (Test-Path $PolicyPath) {
        $value = (Get-ItemProperty -Path $PolicyPath -Name DisableAIDataAnalysis -ErrorAction SilentlyContinue).DisableAIDataAnalysis

        if ($value -eq 1) {
            return 'Disabled'
        }
        elseif ($value -eq 0) {
            return 'Enabled'
        }
    }

    return 'NotConfigured'
}

# ------------------------------------------------------------
# Recall bileşenini sistemden kaldır
# ------------------------------------------------------------
function Remove-RecallPayload {

    $featureState = Get-RecallFeatureState

    if ($featureState -eq 'DisabledWithPayloadRemoved') {
        Write-Host 'Recall zaten devre dışı ve payload sistemden kaldırılmış.' -ForegroundColor Green
        return
    }

    Write-Host ''
    Write-Host 'Recall bileşeni sistemden kaldırılabilir.' -ForegroundColor Yellow
    $choice = Read-Host 'Sistemden kaldırmayı da tetiklemek ister misiniz? (E/H)'

    if ($choice -match '^(E|e|Y|y)$') {

        Write-Host 'DISM ile Recall payload kaldırılıyor...' -ForegroundColor Cyan

        dism /online /disable-feature /featurename:Recall /Remove /NoRestart

        if ($LASTEXITCODE -eq 0) {
            Write-Host 'Recall payload başarıyla kaldırıldı.' -ForegroundColor Green
        }
        else {
            Write-Warning 'Payload kaldırma işlemi tamamlanamadı.'
        }
    }
    else {
        Write-Host 'Payload kaldırma işlemi atlandı.' -ForegroundColor DarkYellow
    }
}

# ------------------------------------------------------------
# Recall devre dışı bırak
# ------------------------------------------------------------
function Disable-Recall {

    Ensure-Path $PolicyPath

    if ($PSCmdlet.ShouldProcess('Windows Recall','Disable')) {

        New-ItemProperty -Path $PolicyPath `
            -Name 'DisableAIDataAnalysis' `
            -PropertyType DWord `
            -Value 1 `
            -Force | Out-Null

        Write-Host 'Recall politikası devre dışı bırakıldı.' -ForegroundColor Green

        # Kullanıcı isterse payload da kaldır
        Remove-RecallPayload
    }
}

# ------------------------------------------------------------
# Recall etkinleştir
# ------------------------------------------------------------
function Enable-Recall {

    Ensure-Path $PolicyPath

    $featureState = Get-RecallFeatureState

    if ($featureState -eq 'DisabledWithPayloadRemoved') {
        Write-Warning 'Recall payload sistemden kaldırılmış durumda.'
        Write-Warning 'Önce Windows Özellikleri / DISM ile bileşeni yeniden yüklemeniz gerekebilir.'
    }

    if ($PSCmdlet.ShouldProcess('Windows Recall','Enable')) {

        New-ItemProperty -Path $PolicyPath `
            -Name 'DisableAIDataAnalysis' `
            -PropertyType DWord `
            -Value 0 `
            -Force | Out-Null

        Write-Host 'Recall politikası etkinleştirildi.' -ForegroundColor Green
    }
}

# ------------------------------------------------------------
# Ana işlem
# ------------------------------------------------------------
try {

    switch ($Action) {

        'Disable' {
            Disable-Recall
        }

        'Enable' {
            Enable-Recall
        }

        'Status' {

            $policyStatus = Get-RecallStatus
            $featureState = Get-RecallFeatureState

            Write-Host "Recall Politika Durumu: $policyStatus" -ForegroundColor Yellow

            switch ($featureState) {

                'DisabledWithPayloadRemoved' {
                    Write-Host 'Sistem Bileşeni: Disabled with Payload Removed' -ForegroundColor Green
                }

                'Disabled' {
                    Write-Host 'Sistem Bileşeni: Disabled' -ForegroundColor Yellow
                }

                'Enabled' {
                    Write-Host 'Sistem Bileşeni: Enabled' -ForegroundColor Red
                }

                default {
                    Write-Host 'Sistem Bileşeni: Tespit edilemedi' -ForegroundColor DarkYellow
                }
            }
        }
    }

    Write-Host ''
    Write-Host 'İşlem tamamlandı.' -ForegroundColor Cyan
}
catch {
    Write-Error $_.Exception.Message
    exit 1
}
finally {
    Write-Host ''
    Read-Host 'Betikten çıkmak için ENTER''a basın'
}
Ardından yönetici komut isteminde şunu çalıştırın.

Kod: Tümünü seç

gpupdate /force
Resim
Sistem re-start

Geçmiş olsun işe yaramaz bir özellikten kurtuldunuz.Ve makale için teşekkürler @Tarkan_dost....
Cevapla

“Programlama ve Script dilleri” sayfasına dön