<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>..::\\ www.christiano.ch //::.. &#187; Scheduled Task</title>
	<atom:link href="http://www.christiano.ch/wordpress/tag/scheduled-task/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.christiano.ch/wordpress</link>
	<description>christiano.ch blog - personal knowledge base, news, memoires et cetera</description>
	<lastBuildDate>Fri, 06 Jan 2012 15:28:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<meta xmlns="http://www.w3.org/1999/xhtml" name="robots" content="noindex,follow" />
		<item>
		<title>PowerShell: Running PowerShell Scripts as Scheduled Task</title>
		<link>http://www.christiano.ch/wordpress/2010/03/10/powershell-running-powershell-scripts-as-scheduled-task/</link>
		<comments>http://www.christiano.ch/wordpress/2010/03/10/powershell-running-powershell-scripts-as-scheduled-task/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 06:04:39 +0000</pubDate>
		<dc:creator>christian</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Scheduled Task]]></category>

		<guid isPermaLink="false">http://www.christiano.ch/wordpress/2010/03/10/powershell-running-powershell-scripts-as-scheduled-task/</guid>
		<description><![CDATA[Schtasks.exe &#8211; Enables an administrator to create, delete, query, change, run, and end scheduled tasks on a local or remote computer. Running Schtasks.exe without arguments displays the status and next run time for each registered task. If you have jobs &#8230; <a href="http://www.christiano.ch/wordpress/2010/03/10/powershell-running-powershell-scripts-as-scheduled-task/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<table border="0" cellspacing="0" cellpadding="2" width="675">
<tbody>
<tr>
<td valign="top" width="671">Schtasks.exe &#8211; Enables an administrator to create, delete, query, change, run, and end scheduled tasks on a local or remote computer. Running Schtasks.exe without arguments displays the status and next run time for each registered task.          <br /> 
<p>If you have jobs that need to execute regularly, you can manage them with a PowerShell script and make it a scheduled task:</p>
</td>
<td valign="top" width="10"><a href="http://www.christiano.ch/wordpress/wp-content/uploads/2010/03/Logo_PowerShell.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Logo_PowerShell" border="0" alt="Logo_PowerShell" src="http://www.christiano.ch/wordpress/wp-content/uploads/2010/03/Logo_PowerShell_thumb.png" width="160" height="125" /></a> </td>
</tr>
</tbody>
</table>
<p> <span id="more-888"></span>
<p>To create a scheduled task do.</p>
<p><code>schtasks /CREATE /TN CheckHealthScript /TR &quot;powershell.exe -noprofile -executionpolicy Unrestricted -file %public%\checkhealth.ps1&quot; /IT /RL HIGHEST /SC DAILY</code></p>
<p>To get a list of scheduled tasks / enumerate scheduled tasks do:</p>
<p><code>schtasks /query</code></p>
<p><strong>Links</strong></p>
<p><a title="Running PowerShell Scripts as Scheduled Task" href="http://powershell.com/cs/blogs/tips/archive/2010/03/09/running-powershell-scripts-as-scheduled-task.aspx" target="_blank">Running PowerShell Scripts as Scheduled Task</a></p>
<p><a title="About Scheduled Tasks on MSDN" href="http://msdn.microsoft.com/en-us/library/bb736357%28VS.85%29.aspx" target="_blank">About Scheduled Tasks on MSDN</a></p>
<p><a title="About Scheduled Tasks on Technet" href="http://technet.microsoft.com/en-us/library/bb490996.aspx" target="_blank">About Scheduled Tasks on Technet</a></p>
<p>&#160;</p>
<p><strong><em>Script to enumerate / list scheduled tasks on a list of servers..</em></strong></p>
<p> <code>$Version=&quot;v8.4.28 Aaron Dodd&quot;   <br />$Description=&quot;Generate CSV of scheduled tasks in the environment&quot;    </p>
<p>#------------------------------------------------------------------------------    <br /># Settings / Variables    <br />#------------------------------------------------------------------------------    <br />If (Test-Path &quot;QueryScheduledTasks.config&quot;) {    <br />$cfg=[xml](get-content &quot;QueryScheduledTasks.config&quot;)    <br />} Else {    <br />Write-Host &quot;!! ERROR !! - Config file not found&quot;    <br />Write-Host &quot;A file with the same name as this script, ending in .config, must exist in the same directory as this script.&quot;    <br />exit    <br />}    </p>
<p>$ServerList = Import-Csv $cfg.configuration.ServerList.name    <br />$FinalReport=$cfg.configuration.FinalReport.name    <br />$TempDir=$cfg.configuration.TempFolder.name    <br />$TempReport=$TempDir + &quot;\temp.csv&quot;    <br />$ErrorActionPreference=$cfg.configuration.ErrorAction.value    <br />#------------------------------------------------------------------------------    </p>
<p>#------------------------------------------------------------------------------    <br /># Process tasks    <br />#------------------------------------------------------------------------------    <br />ForEach ($Server in $ServerList) {    <br />schtasks /QUERY /S $Server.Name /FO CSV /V &gt; $TempReport    <br />$TempCsv += Import-Csv $TempReport    <br />}    <br />Remove-Item $TempReport    <br />$TempCsv | Export-Csv $FinalReport -notype    <br />#----------------------------------------------------------------</code>
<p>found here =&gt; <a title="http://blog.geekpoet.net/2008/04/powershell-script-to-report-on-all.html" href="http://blog.geekpoet.net/2008/04/powershell-script-to-report-on-all.html" target="_blank">http://blog.geekpoet.net/2008/04/powershell-script-to-report-on-all.html</a></p>
<div class="tweetthis" style="text-align:left;"><p> <a class="tt" href="http://twitter.com/intent/tweet?text=PowerShell%3A+Running+PowerShell+Scripts+as+Scheduled+Task+http%3A%2F%2Fchristiano.ch%2Fwordpress%2F%3Fp%3D888" title="Post to Twitter"><img class="nothumb" src="http://www.christiano.ch/wordpress/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/intent/tweet?text=PowerShell%3A+Running+PowerShell+Scripts+as+Scheduled+Task+http%3A%2F%2Fchristiano.ch%2Fwordpress%2F%3Fp%3D888" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.christiano.ch/wordpress/2010/03/10/powershell-running-powershell-scripts-as-scheduled-task/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

