Posts Tagged PowerShell

PowerShell: Remove Google Chrome (any version)

The following PowerShell script will allow you to remove any installed version of Google Chrome.

Function UninstallChrome() {
    $app = get-wmiobject Win32_Product | Where-Object {$_.Name -eq "Google Chrome"}
    $removeChrome = $app.IdentifyingNumber msiexec /x
    $removeChrome /q
 }
 
# If chrome is running then close the process and uninstall it
 If (Get-Process chrome -ErrorAction SilentlyContinue) {
    # Chrome is running
    # Stop chrome process
    Stop-Process -Name chrome -Force

    # Now uninstall chrome
    UninstallChrome
 } Else {
     # Chrome is not running…
     # Uninstall chrome
     UninstallChrome
 } 

, , , , ,

Leave a comment

Run PowerShell Script in Schedule Tasks

The following will allow you to run a Powershell script as a scheduled task. These instructions have been tested on a Windows 7 64bit computer.

Before proceeding, make sure your Powershell script runs without any errors. The best way to make sure your script is running fine is by calling it from a command prompt.

Note: Make sure you run Set-ExecutionPolicy from an elevated Powershell window to make sure your system (Windows 7) is allowed to run Powershell scripts.

  1. Open a Command Prompt window
  2. Run: powershell -file <your ps script file>
  3. Make sure it executes properly

 

Now, open Windows 7 Task Scheduler:

  1. In the Actions tab
  2. Power shell is found at: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
    1. You can also just use powershell.exe
  3. In Add arguments (optional) field, add the following: -File “C:\Path-to-your-script\Your-ps-script.ps1”
    1. Sample: -File “C:\Program Files (x86)\Info Folder\Get-Speed.ps1”
  4. In Start in (optional) field, add the following: C:\Program Files (x86)\Info Folder
    1. Sample: C:\Program Files (x86)\Info Folder

2016-09-19_1151

I’m not going to go over the other sections as this is the main section to be able to execute Powershell scripts from Schedule Tasks.

, , ,

Leave a comment