# Escape quotes with cmd

**URL:** <https://forums.powershell.org/t/escape-quotes-with-cmd/19295>\
**Category:** PowerShell Help\
**Created:** [May 12, 2022, 8:06am UTC](https://forums.powershell.org/t/escape-quotes-with-cmd/19295 "2022-05-12T08:06:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sadhou2004](https://avatars.discourse-cdn.com/v4/letter/s/ccd318/32.png) [@sadhou2004](https://forums.powershell.org/u/sadhou2004)\
**Post date:** [May 12, 2022, 8:06am UTC](https://forums.powershell.org/t/escape-quotes-with-cmd/19295/1 "2022-05-12T08:06:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [May 12, 2022, 8:59am UTC](https://forums.powershell.org/t/escape-quotes-with-cmd/19295/2 "2022-05-12T08:59:17Z")

</div>

Sadok,  
Welcome to the forum. 👋🏽

> [@sadhou2004](#):
>
> i want to run this powershell scripblock with cmd script :

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

> [@sadhou2004](#):
>
> how can i espace the quotes ?

> **[about Quoting Rules - PowerShell](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_quoting_rules?view=powershell-7.2)**
>
> Describes rules for using single and double quotation marks in PowerShell.

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 PowerShell.org](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/2X/b/bee50c628238f2c076c0504efb6b15f2fb11f002.gif) \<---- Click 👆🏽 😉

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

```

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:17pm UTC](https://forums.powershell.org/t/escape-quotes-with-cmd/19295/3 "2024-05-16T20:17:57Z")

</div>


