Skip to content

Instantly share code, notes, and snippets.

@flipeador
Created April 19, 2025 01:50
Show Gist options
  • Save flipeador/68d74eb2373840aaaa2b1380f67d7b7d to your computer and use it in GitHub Desktop.
Save flipeador/68d74eb2373840aaaa2b1380f67d7b7d to your computer and use it in GitHub Desktop.
Install Windows capabilities and features with PowerShell.

Windows Capabilities & Features

Instructions

Open the Windows Terminal as Administrator and run the PowerShell script.

Install OCR Language Capabilities

Install all Windows OCR language capability packages to the system via Windows Update.

Enables text recognition capabilities to apps like Snipping Tool and PowerToys's Text Extractor.

Get-WindowsCapability -Online |
    Where-Object { $_.Name -Like 'Language.OCR~*' -And $_.State -Eq "NotPresent" } |
    ForEach-Object {
        try {
            Write-Host "Installing: $($_.Name)"
            Add-WindowsCapability -Name $_.Name -Online -ErrorAction Stop
        }
        catch {
            Write-Warning "Error: $_"
        }
    }

Install Other Capabilities

Get-WindowsCapability -Online | Where-Object { $_.Name -Like 'MathRecognizer~*' } | Add-WindowsCapability -Online
Get-WindowsCapability -Online | Where-Object { $_.Name -Like 'Tools.Graphics.DirectX~*' } | Add-WindowsCapability -Online
Get-WindowsCapability -Online | Where-Object { $_.Name -Like 'Msix.PackagingTool.Driver~*' } | Add-WindowsCapability -Online
Get-WindowsCapability -Online | Where-Object { $_.Name -Like 'Microsoft.Windows.StorageManagement~*' } | Add-WindowsCapability -Online

Export Features & Capabilities

Get-WindowsCapability -Online |
    Sort-Object {
        switch ($_.State) {
            'Installed' { 0 }
            'InstallPending' { 1 }
            'NotPresent' { 2 }
            default { 3 }
        }
    } |
    Select-Object Name, State |
    Export-Csv -Path "Capabilities.csv" -NoTypeInformation

Get-WindowsOptionalFeature -Online |
    Sort-Object {
        switch ($_.State) {
            'Enabled'   { 0 }
            'EnablePending' { 1 }
            'Disabled'  { 2 }
            default     { 3 }
        }
    } |
    Select-Object FeatureName, State |
    Export-Csv -Path "Features.csv" -NoTypeInformation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment