couple of powershell scripts

Discussion in 'Windows 10' started by driz, Jul 20, 2015.

  1. driz

    driz MDL Novice

    Sep 9, 2013
    11
    5
    0
    #1 driz, Jul 20, 2015
    Last edited by a moderator: Apr 20, 2017
    this is probably scrub s**t for some of you guys, but these are a couple scripts i run on my boxes following Windows 10 install. Make sure you set-executionpolicy remotesigned if you try these as scripts. I cant post a link, so make sure you modify the $source below, should be fairly obvious what it should be set to.

    Code:
    If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
    
    {   
    $arguments = "& '" + $myinvocation.mycommand.definition + "'"
    Start-Process powershell -Verb runAs -ArgumentList $arguments
    Break
    }
     
    # Run your code that needs to be elevated here
    $source = "h++p://winhelp2002 mvps org/hosts.txt"
    $destination = "c:\windows\system32\drivers\etc\hosts"
    
    
    Invoke-WebRequest $source -OutFile $destination
    Code:
    If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
    
    {   
    $arguments = "& '" + $myinvocation.mycommand.definition + "'"
    Start-Process powershell -Verb runAs -ArgumentList $arguments
    Break
    }
     
     
    get-appxpackage -AllUsers -Name Microsoft.3DBuilder                     | remove-appxpackage
    get-appxpackage -AllUsers -Name Microsoft.Getstarted                    | remove-appxpackage
    get-appxpackage -AllUsers -Name Microsoft.MicrosoftOfficeHub            | remove-appxpackage
    get-appxpackage -AllUsers -Name Microsoft.MicrosoftSolitaireCollection  | remove-appxpackage
    get-appxpackage -AllUsers -Name Microsoft.SkypeApp                      | remove-appxpackage
    get-appxpackage -AllUsers -Name Microsoft.WindowsMaps                   | remove-appxpackage
    get-appxpackage -AllUsers -Name Microsoft.BingWeather                   | remove-appxpackage
    get-appxpackage -AllUsers -Name Microsoft.Office.OneNote                | remove-appxpackage
    get-appxpackage -AllUsers -Name Microsoft.XboxApp                       | remove-appxpackage
    get-appxpackage -AllUsers -Name Microsoft.ZuneMusic                     | remove-appxpackage
    get-appxpackage -AllUsers -Name Microsoft.ZuneVideo                     | remove-appxpackage
    get-appxpackage -AllUsers -Name Microsoft.BingSports                    | remove-appxpackage
    get-appxpackage -AllUsers -Name Microsoft.BingNews                      | remove-appxpackage
    get-appxpackage -AllUsers -Name Microsoft.WindowsPhone                  | remove-appxpackage
    get-appxpackage -AllUsers -Name Microsoft.BingFinance | remove-appxpackage
    write-host "completed"
     
  2. crossup

    crossup MDL Junior Member

    Jun 20, 2015
    70
    17
    0
    Is it possible to add them back, once they are removed?
     
  3. driz

    driz MDL Novice

    Sep 9, 2013
    11
    5
    0
    Honestly, I'm not sure. I had a similar script for windows 8.1 but i've never wanted to add anything back before. There is an Add-AppXPackage cmdlet but you have to specify a path.
     
  4. Espionage724

    Espionage724 MDL Addicted

    Nov 7, 2009
    901
    256
    30
  5. Hadron-Curious

    Hadron-Curious MDL Guru

    Jul 4, 2014
    3,377
    459
    120
    One has to be wary of the consequences. It might be consuming much of your memory with time. It is not always advisable.
     
  6. timster

    timster MDL Senior Member

    Aug 23, 2009
    465
    344
    10
    you can reinstall all the apps from the Store