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? :)
Powershell

Avatar of undefined
Last Comment
David Johnson, CD
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
ivan rosa
Flag of United States of America image

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

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
the user needs to be logged in so change it from logged in or not 
Powershell
Powershell

Windows PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language built on the .NET Framework. PowerShell provides full access to the Component Object Model (COM) and Windows Management Instrumentation (WMI), enabling administrators to perform administrative tasks on both local and remote Windows systems as well as WS-Management and Common Information Model (CIM) enabling management of remote Linux systems and network devices.

27K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo