-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
xScheduledTask can't disable default ScheduledDefrag task #137
Comments
I initially tried using a minimal configuration, which also failed
|
I'm pretty sure it's because the task has no triggers. |
For anyone else needing to do this, the workaround is a Script Resource, which actually took me less time to write then the definition for xScheduledTask, lol
|
Hi @RobBiddle - thanks for submitting this. I could be wrong, but I think this is a duplicate of #74. I just finished the fix for this a couple of weeks ago and it should go out to the resource kit in the next release. Here is the PR that contained the fix: #132 I'll leave this open for a little bit, but if the new release does fix the issue then we should be able to close it. |
Hi @RobBiddle - the new release of xComputerManagement went out today with the fix you need (hopefully). Could you give this a try and see if it solves the issue for you? Thanks! |
I've installed https://www.powershellgallery.com/packages/xComputerManagement/4.0.0.0 and still can not disable the built-in scheduled task "XblGameSaveTask". |
@PlagueHO : Hi Daniel, I installed 4.0.0.0 version to test the deletion of built-in scheduled tasks : it works well for tasks with known Trigger types and helps a lot for my Citrix VDA optimization (https://github.com/virtualdesktopdevops/xd7vda) However, it fails with the following error if the Trigger type is unknown : It think that the correct behavior would be to delete the scheduled task, even if the Trigger type is unknown. Do you agree with this ? |
Hi @matt6697 - sorry about the delay in getting to look at this! But I'm on it now. We don't actually have test coverage hitting this line, but it would be good to get a test for it so we don't regress at any point. You probably just need a test like this: Context 'When a built-in scheduled task exists and is enabled, but it should be disabled and the trigger type is not recognized' {
$testParameters = @{
TaskName = 'Test task'
TaskPath = '\Test\'
Enable = $false
Verbose = $True
}
Mock -CommandName Get-ScheduledTask -MockWith {
@{
TaskName = $testParameters.TaskName
TaskPath = $testParameters.TaskPath
Actions = [pscustomobject] @{
Execute = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe'
}
Triggers = [pscustomobject] @{
Repetition = @{
Duration = "PT15M"
Interval = "PT15M"
}
CimClass = @{
CimClassName = 'MSFT_TaskEventTrigger'
}
}
Settings = [pscustomobject] @{
Enabled = $true
}
} }
It 'Should return the correct values from Get-TargetResource' {
$result = Get-TargetResource @testParameters
$result.Enable | Should -Be $true
$result.Ensure | Should -Be 'Present'
$result.ScheduleType | Should -BeNullOrEmpty
}
It 'Should return false from the test method' {
Test-TargetResource @testParameters | Should -Be $false
}
It 'Should disable the scheduled task in the set method' {
Set-TargetResource @testParameters
Assert-MockCalled Register-ScheduledTask -Exactly -Times 1
}
} |
I've had a very similar issue. Created a PR that has fixed it for me - #228 |
I'm using xComputerManagement 3.2.0.0, attempting to disable the default task ScheduledDefrag
I've tried populating all of the current values for the task, only changing Enable to $false and ScheduleType to 'Once'.
Here is the configuration and error thrown:
The text was updated successfully, but these errors were encountered: