Skip to content
This repository has been archived by the owner on May 15, 2018. It is now read-only.

Issues using ScheduledTask #7

Open
kevinsea opened this issue May 31, 2015 · 1 comment
Open

Issues using ScheduledTask #7

kevinsea opened this issue May 31, 2015 · 1 comment

Comments

@kevinsea
Copy link

I'm trying to use DSC to create scheduled tasks. I run the code below and it appears successful and there are no issues in the event log, but a task is not created.

Configuration Misc
{
    param([PSCredential] $creds)

    Import-DscResource -ModuleName  StackExchangeResources

    Node localhost
    {

        ScheduledTask Test_Task
        {
            Ensure = "Present"
            Name = "Proto2"
            FilePath = "D:\DSCTest\myapp.exe"  
            At = "11:00"
            Credential = $creds
            Daily = $true
            #sint32 Hours; sint32 Minutes; boolean Once; int32 DaysInterval; string DaysOfWeek[]; boolean Weekly;   
        }

    }
}

cls


$myCreds = New-Object System.Management.Automation.PSCredential("NT AUTHORITY\NETWORK SERVICE") 

#I've also tried supply my admin creds $myCreds = Get-Credential

Misc($myCreds)  -OutputPath "C:\Admin\TestingStuff\PS\DSC1\Misc"

Start-DscConfiguration -Path "C:\Admin\TestingStuff\PS\DSC1\Misc" -Wait -Verbose -Force -Debug 

Results:
VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = SendConfigurationApply,'className' = MSFT_DSCLocalConfigurationManager,'namespaceName' =
root/Microsoft/Windows/DesiredStateConfiguration'.
VERBOSE: An LCM method call arrived from computer USB-TGKCTEST with user sid S-1-5-21-2950772361-2964733660-914393307-1001.
VERBOSE: [USB-TGKCTEST]: LCM: [ Start Set ]
VERBOSE: [USB-TGKCTEST]: LCM: [ Start Resource ] [[ScheduledTask]Test_Task::[Misc]System.Management.Automation.PSCredential::[Misc]System.Management.Automation.PSCredential]
VERBOSE: [USB-TGKCTEST]: LCM: [ Start Test ] [[ScheduledTask]Test_Task::[Misc]System.Management.Automation.PSCredential::[Misc]System.Management.Automation.PSCredential]
VERBOSE: [USB-TGKCTEST]: [[ScheduledTask]Test_Task::[Misc]System.Management.Automation.PSCredential::[Misc]System.Management.Automation.PSCredential]
Unable to find matching job.
VERBOSE: [USB-TGKCTEST]: LCM: [ End Test ] [[ScheduledTask]Test_Task::[Misc]System.Management.Automation.PSCredential::[Misc]System.Management.Automation.PSCredential]
in 0.5160 seconds.
VERBOSE: [USB-TGKCTEST]: LCM: [ Start Set ] [[ScheduledTask]Test_Task::[Misc]System.Management.Automation.PSCredential::[Misc]System.Management.Automation.PSCredential]
VERBOSE: [USB-TGKCTEST]: LCM: [ End Set ] [[ScheduledTask]Test_Task::[Misc]System.Management.Automation.PSCredential::[Misc]System.Management.Automation.PSCredential]
in 0.9530 seconds.
VERBOSE: [USB-TGKCTEST]: LCM: [ End Resource ] [[ScheduledTask]Test_Task::[Misc]System.Management.Automation.PSCredential::[Misc]System.Management.Automation.PSCredential]
VERBOSE: [USB-TGKCTEST]: LCM: [ End Set ] in 1.8358 seconds.
VERBOSE: Operation 'Invoke CimMethod' complete.
VERBOSE: Time taken for configuration job to complete is 2.025 seconds

@tuespetre
Copy link

It's because this resource is using 'scheduled jobs' rather than 'scheduled tasks', so it only accepts PowerShell files. I just found this out as well...

I think the -ErrorAction SilentlyContinue needs to be removed from this:

https://github.com/PowerShellOrg/StackExchangeResources/blob/master/DSCResources/StackExchange_ScheduledTask/StackExchange_ScheduledTask.psm1#L226

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants