In this tutorial, I will explain how to solve error 0x800f0954 with the PowerShell Add-WindowsCapability Cmdlet when trying to install a Windows feature.
This error mainly occurs when you use a WSUS server to update your Windows computers and therefore when using the Cmdlet Add-WindowsCapability, it will look for files on the WSUS server.
Here is the error:

To solve this problem, you must tell the computer to use Windows Update for optional components, this configuration is done using Group Policy.
This need being punctual, I advise you to do this configuration locally.
Open the Local Group Policy Editor console: gpedit.msc.
Go to the location: Computer Configuration / Administrative Templates / System and find the setting Specify settings for installing optional components and repairing component 1, double click on it to open it.

Enable setting 1 and check the box 2 Download repair content and optional options from Windows Update instead of Windows Server Update Services (WSUS), then click Apply buttons 3> > and OK 4 to confirm and close.

Enter the gpupdate /force command to update the settings.
You should be able to run your Add-WindowsCapability command again and it should run without error.

Didn’t work for me, as WSUS was forcing too much. But a dude in another thread came up with a solution to clear the windows update policy cache. This is my working script:
# Set Windows Update options
Set-ItemProperty -Path “HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate” -Name SetPolicyDrivenUpdateSourceForDriverUpdates -Value 0
Set-ItemProperty -Path “HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate” -Name SetPolicyDrivenUpdateSourceForFeatureUpdates -Value 0
Set-ItemProperty -Path “HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate” -Name SetPolicyDrivenUpdateSourceForOtherUpdates -Value 0
Set-ItemProperty -Path “HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate” -Name SetPolicyDrivenUpdateSourceForQualityUpdates -Value 0
Set-ItemProperty -Path “HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU” -Name UseUpdateClassPolicySource -Value 0
# Clear Cache
Remove-Item -Path “HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UpdatePolicy\GPCache\CacheSet001\WindowsUpdate” -Recurse -Force
Remove-Item -Path “HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UpdatePolicy\GPCache\CacheSet002\WindowsUpdate” -Recurse -Force
# Restart Update Service
Restart-Service wuauserv
# Install FoD packages:
Add-WindowsCapability -Online -Name Rsat.ActiveDirectory.DS-LDS.Tools~~~~0.0.1.0
Add-WindowsCapability -Online -Name Rsat.GroupPolicy.Management.Tools~~~~0.0.1.0
# Restore GPO settings
gpupdate /force