Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Clarification of scheduled task creation with PowerShell 4.0...

$
0
0

Hi all,

I'm new to scripting so please forgive any poor terminology, etc...

I've written two scripts which work perfectly when run manually.  The first creates a backup, the second deletes the same backup.

At the end of the first script I want to add the creation of a task which will trigger the second script to run ten days later.

<# Scheduled Task Creation #>
$A = New-ScheduledTaskAction -Execute C:\Users\myUser\Desktop\PowerShell\snapshotDestroyer.ps1 -Argument $snapName $listFilePath
$T = New-ScheduledTaskTrigger -At <# 10 days later? #> -Once
$P = New-ScheduledTaskPrincipal -UserId "myDomain\myUser"
$D = New-ScheduledTask -Action $A -Principal $P -Trigger $T
Register-ScheduledTask destroyTask -InputObject $D

The task appears to get created & start running, but it doesn't do anything...

So my questions are:

What is the correct syntax for the arguments of New-ScheduledTaskAction

AND

How can I trigger after 10 days? I see a weekly & monthly option, but nothing in between.

Thanks in advance.



Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>