winget-cli
winget-cli copied to clipboard
Turn Windows features on and off
Part of my setup is using Docker for Windows, obviously it works best with WSL2.
It would be nice to be able to turn things on in windows for my setup to be complete.
This can be done easily with PowerShell or the Deployment Image Servicing and Management (DISM) tool. I don't see how winget would help with that...
It would be nice if winget install telnet
turned on telnet in Windows features.
Sorry but that's really just Install-WindowsFeature Telnet-Client
in PowerShell with less ambiguity about what's going to happen. Or alternatively dism /online /Enable-Feature /FeatureName:TelnetClient
with DISM.
It would help for installing the RSAT, since that's been split up into 20-someodd packages in optional features. Chocolatey has a choco install rsat
that installs all of them via a PowerShell script.
Maybe PowerShell script support as an installer type would be the real feature request? Although that may encourage bad habits, since people could bypass the manifest creation step and put all of the logic inside of a non-standard script which then has to be debugged in a different way.
If all you know is a hammer everything looks like a nail.
I'm a strong proponent of using the right tool for the job and the RSAT installation in PowerShell really is just a single line:
#### Client OS (Windows 10) - uses DISM behind the scenes
# List RSAT components that are not installed
Get-WindowsCapability -Name RSAT* -Online | Where-Object { $_.State -eq "NotPresent" }
# Install all RSAT components
Get-WindowsCapability -Name RSAT* -Online | Add-WindowsCapability –Online
#### Server OS (Server 201X) - uses Server Manager behind the scenes
# List RSAT components that are not installed
Get-WindowsFeature -Name RSAT* | Where-Object { $_.Installed -ne $true }
# Install all RSAT components
Install-WindowsFeature -Name RSAT -IncludeAllSubFeature -IncludeManagementTools
See https://hahndorf.eu/blog/WindowsFeatureViaCmd for details.
This could be part of #163 "Support for package dependencies". If you winget install ubuntu
we should be able to see if WSL is enabled or not, and take care of that for you.
If it were me, I;d keep the focus on WInget being a tool to lay down applications on developer workstations. If you need to configure a system after installation, you just use the existing PowerShell tool. THat has considerable advantages for not causing the winget guys to have to reinvent more wheels and would certainly end up with less confusing commands.
What could be done is to allow packages to define post installation configuration (like apt
has debconf
) but I'm strongly against adding option such as enabling features via winget
.
I would suggest that when we have dependencies in winget
, and the app manifest define that it depend on some windows features, winget would check if that exist and installed
If condition not meet, winget would just throw error with helpful message like suggest powershell command to install as that would allow user to communicate to IT management to enable if allowed.
As Windows feature is mostly need to be control by Administration
If you want to add/remove features, there are cmdlets for that.
Let WInget do its job and not all the other jobs it could do. Winget might have some great use cases and a great vision, but let's not reinvent wheels we do not need to.
I would suggest that when we have dependencies in
winget
, and the app manifest define that it depend on some windows features, winget would check if that exist and installed If condition not meet, winget would just throw error with helpful message like suggest powershell command to install as that would allow user to communicate to IT management to enable if allowed. As Windows feature is mostly need to be control by Administration
I can see this being useful. winget does not need to install features or optional components, Get-WindowsCapability -Name RSAT* -Online | Add-WindowsCapability –Online
works just fine as we've established but it would maybe be useful if windows features can be listed as dependencies of a package.
It pains me to say but we all know there's some software out there that requires .NET 3.5 for example. winget could test for the feaure and throw an error that a dependency is not satisfied.
@jantari we're working on the experimental dependency flow to enable Windows features. We've started seeing more packages that require .NET 3.5, and this would essentially unblock them.
It would be some future feature to look at something like winget enable <Windows feature>
and the corrolary winget disable <Windows feature>
.
- https://github.com/microsoft/winget-cli/pull/3005#event-8594350040
This would be a very nice addition to assist enterprise management and simplify how its done within Intune. I'm doing something like this at the moment.
`# Pro-Active Remediation Detect [int32]$SkipRemediate = 0 [int32]$Remediate = 1
#endregion
try { if ($(Get-WindowsOptionalFeature -Online -FeatureName 'NetFx3' -ErrorAction Stop).State -eq "Enabled") { exit $Remediate } else { exit $SkipRemediate } } catch { Write-Host $_.Exception.Message exit $Remediate } `
`# Pro-Active Remediation Remediate #region DoNotModify
[int32]$Success = 0 [int32]$Failure = 1
#endregion
try { # Disable AND remove source? # Disable-WindowsOptionalFeature -Online -FeatureName "NetFx3" -NoRestart -Remove # Disable Disable-WindowsOptionalFeature -Online -FeatureName "NetFx3" -NoRestart -ErrorAction Stop exit $Success } catch { Write-Host $_.Exception.Message exit $Failure } `
- or -
`
Win32App Requirement
If ((Get-WindowsCapability -Online -Name NetFX3~~~~).Name -eq 'NetFX3~~~~') { $Requirement = "NetFX3" } `
`
Win32App Detection
If ((Get-WindowsCapability -Online -Name NetFX3~~~~).State -eq 'Installed') { $Detection = "NetFX3" } `
We've added support for enabling Windows Features in WinGet 1.7 as a dependency of another package. As this version continues to roll out, we will be adding a manifest for WSL including the Windows Feature it depends on.
As this version continues to roll out, we will be adding a manifest for WSL including the Windows Feature it depends on.
Is this still WIP?