In M-x powershell and M-x shell, the terminal is "dumb" and only understands programs that print, but not programs that go fullscreen.
So, it will work with ls, cat, and cd, but will fail on vim, man, and less. I bet your script tries to open vim, no?
This restriction exists for a reason: when a program goes fullscreen, it captures all keyboard input. So if you open vim and type C-x, does it run the Emacs command for C-x or the Vim command? If you always run the Emacs command, that means when you type j, it will insert j into the Emacs buffer instead of scrolling down in Vim. Vim will become unusable. If you always run the Vim command, that means you can no longer use C-x C-c to get out of Emacs, since the command will be absorbed by Vim.
One workaround is to use M-x term. In term all keystrokes are sent to the program, so you can open and use Vim like normal. To run an Emacs command, start with C-c. You can read more about it here. I'm not sure it it exists in Windows.
Another workaround to use emacsclient:
;; in init.el
(server-start)
# in a shell
$ emacsclient file.txt
This will open the file in your existing Emacs window. When you're done editting the file, press C-x # to go back to the shell.