Using powershell commands inside of batch commands

Greetings! I hope I can get some insight into this as I’m unable to get it functioning. Long story short, I need to run powershell commands inside of an unattended answer file that adds a powershell command to a scheduled task. The line also needs to be no more than 259 characters (this is the exact character count it is currently).

Here is the line:

powershell.exe “Set-ScheduledTask -TaskName TestTask -Action (New-ScheduledTaskAction "powershell.exe” -Argument "“New-Item -Path c: -Name textshut.txt -ItemType File"“),(New-ScheduledTaskAction "schtasks.exe” -Argument "/TN TestTask /Delete /F“)”

When I run this, it says it’s missing the closing ‘)’. I’m unsure how to break the quotes so that all the characters are recognized properly by the command line.

submitted by /u/_VitaminD
[link] [comments]

Leave a Reply