We help IT Professionals succeed at work.

Enable Windows Features using Group Policy

608 Views
1 Endorsement
Last Modified: 2020-07-21
Hi,

I need to turn on the Windows Media Player Feature in Windows 10 for a large number of domain joined computers.

I know how to do it manually via 'Control Panel - Add Windows Features' and have found articles describing how to enable this feature via PowerShell or Command Prompt.

My question is how to do this via Group Policy. I've tried a number of different ways eg. creating a batch file and adding it to the Logon GPO, running PowerShell via GPO etc but nothing seems to be working. Not sure if this is because users are not local admins?

Has anyone done something like this before and can you please point me in the right direction?
Thanks
Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2019
Most Valuable Expert 2018

Commented:
You need to run it as a Computer Startup script applied to the computers in question, not as a logon script. Adding features requires elevation.
The script should be as easy as
If ((Get-WindowsOptionalFeature -Online -FeatureName WindowsMediaPlayer).State -ne 'Enabled')
	Enable-WindowsOptionalFeature -FeatureName WindowsMediaPlayer -Online
}

Open in new window

Author

Commented:
Hi, that's similar to what I was trying but it still doesn't work i'm afraid. I'm not sure if it's becasue of an execution policy restriction?
CERTIFIED EXPERT
Most Valuable Expert 2019
Most Valuable Expert 2018

Commented:
If this has never been configured, then that could be a reason, yes.
Save this as Whatever.cmd and deploy it as batch (you could optionally set the executionpolicy as well, while you're at it ...):
@PowerShell.exe -Command "Invoke-Expression -Command ((Get-Content -Path '%~f0' | Select-Object -Skip 2) -join [environment]::NewLine)"
@exit /b %Errorlevel%

If ((Get-WindowsOptionalFeature -Online -FeatureName WindowsMediaPlayer).State -ne 'Enabled')
	Enable-WindowsOptionalFeature -FeatureName WindowsMediaPlayer -Online
} 

Open in new window

This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
hi

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions