Solved

PowerScript script isn't executing when lauched by task scheduler

Posted on 2014-01-23
7
424 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 40

Expert Comment

by:footech
ID: 39804263
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
ID: 39804348
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
ID: 39804382
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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
LVL 53

Assisted Solution

by:Will Szymkowski
Will Szymkowski earned 250 total points
ID: 39804386
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
ID: 39804406
Sorry for a dumb question but what is a service account?
0
 
LVL 9

Accepted Solution

by:
David Carr earned 250 total points
ID: 39804577
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
ID: 39804609
thanks!!
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
Last week, our Skyport webinar on “How to secure your Active Directory” (https://www.experts-exchange.com/videos/5810/Webinar-Is-Your-Active-Directory-as-Secure-as-You-Think.html?cid=Gene_Skyport) provided 218 attendees with a step-by-step guide for…
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.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…

828 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