Problems with gpo & ps1 ...

I have an issue with a PowerShell script with GPO, my script:

Get-AppxPackage -AllUsers | where-object {$ –notlike “*camera*”} | where-object {$ –notlike “*calc*”} | where-object {$ –notlike “*photos*”} | Remove-AppxPackage
Get-appxprovisionedpackage –online | where-object {$ –notlike “*camera*”} | where-object {$ –notlike “*calc*”} | where-object {$ –notlike “*photos*”}| Remove-AppxProvisionedPackage -online

The idea is to delete all the applications provided by Microsoft in Windows 10.

I try to put it as a startup script, in the end, and don’t work.

Do you have any idea why ???

Welcome to the forum. :wave:t4:

I used something similar for a client a time ago. I don’t know if this still works but it’s worth trying. I created the list of apps the client wanted to get rid of. Of course you could turn the logic around and use a list with apps you want to keep. :wink:

$RemoveCollection = @(
Get-AppxProvisionedPackage -Online | 
    Where-Object {$_.displayname -in $RemoveCollection} | 
        Remove-AppxProvisionedPackage -AllUsers

Thanks Olaf !!!

Your avatar is amazing !!!

Finally, I see the error:

Get-AppxPackage : Access is denied

Do you have any idea why run that PS1 over a normal user whit admin rights ???

Thanks so much !!!

I’d recommend to run such a script as part of the provisioning process. From second time it runs as startup script it’s wasting time and energy. :wink:

Sorry for the question, can you give me more details about your suggestion ???

I actually do not know what exactly you mean.

In most enterprises computers will be provisioned by the IT departement. And they usually have a process for installing the OS and all needed software and so on. And in this process the apps should be removed.

Dear Olaf !!!

I use your script and works fine !!! Thanks so much for that !!!

Just a question, is possible to do something if the scrip sends an error to continue with the next step.

I check and send me this error:

+         Remove-AppxProvisionedPackage -AllUsers
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Remove-AppxProvisionedPackage], COMException
    + FullyQualifiedErrorId : Microsoft.Dism.Commands.RemoveAppxProvisionedPackageCommand
Remove-AppxProvisionedPackage : The system cannot find the path specified.

And block to the next step.

Do you have any suggestions ???

Kind regards.

Of course it is. Either you ignore the error or you handle it:

You should always read the help about the cmdlets you’re about to use completely including the examples to learn how to use them.