0

I have to start a .ps1 when a specific ID come. So I used the Task Scheduler and my script starts correctly!

I'm starting powershell.exe with the arguments -File C:\Users\ostefanini\Documents\powersh\backup_started.ps1 -WindowStyle Maximized.

But… the PowerShell window does not appear. I tried to reveal it with "YAPM" (and old task manager on windows, with the ability of reveal window's task) but the program cannot perform this operation.

So, how to see my PowerShell window? (I finished my script with cmdlet pause).

And the second question, in direct relation with the first one, because my script finish by a "pause" it's never ended. If my task starts again, my script didn't run because of double instance.

6
  • Why are you pausing the script and waiting for user intervention? I'm guessing so you can see the script output to check something happened or didn't? If so, it's better practice to log the output to a file then you can let the script run and just check the file if you need to. Removing the pause and using logging would answer both of your questions. Here's a good answer with a logging function: stackoverflow.com/questions/7834656/… Commented Nov 17, 2016 at 9:37
  • Thanks, Of course it's not a great idea, but I would like to see my powershell window... Commented Nov 17, 2016 at 9:38
  • Fair enough, can you share the command you're using in Task Scheduler to start the script? Commented Nov 17, 2016 at 9:39
  • Okay, I see the option -WindowStyle from here: msdn.microsoft.com/fr-fr/powershell/scripting/core-powershell/… I tried the argument "Normal" but nothing appear. here is my line: powershell.exe and arguments: -file C:\Users\ostefanini\Documents\powersh\backup_started.ps1 -WindowStyle Maximized. But I noticed that my explorer.exe restart two or three times Commented Nov 17, 2016 at 10:33
  • How is your scheduled task configured exactly? Commented Nov 17, 2016 at 11:26

1 Answer 1

1

Okay, I found all solutions. First, to make a schedule task visible, select your schedule task, then right-click and choose "properties". In the tab "general", section "security options" choose "Execute only if the user is connected" and don't choose "Execute also if the user was not connected". It's because the task scheduler will not appear window... if no one will see it ^^

and second, for the problem of double instance, it's the default configuration of the process of creation task scheduler. To change it, go (on the same properties window) to the tab "Parameters" and choose in the last dropdown list "Execute a new instance in parallel" Sorry it's in french (sorry it's in french)

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.