How do I have a PowerShell script embedded within the same file as a Windows batch script?
I know this kind of thing is possible in other scenarios:
This one only passes the right lines to PowerShell:
dosps2.cmd:
@findstr/v "^@f.*&" "%~f0"|powershell -&goto:eof
Write-Output "Hello World"
Write-Output "Hello some@com & again"
The regular expression excludes the lines starting with @f and including an & and passes everything else to PowerShell.
C:\tmp>dosps2
Hello World
Hello some@com & again