我參考了這篇文章
https://blog.miniasp.com/post/2021/12/11/How-to-setup-OpenSSH-Server-in-Windows
在無對外網路的Windows Server 2019環境下使用管理權限的PowerShell
設了Proxy如下:
$Proxy = "http://10.99.99.99:80"
$ENV:HTTP_PROXY=$proxy
$ENV:HTTPS_PROXY=$proxy
結果我想安裝個OpenSSH
PS C:\Users\JAMES\Downloads> Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Add-WindowsCapability : Add-WindowsCapability failed. Error code = 0x800f0954
At line:1 char:1
+ Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Add-WindowsCapability], COMException
+ FullyQualifiedErrorId : Microsoft.Dism.Commands.AddWindowsCapabilityCommand
其他Invoke-WebRequest都有吃到proxy 對外有通
唯獨Add-WindowsCapability無法
求解~
我有看到 0x800f0954, 可能跟群組原則某個選項有關,可以試試看改設定 (我看訊息是英文的,就以英文版的介面來說明):
Specify settings for optional component installation and component repair to open its settings
打開對話框Enabled
Download repair content and optional features directly from Windows Updates instead of Windows Server Updates Services (WSUS)
gpupdate /force
Add-WindowsCapability
我是這樣解決的,希望能幫到你。