As per my comment, from your other post, where I provide feedback. This is what I mean.
The below will work as shown...
@echo off
cls
::
title cpm
color e
::
::
cls
PowerShell -Command 'Hello from PowerShell^';^
Get-Date^;^
(Get-Process)[0]
::
@echo off
echo "hello from cmd"
:: Begin Results =========================================
:: D:\Scripts>PowerShell -Command 'Hello from PowerShell';Get-Date;(Get-Process)[0]
:: Hello from PowerShell
::
:: Saturday, August 6, 2022 00:30:14
::
:: Id : 10508
:: Handles : 224
:: CPU :
:: SI : 0
:: Name : aesm_service
::
::
::
:: "hello from cmd"
:: End Results =========================================
...but, if you'd say try and us a Select-Object command on that 'Get-Process', it will fail on that. Again, the more complicated the PS command you try and fire off, the more issues (formatting and execution ), you are going to encounter.
So, I cannot fathom why the bat/cmd, with embedded PS code, but, again, just write a .ps1 and call it from your bat/cmd file via PS. You'll have far more flexibility and readability options and far fewer headaches and unreasonable code statements.