Invoke-command Scriptblock help needed.

windows 7 computer start-scheduledtask not a valid function so I am trying to use schtasks which run on Windows 7


This invoke-command having trouble with

PS C:\util> Invoke-Command -ComputerName tgkw012 -ScriptBlock {schtasks /run /s /TN “Install-Updates”}
ERROR: Invalid syntax. Value expected for '/s'.
+ CategoryInfo          : NotSpecified: (ERROR: Invalid ...ected for '/s'.:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
+ PSComputerName        : tgkw012

Type "SCHTASKS /RUN /?" for usage.

Any ideas


Thank you



With the invoke command you’re running it on the remote server. Looking at the error you just need to drop the /S

Invoke-Command -ComputerName tgkw012 -ScriptBlock {schtasks /run /TN “Install-Updates”}

That makes 2 assumptions:

  1. The remote computer has that task name
  2. the account you’re running the command as, has permissions to run that scheduled task.

Thanks that worked great