<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: chustedde</title>
    <description>The latest articles on DEV Community by chustedde (@chustedde).</description>
    <link>https://dev.to/chustedde</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F144885%2F68864488-d8a3-4fdc-adb4-64642824002c.png</url>
      <title>DEV Community: chustedde</title>
      <link>https://dev.to/chustedde</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/chustedde"/>
    <language>en</language>
    <item>
      <title>Why is your PowerShell Scheduled Task not running?</title>
      <dc:creator>chustedde</dc:creator>
      <pubDate>Thu, 14 Mar 2019 21:58:00 +0000</pubDate>
      <link>https://dev.to/chustedde/why-is-my-powershell-scheduled-task-not-running-16ik</link>
      <guid>https://dev.to/chustedde/why-is-my-powershell-scheduled-task-not-running-16ik</guid>
      <description>&lt;p&gt;This is one of the most-referenced entries I've made in my department's shared notes, so it seemed like a good choice for my first post to a wider audience!&lt;/p&gt;

&lt;h2&gt;
  
  
  Signature required
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Does your task server require scripts to be signed?

&lt;ul&gt;
&lt;li&gt;If so, &lt;a href="https://devblogs.microsoft.com/scripting/hey-scripting-guy-how-can-i-sign-windows-powershell-scripts-with-an-enterprise-windows-pki-part-1-of-2/"&gt;do you have a valid code signing certificate&lt;/a&gt; and &lt;a href="https://devblogs.microsoft.com/scripting/hey-scripting-guy-how-can-i-sign-windows-powershell-scripts-with-an-enterprise-windows-pki-part-2-of-2/"&gt;is your script signed&lt;/a&gt;?&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;If your script is signed, is the signature still valid? Here's how to check: &lt;code&gt;Get-AuthenticodeSignature -FilePath your-script.ps1&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;If it's not valid, sign it again (I have a shortcut to do this in &lt;a href="https://gist.github.com/chustedde/95e619c86a804258bd536bc5dd080cbb#file-microsoft-powershell_profile-ps1-L31"&gt;my PowerShell profile&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Who's running things?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Is the task set to run whether or not the user is logged on?&lt;/li&gt;
&lt;li&gt;Do you have a specific account that runs scheduled tasks?

&lt;ul&gt;
&lt;li&gt;Did you save the correct password when setting up the task?&lt;/li&gt;
&lt;li&gt;Just try the password one more time... I won't tell anyone you tried typing it instead of copying and pasting 😅&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Does the user/script-running account have the correct permissions to do everything you need it to?

&lt;ul&gt;
&lt;li&gt;Folder permissions are a common issue&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Trust issues
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Does the account running the script trust your signature?

&lt;ul&gt;
&lt;li&gt;You may need to trust/re-trust your signature, especially if you were recently issued a new code signing cert&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;If possible, on the machine running the task, open up a command prompt (or PowerShell!) and try launching PowerShell as the user running the task: &lt;code&gt;runas /user:example.edu\taskrunner powershell.exe&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;Try running your script in the new PowerShell window that just popped up&lt;/li&gt;
&lt;li&gt;When it asks you to trust your script, you say &lt;del&gt;yes&lt;/del&gt; &lt;code&gt;[A]lways&lt;/code&gt;!&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I hope this saves at least a few people from a few moments of frustration. There are &lt;a href="https://stackoverflow.com/a/46367395/2547475"&gt;weirder issues&lt;/a&gt; out there for sure, but this checklist should help you solve the most common ones!&lt;/p&gt;

</description>
      <category>windows</category>
      <category>powershell</category>
      <category>script</category>
    </item>
  </channel>
</rss>
