Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9253959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:20:52+00:00 2026-06-18T11:20:52+00:00

I am trying to schedule another powershell script using schtasks.exe using following command: $Command

  • 0

I am trying to schedule another powershell script using schtasks.exe using following command:

$Command = cmd /c "$Env:WinDir/system32/schtasks.exe /create /s $ComputerName  /tn $TaskName /tr $TaskRun /sc $Schedule /d $Days /st $StartTime /RU system"

Invoke-Expression $Command

It schedules the task on remote servers but throws an error:

“The term ‘SUCCESS:’ is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the
name, or if a path was included, verify that the path is correct and try again.

It does successfully schedule the job at correct times but throws this error.
Does anyone know how to resolve this error?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T11:20:54+00:00Added an answer on June 18, 2026 at 11:20 am

    The error is displayed because when you create your $command variable, your setting it’s value to the RESULT of the expression, which is SUCCESS. The command is done running before your execute Invoke-Expression. Because of that, Invoke-Expression is actually running the result (SUCCESS) as it’s scriptblock, and you get an error. Proof:

    PS > $command = whoami
    
    PS > $command
    computer\user
    
    PS > $command = 'whoami'
    
    PS > $command
    whoami
    

    You can either just call the command directly as you do when you create your $command variable, or you can save the expression(cmd /c ...) as a string and then invoke it. Ex:

    $Command = 'cmd /c "$Env:WinDir/system32/schtasks.exe /create /s $ComputerName  /tn $TaskName /tr $TaskRun /sc $Schedule /d $Days /st $StartTime /RU system"'
    
    Invoke-Expression $Command
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to schedule the tasks from my application using schtasks instead of
I am trying to schedule my R script using cron, but it is not
I'm trying to create a work schedule creator with multiple stores and each store
I am trying to schedule a reboot programmablly on winxp by using c# currently,
I'm trying to create an dynamic AJAX function using PHP and MySQL but have
I'm trying to schedule a repeating event to run every minute in Python 3.
I am trying to schedule wall posts to be added to the Facebook business
I am trying to make a schedule table that would delete certain rows according
I'm trying to use a timer to schedule a recurring event in an application.
I'm trying to develop a simple php based schedule ... This is my database

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.