Problems with gpo & ps1 ...

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

Get-AppxPackage -AllUsers | where-object {$_.name –notlike “*camera*”} | where-object {$_.name –notlike “*calc*”} | where-object {$_.name –notlike “*photos*”} | Remove-AppxPackage
Get-appxprovisionedpackage –online | where-object {$_.name –notlike “*camera*”} | where-object {$_.name –notlike “*calc*”} | where-object {$_.name –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 ???

Carlos,
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 = @(
    'Microsoft.MicrosoftStickyNotes'
    'Microsoft.MicrosoftSolitaireCollection'
    'Microsoft.MicrosoftOfficeHub'
    'Microsoft.Office.OneNote'
    'Microsoft.MixedReality.Portal'
    'Microsoft.Office.OneNote'
    'Microsoft.Windows.Photos'
    'Microsoft.SkypeApp'
    'Microsoft.StorePurchaseApp'
    'microsoft.windowscommunicationsapps'
    'Microsoft.WindowsFeedbackHub'
    'Microsoft.WindowsStore'
    'Microsoft.Xbox.TCUI'
    'Microsoft.XboxApp'
    'Microsoft.XboxGameOverlay'
    'Microsoft.XboxGamingOverlay'
    'Microsoft.XboxIdentityProvider'
    'Microsoft.XboxSpeechToTextOverlay'
    'Microsoft.YourPhone'
    'Microsoft.ZuneMusic'
    'Microsoft.ZuneVideo'
    'Microsoft.People'
    )
        
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.