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
Olaf
May 12, 2022, 8:59am
#2
Sadok,
Welcome to the forum.
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 PowerShell.org <---- Click
PowerShell.exe -Command "Get-ScheduledTask | foreach {Export-ScheduledTask -TaskName $_.TaskName -TaskPath $_.TaskPath | Out-File (Join-Path 'D:\Testing\Sauv\SchTasks' '$($_.TaskName).xml')}"