Enable and disable scheduled task with PowerShell and variable

Just get rid of the curly brackets

$TaskName = "Name of my task"

Enable-ScheduledTask -TaskName "$TaskName"
Disable-ScheduledTask -TaskName "$TaskName"