A script to run powershell to remove windows mail program

Brad Davis 1 Reputation point
2022-03-02T16:31:20.503+00:00

Excuse my ignorance here but I am looking to write a script to remove windows mail from pcs that I build for all users. I know the command in powershell but have to run it as administrator. Trying to see if I can make a batch file or something similar.

This is what I have currently, obviously run powershell as administrator:
Get-AppxPackage Microsoft.windowscommunicationsapps | Remove-AppxPackage

Thanks in advance, and yes, I am slightly higher than a novice but not much. We all learn somewhere right?

Windows for business Windows Server User experience PowerShell
{count} votes

3 answers

Sort by: Most helpful
  1. Carlos Solís Salazar 18,191 Reputation points MVP Volunteer Moderator
    2022-03-02T21:50:28.443+00:00

    Hi @Brad Davis

    What is the intention of the Batch file??

    You can create a script for PowerShell "script.ps1"

    If you what run the command remotely you can use Invoke-Command (https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/invoke-command?view=powershell-7.2)

    Hope this helps,
    Carlos Solís Salazar

    ----------

    Please "Accept as Answer" and Upvote if any of the above helped so that, it can help others in the community looking for remediation for similar issues.

    0 comments No comments

  2. Brad Davis 1 Reputation point
    2022-03-03T22:42:57.363+00:00

    Thank you for the response, Carlos!

    Again, I am basically a novice. I am wanting a script that I put on a flash drive with all the software I am installing so I can simplify removing default windows mailer from all machines as I am building them.

    Any assistance would be greatly helpful.
    Thanks!

    Brad

    0 comments No comments

  3. Carlos Solís Salazar 18,191 Reputation points MVP Volunteer Moderator
    2022-03-04T12:47:30.52+00:00

    Hi @Brad Davis

    Save the following line in a file with the name of your preference, the only requirement is that the extension must be .ps1

    Get-AppxPackage Microsoft.windowscommunicationsapps | Remove-AppxPackage  
    

    Later from the host you can execute this command from powershell

    powershell -ep Bypass D:\MyScript.ps1  
    

    Hope this helps,
    Carlos Solís Salazar

    ----------

    Please "Accept as Answer" and Upvote if any of the above helped so that, it can help others in the community looking for remediation for similar issues.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.