Solved

PowerScript script isn't executing when lauched by task scheduler

Posted on 2014-01-23
7
427 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

The following article is comprised of the pearls we have garnered deploying virtualization solutions since Virtual Server 2005 and subsequent 2008 RTM+ Hyper-V in standalone and clustered environments.
Microsoft Office 365 is a subscriptions based service which includes services like Exchange Online and Skype for business Online. These services integrate with Microsoft's online version of Active Directory called Azure Active Directory.
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

630 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