I want to specify a multi-line PowerShell command in a cmd.exe .bat script. I clearly do not yet have the right line continuation and/or quoting. I also tried using a backtick as the line continuation character with similar failure. How can I enter this correctly?
PS C:\src\t> cat .\pd.bat
powershell -NoProfile -Command "Get-ChildItem -Path '../' -Filter '*.doc' | ^
Select-Object -First 1 | ^
ForEach-Object { notepad `"$_.FullName`" }"
PS C:\src\t> .\pd.bat
C:\src\t>powershell -NoProfile -Command "Get-ChildItem -Path '../' -Filter '*.doc' | ^
^ : The term '^' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if
a path was included, verify that the path is correct and try again.
At line:1 char:45
+ Get-ChildItem -Path '../' -Filter '*.doc' | ^
+ ~
+ CategoryInfo : ObjectNotFound: (^:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException