guitarrapc / GraniResource

PowerShell Desired State Configuration Resources for real production workload.
https://www.powershellgallery.com/packages/GraniResource
MIT License
43 stars 8 forks source link

[Enhancement]cScheduledTask TaskPath Property requires \ at first char for Get/Test. #52

Closed guitarrapc closed 8 years ago

guitarrapc commented 8 years ago

Reference

ref : https://github.com/guitarrapc/DSCResources/issues/49#issuecomment-178571072

Description

If you set cScheduledTask as below it works fine.

configuration present
{
    Import-DscResource -Modulename GraniResource
    Node $AllNodes.Where{$_.Role -eq "localhost"}.NodeName
    {
        cScheduleTask hoge
        {
            Ensure = "Present"
            Execute = "C:\Temp\test.bat"
            TaskName = "TestRenaud2123"
            TaskPath = "\rimes"
            ScheduledAt = [datetime]"00:00:00", [datetime]"01:00:00"
            RepetitionIntervalTimeSpanString = @(([TimeSpan]"00:05:00").ToString())
            RepetitionDurationTimeSpanString = @(([TimeSpan]::MaxValue).ToString())
            Disable = $false
        }
    }
}

But if you set TaskPath without \ on first char, Test always fail and start Set.

configuration present
{
    Import-DscResource -Modulename GraniResource
    Node $AllNodes.Where{$_.Role -eq "localhost"}.NodeName
    {
        cScheduleTask hoge
        {
            Ensure = "Present"
            Execute = "C:\Temp\test.bat"
            TaskName = "TestRenaud2123"
            TaskPath = "rimes"
            ScheduledAt = [datetime]"00:00:00", [datetime]"01:00:00"
            RepetitionIntervalTimeSpanString = @(([TimeSpan]"00:05:00").ToString())
            RepetitionDurationTimeSpanString = @(([TimeSpan]::MaxValue).ToString())
            Disable = $false
        }
    }
}

Todo

guitarrapc commented 8 years ago

Hi @renaudl,

I have released new version 3.7.6. You can find it at PowerShell Gallery. Appreciate for your feed back.

Cheers,