Solved

PowerScript script isn't executing when lauched by task scheduler

Posted on 2014-01-23
7
422 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
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Find out how to use Active Directory data for email signature management in Microsoft Exchange and Office 365.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this Micro Tutorial viewers will learn how to use Windows Server Backup to create full image of their system. Tutorial shows how to install Windows Server Backup Feature on Windows 2012R2 and how to configure scheduled Bare Metal Recovery backup.…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

910 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

17 Experts available now in Live!

Get 1:1 Help Now