Update - It work on tasks that I've created.
When I try to disable a task created by someone else, and the machine name has subsequently changed, I can't disable the task.
The code throws an exception - "No mapping between account names and security IDs was done (Exception from HRESULT 0x80070534)"
Also, if I try to disable the task by right-clicking it in task scheduler, it won't let me, displaying an error message saying 'The specified account name is not valid'. In order to fix this, I have to go into the properties of the task and change the user account.
Strangely, the task with the incorrect account name still runs, so how would I change the account name so that I can disable it?
When I try to disable a task created by someone else, and the machine name has subsequently changed, I can't disable the task.
The code throws an exception - "No mapping between account names and security IDs was done (Exception from HRESULT 0x80070534)"
Also, if I try to disable the task by right-clicking it in task scheduler, it won't let me, displaying an error message saying 'The specified account name is not valid'. In order to fix this, I have to go into the properties of the task and change the user account.
Strangely, the task with the incorrect account name still runs, so how would I change the account name so that I can disable it?