Solved

PowerScript script isn't executing when lauched by task scheduler

Posted on 2014-01-23
7
421 Views
Last Modified: 2014-01-23
I have this ps1 file that sends an email to all users in AD warning them that their password will expire. I have scheduled it to run every morning at 3:00am. if I run it in the script in the powershell ISE (i.e. right click on the ps1 file and select edit. Then run it in the PS editor it works fine. But not on it's own. Obviously it needs administrator perms or something

I've seen a lot of posts on the web but since I'm a little slow on the uptake can anyone boil it down for me without a lot of explanation. please.

thanks!!
0
Comment
Question by:ronfast
7 Comments
 
LVL 39

Expert Comment

by:footech
Comment Utility
Look at the history for the task.  Is it being run?
How is your scheduled task configured?

You need to determine whether it's a problem with the script or how it's being called.  Add in some simple logging to the script so that you can see whether it's even working (something like "task is started" | out-file "c:\temp\log.txt" ).Can you provide the script?  Perhaps just a portion of it is erroring out that needs to be handled differently when run as a scheduled task.
0
 
LVL 10

Expert Comment

by:ienaxxx
Comment Utility
It is probably ecause of the standard execution policy of the powershell scripts.

running
Set-ExecutionPolicy RemoteSigned

Open in new window

once from an elevated powershell will probably do the trick.

reference: http://technet.microsoft.com/en-us/library/ee176961.aspx
0
 

Author Comment

by:ronfast
Comment Utility
Script File is attached. I changed the extension though so it would upload.
As far as the task scheduler

General Tab: I've selected the following
Run whether the user is logged on or not
Run with highest privileges
Configure for Windows Server 2012

Conditions Tab: I unchecked the following (I had seen a reference to this on the web)
Start the task only if the computer is on AC power

The rest of the settings are default
PWDScript
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 53

Assisted Solution

by:Will Szymkowski
Will Szymkowski earned 250 total points
Comment Utility
If this is due to the account permissions to run this Powershell script you will need to modify the "Change User or Group" with an account that has rights to run it (i would recommend a service account). This other thing you are going to need to make sure that you have enabled is "run weather user is logged on or not".

If either of those are not configured properly this could be where the issue is.

Will.
0
 

Author Comment

by:ronfast
Comment Utility
Sorry for a dumb question but what is a service account?
0
 
LVL 9

Accepted Solution

by:
David Carr earned 250 total points
Comment Utility
A service account is an Active Directory account not linked to a person but created specifically to run a service. It usually has a strong password that does not expire. Depending on how your Active Directory is set up, you may need one in multiple domains or you many have one that works across all domains. Service account passwords should be changed regularly and the accounts should be monitored for abuse to make sure they are being used only for service requested.
0
 

Author Closing Comment

by:ronfast
Comment Utility
thanks!!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
In this Micro Tutorial viewers will learn how to use Boot Corrector from Paragon Rescue Kit Free to identify and fix the boot problems of Windows 7/8/2012R2 etc. As an example is used Windows 2012R2 which lost its active partition flag (often happen…
In this Micro Tutorial viewers will learn how to restore their server from Bare Metal Backup image created with Windows Server Backup feature. As an example Windows 2012R2 is used.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now