How do I run a powershell script as a task in task scheduler?

I have a password reset script (passwordexpire.ps1) that works perfectly whenever I r-click and 'run using powershell'.
However, I wish to automate this daily task and my attempts to set it up in task Scheduler on the DC fails to run. I see the task steps are created and given process IDs in the 'history' tab, all as completed, but nothing results from it running.

Does anyone have some steps I can follow to make this work? I've read that configuring the location of where it starts is something to be modified when using .ps1 files but have not found anything else.

Server 2008 R2 standard.
The script is a simple notepad file renamed as .ps1
LVL 14
Michael MachieIT SupervisorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hello ThereSystem AdministratorCommented:
It's easy.

Just create a new task that will run Powershell under admin account and then in Arguments field write the path to your .ps1 script.

More here.
0
KimputerCommented:
executable: powershell
arguments:  -ExecutionPolicy RemoteSigned -File C:\scripts\script.ps1
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Hello ThereSystem AdministratorCommented:
Yes, you have to specify full argument.
0
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Michael MachieIT SupervisorAuthor Commented:
Thanks to both. Points awarded based on the below explanation..

Kimputer provided the exact arguments needed, which worked, without going to an external site so gets the Accept.

B A's link in the post provided a step-by-step instruction list, but from an external source, and since that is against E-E TOS I cannot grant points because when the link goes dead (and they usually do, hence the E-E TOS statement about external sites) I cannot Accept and lead future people to a dead link.
0
Hello ThereSystem AdministratorCommented:
Well, I take that. Just realize that I put some effort to answer you and as far as my answer is correct too, you should let others know...
0
Michael MachieIT SupervisorAuthor Commented:
Hi, i didnt ever see the name Hello There next to any comments. I only saw B A and Kimputer. Looking nkw i do mot see a B A and  now see a Hello There.

Not sure if that is the reason why i didnt mention your name but it may be.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.