I'm trying to use SCHTASKS to create a scheduled task on Windows. The parameters include single quotes. If I create my task manually, it works. In the Windows Task Scheduler GUI, the "Details" (within the action tab) show up like this:
powershell (New-Object System.Net.WebClient).DownloadString ('http://mywebserver/myscript.ps1\') | powershell.exe -noprofile -
However, when I enter my SCHTASKS command...
schtasks.exe /Create /TN "My Task" /TR "powershell (New-Object System.Net.WebClient).DownloadString ('http://mywebserver/myscript.ps1\') | powershell.exe -noprofile -" /SC MINUTE /mo 60 /RL HIGHEST
This then appears in the GUI (note the interpretation of a single quote to a double one on the first, but not the second instance:
powershell (New-Object System.Net.WebClient).DownloadString ("http://mywebserver/myscript.ps1\') | powershell.exe -noprofile -
I've tried escaping it etc. (which works fine for double quotes but not for single) but can't seem to figure it out..?!
Many thanks in advance for any suggestions.