Link to home
Create AccountLog in
Avatar of ivan rosa
ivan rosaFlag for United States of America

asked on

Not Launching Chrome from a Powershell within a Task Scheduler

Hello Guys,
 I have in various PS scripts within the Task Scheduler and they all work fine except for this one that launches a chrome website.

for the sake of the purpose the below would fit my question
$googlePath = "C:\Program Files\Google\Chrome\Application\chrome.exe"
$Google     = "https://www.google.com"
$msn        = "https://www.msn.com"
$getMDate   = (Get-Date).Month


if ($getMDate -eq "5") {
    Start-Process -FilePath $googlePath -ArgumentList $($Google) -Verb RunAs -PassThru
}else{
    Start-Process -FilePath $googlePath -ArgumentList $($msn) -Verb RunAs -PassThru
}

Open in new window


here's a view from the Task Sequence:
User generated image
Use in Program/script field
%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe

Open in new window

and add argument
-NoProfile -NoLogo -NonInteractive -ExecutionPolicy Bypass -File “C:\Temp\kicks.ps1”

Open in new window

any thoughts? :)
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

if chrome is your default browser
$Google     = "https://www.google.com"
$msn        = "https://www.msn.com"
$getMDate   = (Get-Date).Month


if ($getMDate -eq "6") {
    Start-Process  $($Google) 
}else{
    Start-Process  $($msn)
}

Open in new window

Avatar of ivan rosa

ASKER

Yes, chrome is default browser
by the way thanks for the comment, however I run into the same issue. It runs perfect in the console, but if you run it from the "Task Scheduler" then it fails.

furthermore I even added in the "Environment Variable" list
ASKER CERTIFIED SOLUTION
Avatar of footech
footech
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
the user needs to be logged in so change it from logged in or not