Escape quotes with cmd

Hello guys,

i want to run this powershell scripblock with cmd script :

Get-ScheduledTask | foreach {Export-ScheduledTask -TaskName $.TaskName -TaskPath $.TaskPath | Out-File (Join-Path “D:\Testing\Sauv\SchTasks” “$($_.TaskName).xml”)}

Like :

powershell -command “Get-ScheduledTask | foreach {Export-ScheduledTask -TaskName $.TaskName -TaskPath $.TaskPath | Out-File (Join-Path “D:\Testing\Sauv\SchTasks” “$($_.TaskName).xml”)}”

but i can’t get the result, how can i espace the quotes ?

thanx for your help

Welcome to the forum. :wave:t4:

Why? I mean why don’t you use PowerShell without CMD?

BTW: When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.

Thanks in advance

How to format code in <---- Click :point_up_2:t4: :wink:

PowerShell.exe -Command "Get-ScheduledTask | foreach {Export-ScheduledTask -TaskName $_.TaskName -TaskPath $_.TaskPath | Out-File (Join-Path 'D:\Testing\Sauv\SchTasks' '$($_.TaskName).xml')}"