Problems with gpo & ps1 ...

Carlos Arizmendi 41 Reputation points
2022-05-17T23:56:47.493+00:00

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

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

Windows
Windows
A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.
4,720 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,352 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Carlos Solís Salazar 16,351 Reputation points
    2022-05-18T00:56:20.007+00:00

    Hi @Carlos Arizmendi a

    Thank you for asking this question on the **Microsoft Q&A Platform. **

    Try the recommendations of this post

    Sometimes you would need to automate an uninstall of an application through Group Policies (GPO). This can be done by running a PowerShell script. Firstly create a PowerShell script as below:

    $appplication = Get-WmiObject -Class Win32_Product | Where-Object  
    {$_.Name -match "My Application Name"}  
    $application.Uninstall()  
    

    Save the file and create a new GPO and set the script to load by setting up the Computer Configuration/ Policies/ Windows Settings/ Scripts/ Startup.

    Hope this helps,
    Carlos Solís Salazar

    ----------

    Accept Answer and Upvote, if any of the above helped, this thread can help others in the community looking for remediation for similar issues.
    NOTE: To answer you as quickly as possible, please mention me in your reply.



  2. MotoX80 31,556 Reputation points
    2022-05-18T02:15:10.467+00:00

    Add a Start-Transcript command to your .ps1. It will create a log of everything the script does.

    https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.host/start-transcript?view=powershell-5.1

    If the commands don't generate any output at all, you may need to add -verbose to the commands to get additional info.

    0 comments No comments

  3. Carlos Arizmendi 41 Reputation points
    2022-05-20T15:00:22.663+00:00

    Hi !!!

    I put it Start-Transcript when I run manually to create the log file, but when I run by the policy do anything !!!

    I'm really frustrating the PS1 doesn't run !!!

    Thanks so much ...


  4. Limitless Technology 39,336 Reputation points
    2022-05-23T09:37:14.26+00:00

    Hello

    Thank you for your question and reaching out. I can understand you are having issues related to related start-up script to remove app.

    Please try to put pause or Sleep before starting the script as running PowerShell script can be slow compared to .bat script and it requires to be in User-context mode after user profile is loaded.

    Please also put logging of errors to review any potential syntax or other errors


    --If the reply is helpful, please Upvote and Accept as answer--

    0 comments No comments