If the PowerShell environment throws an error regarding the package name or source, you can use the Deployment Image Servicing and Management (DISM) command, which functions effectively the same way for this feature.
Although often not required, restart your PC if prompted or if the viewer doesn’t appear: install xps viewer windows 11 powershell
Restart-Computer
DISM /Online /Add-Capability /CapabilityName:XPS.Viewer~~~~0.0.1.0 If the PowerShell environment throws an error regarding
: If the "Optional Features" list in Settings is empty or failing to load, PowerShell bypasses the GUI to install the package directly from Microsoft's servers. install xps viewer windows 11 powershell
: If Add-WindowsCapability doesn't work, try this DISM (Deployment Image Servicing and Management) command in an elevated PowerShell window: DISM /Online /Add-Capability /CapabilityName:XPS.Viewer~~~~0.0.1.0 Alternative: Installing via Settings GUI