I need create schedule task programmatically using Powershell (PS remoting).
My task executes a powershell script (and other cases a script cmd) immediately.
$powershellcmd = (get-command powershell.exe).Definition $upgradeWSPps1 = (Join-Path $ScriptDirectory Tests.LifeCycle.Deploy.MOSS.UpgradeWSP.ps1) $cmdToRun = "$powershellcmd -ExecutionPolicy Bypass -WindowStyle Hidden -NoLogo -File ""$upgradeWSPps1"" "
If you're creating a scheduled task by providing $cmdToRun to schtasks then you'll need to use both Windows CLI style escape character and Powershell style escape characters for double-quotes. In Powershell the back-tick ` is the escape character, but in Windows CLI (classic Windows shell) it is the forward slash.
Any suggestions about it ? any good sample code ?