I'm trying to create a scheduled task through schtasks comand and I'm struggling on how to escape double quotes (and other possible special characters) for the password on /RP parameter.
SCHTASKS /create /tn "Task name" /tr "powershell D:\path\to\powershell\script\powershellScript.ps1" /ru userName /rp pass"word /rl HIGHEST /f /sc MONTHLY /st 02:00
Some examples of what I've tried so far (after a lot of search), nothing working (and all combinations I could think of):
- Enclosing the password with double quotes: /rp "pass"word"
- Enclosing the password with single quotes: /rp 'pass"word'
- Escaping special characters with ^: /rp "pass^"word"
- Escaping special characters with ": /rp "pass""word"
- Escaping special characters with : /rp "pass\"word"
Every time, the error message I got is always the same (or very similar), suggesting that the double quotes causes the interpretation of the command to break:
Invalid syntax. Mandatory option 'sc' is missing. Type "CREATE /?" for usage.
Is it even possible?