categories/Recall.ps1

# Recall category: DisableAIDataAnalysis policy value (turns off Recall snapshots).

function Get-OctaRecallCategory {
    [CmdletBinding()]
    param()
    return [pscustomobject]@{
        Id                  = 'recall'
        DisplayName         = 'Recall'
        Description         = 'Disable Recall snapshots'
        RequiresElevation   = $true
        ContainsIrreversibleActions = $false
        GetActionsFunction  = 'Get-OctaRecallActions'
        ApplyActionFunction = 'Set-OctaRecallAction'
    }
}

function Get-OctaRecallActions {
    [CmdletBinding()]
    param()
    $regPath = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsAI'
    $current = $null
    if (Test-Path $regPath) {
        $current = (Get-ItemProperty -Path $regPath -Name 'DisableAIDataAnalysis' -ErrorAction SilentlyContinue).DisableAIDataAnalysis
    }
    if ($null -ne $current -and $current -eq 1) {
        return @()
    }
    $displayCurrent = if ($null -eq $current) { '(not set)' } else { $current }
    return @(
        New-OctaAction -TargetType Registry -TargetIdentifier "$regPath|DisableAIDataAnalysis" `
            -CurrentValue $displayCurrent -PlannedValue 1 -Reversible $true
    )
}

function Set-OctaRecallAction {
    [CmdletBinding()]
    param([Parameter(Mandatory)]$Action)
    $keyPath, $valueName = $Action.TargetIdentifier -split '\|', 2
    if (-not (Test-Path $keyPath)) {
        New-Item -Path $keyPath -Force | Out-Null
    }
    # PlannedValue, not a hardcoded 1 - see the same note in categories/Copilot.ps1.
    Set-ItemProperty -Path $keyPath -Name $valueName -Value $Action.PlannedValue -Type DWord
}