Thanks for the reply, the issue I am having is that when using escape token to create SQL agent jobs, its clashing with SQLCMD. I am getting the error.
invoke-sqlcmd : 'JOBID' scripting variable not defined
At line:16 char:1
select @outputfilepath = N'K:\SQL\file_$(ESCAPE_SQUOTE(JOBID))_$(ESCAPE_SQUOTE(STEPID))_$(ESCAPE_SQUOTE(STRTDT))_$(ESCAPE_SQUOTE(STRTTM)).txt'