Solved

PowerScript script isn't executing when lauched by task scheduler

Posted on 2014-01-23
7
425 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Background Information Recently I have fixed file server permission issues for one of my client. The client has 1800 users and one Windows Server 2008 R2 domain joined file server with 12 TB of data, 250+ shared folders and the folder structure i…
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

738 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