Replies: 5 comments 10 replies
-
@dummys I'm trying to understand why you would use WMI for it? I have done something in the real past, which leverage VBSCript. When using PowerShell, I mainly use the default commands available, or get to pre-existing DSC resources. For example, the $schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Create scheduled task
type: ComputerManagementDSC/ScheduledTask
properties:
TaskName: 'Test'
TaskPath: 'Test'
ActionExecutable: 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe'
ScheduleType: 'AtStartup' If you need to require elevation check, you can always include: metadata:
Microsoft.DSC:
securityContext: elevated |
Beta Was this translation helpful? Give feedback.
-
My goal is to delete scheduled task, not to create one.
|
Beta Was this translation helpful? Give feedback.
-
the problem is that it didnt exist any resource for scheduled task I think |
Beta Was this translation helpful? Give feedback.
-
I found another weird issue: when I want to use old PSDesiredstate module for scheduled task and use one array or resources it didn't work: - name: Use Windows powershell to configure scheduled task
type: Microsoft.Windows/WindowsPowerShell
properties:
resources:
- name: DisableMarebackup
type: ComputerManagementDsc/ScheduledTask
properties:
taskName: MareBackup
taskPath: '\Microsoft\Windows\Application Experience'
enable: false
- name: DisableProxy
type: ComputerManagementDsc/ScheduledTask
properties:
taskName: Proxy
taskPath: '\Microsoft\Windows\Autochk'
enable: false When I do it like this it works: # yaml-language-server: $schema=https://aka.ms/dsc/schemas/v3/bundled/config/document.vscode.json
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: bla1
type: Microsoft.Windows/WindowsPowerShell
properties:
resources:
- name: DisableMarebackup
type: ComputerManagementDsc/ScheduledTask
properties:
taskName: MareBackup
taskPath: '\Microsoft\Windows\Application Experience'
enable: false
- name: bla2
type: Microsoft.Windows/WindowsPowerShell
properties:
resources:
- name: DisableStartupAppTask
type: ComputerManagementDsc/ScheduledTask
properties:
taskName: StartupAppTask
taskPath: '\Microsoft\Windows\Application Experience'
enable: false I'm wondering why when using an array of resources under the Microsoft.Wiindows/WindowsPowerShell it didn't work |
Beta Was this translation helpful? Give feedback.
-
oh xyeah sure I already used this yes. |
Beta Was this translation helpful? Give feedback.
-
Is it possible to manage it using Microsoft/WMI ? If yes, can you show an example on how to use it please ?
Beta Was this translation helpful? Give feedback.
All reactions