Public/Enable-CopilotAIFeature.ps1

function Enable-CopilotAIFeature {
    <#
    .SYNOPSIS
        Re-enables Windows AI features on Copilot+ PCs.

    .DESCRIPTION
        Reverses the changes made by Disable-CopilotAIFeature. Removes
        restrictive registry policies, re-enables services, and re-enables
        scheduled tasks for specified Windows AI features.

        Features:
        - Recall: Re-enables Windows Recall
        - ClickToDo: Re-enables Click to Do
        - WindowsAI: Re-enables the Windows AI Fabric Service (WSAIFabricSvc)
        - All: Re-enables all of the above

    .PARAMETER Feature
        One or more features to re-enable. Accepts multiple values.

    .EXAMPLE
        Enable-CopilotAIFeature -Feature All

        Re-enable all Windows AI features.

    .EXAMPLE
        Enable-CopilotAIFeature -Feature Recall -WhatIf

        Preview the changes that would re-enable Windows Recall.

    .LINK
        https://github.com/DailenG/WinslopFix
    #>

    [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Medium')]
    param(
        [Parameter(Mandatory)]
        [ValidateSet('Recall', 'ClickToDo', 'WindowsAI', 'All')]
        [string[]]$Feature
    )

    process {
        Assert-Administrator

        # Expand 'All' into individual features
        if ('All' -in $Feature) {
            $Feature = @('Recall', 'ClickToDo', 'WindowsAI')
        }

        $results = [System.Collections.Generic.List[PSCustomObject]]::new()

        # --- Recall ---
        if ('Recall' -in $Feature) {
            $regPath = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsAI'

            if ($PSCmdlet.ShouldProcess('Windows Recall', 'Remove restrictive registry policies')) {
                if (Test-Path -LiteralPath $regPath) {
                    Remove-ItemProperty -Path $regPath -Name 'DisableAIDataAnalysis' -ErrorAction SilentlyContinue
                    Remove-ItemProperty -Path $regPath -Name 'DisableRecall'         -ErrorAction SilentlyContinue
                    Remove-ItemProperty -Path $regPath -Name 'AllowRecallEnablement' -ErrorAction SilentlyContinue
                    Write-Verbose 'Recall registry policies removed.'
                }
            }

            # Re-enable Recall service
            if ($PSCmdlet.ShouldProcess('ScreenshotIndexerService', 'Set startup type to Manual')) {
                $svc = Get-Service -Name 'ScreenshotIndexerService' -ErrorAction SilentlyContinue
                if ($svc) {
                    Set-Service -Name 'ScreenshotIndexerService' -StartupType Manual -ErrorAction SilentlyContinue
                    Write-Verbose 'ScreenshotIndexerService set to Manual startup.'
                }
            }

            # Re-enable Recall scheduled tasks
            if ($PSCmdlet.ShouldProcess('Recall Scheduled Tasks', 'Enable AI snapshot tasks')) {
                $recallTasks = Get-ScheduledTask -TaskPath '\Microsoft\Windows\WindowsAI\' -ErrorAction SilentlyContinue |
                    Where-Object { $_.TaskName -match 'Recall|Snapshot|ScreenshotIndex' }

                foreach ($task in $recallTasks) {
                    Enable-ScheduledTask -InputObject $task -ErrorAction SilentlyContinue | Out-Null
                    Write-Verbose "Enabled scheduled task: $($task.TaskName)"
                }
            }

            Write-WinslopFixLog -Message 'Windows Recall re-enabled (registry, service, tasks).' -EventId 4001

            $results.Add([PSCustomObject]@{
                Feature = 'Recall'
                Action  = 'Enabled'
                Details = 'Registry policies removed, ScreenshotIndexerService set to Manual, scheduled tasks enabled'
            })
        }

        # --- Click to Do ---
        if ('ClickToDo' -in $Feature) {
            $regPath = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsAI'

            if ($PSCmdlet.ShouldProcess('Click to Do', 'Remove restrictive registry policy')) {
                if (Test-Path -LiteralPath $regPath) {
                    Remove-ItemProperty -Path $regPath -Name 'DisableClickToDo' -ErrorAction SilentlyContinue
                    Write-Verbose 'Click to Do registry policy removed.'
                }
            }

            Write-WinslopFixLog -Message 'Click to Do re-enabled via registry.' -EventId 4001

            $results.Add([PSCustomObject]@{
                Feature = 'ClickToDo'
                Action  = 'Enabled'
                Details = 'Registry policy removed: DisableClickToDo'
            })
        }

        # --- Windows AI Fabric Service ---
        if ('WindowsAI' -in $Feature) {
            if ($PSCmdlet.ShouldProcess('WSAIFabricSvc', 'Set startup type to Automatic and start')) {
                $svc = Get-Service -Name 'WSAIFabricSvc' -ErrorAction SilentlyContinue
                if ($svc) {
                    Set-Service  -Name 'WSAIFabricSvc' -StartupType Automatic -ErrorAction SilentlyContinue
                    Start-Service -Name 'WSAIFabricSvc' -ErrorAction SilentlyContinue
                    Write-Verbose 'WSAIFabricSvc set to Automatic and started.'
                }
                else {
                    Write-Verbose 'WSAIFabricSvc not found (may not exist on this build).'
                }
            }

            # Re-enable all Windows AI scheduled tasks
            if ($PSCmdlet.ShouldProcess('Windows AI Scheduled Tasks', 'Enable all AI tasks')) {
                $aiTasks = Get-ScheduledTask -TaskPath '\Microsoft\Windows\WindowsAI\' -ErrorAction SilentlyContinue

                foreach ($task in $aiTasks) {
                    Enable-ScheduledTask -InputObject $task -ErrorAction SilentlyContinue | Out-Null
                    Write-Verbose "Enabled scheduled task: $($task.TaskName)"
                }
            }

            Write-WinslopFixLog -Message 'Windows AI Fabric Service re-enabled (service, scheduled tasks).' -EventId 4001

            $results.Add([PSCustomObject]@{
                Feature = 'WindowsAI'
                Action  = 'Enabled'
                Details = 'WSAIFabricSvc set to Automatic, all WindowsAI scheduled tasks enabled'
            })
        }

        return $results
    }
}