Enable Windows Features using Group Policy

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
Exchange NoobAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

oBdACommented:
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

Exchange NoobAuthor 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?
oBdACommented:
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

Exchange NoobAuthor Commented:
Hi, thanks again but that also didn't work.

I did some more digging and managed to resolve this myself but creating a .bat file with DISM /online /enable-feature /featurename:MediaPlayback and running this as a startup script

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.