You should not be deploying a script for production use in PowerShell ISE (ever). When you run PowerShell you get a console that has access to the operating system. When you run PowerShell ISE it is a Win32 application that has a console emulator built into it. The console in ISE is not a real execution environment and there are several functions that simply don’t work in it. It’s acceptable for initial testing, but you shouldn’t trust it as a complete test and you definitely shouldn’t use it for normal execution. Basically, the console in ISE is fake. The PowerShell team wrote up a list of differences, which is dated now but gives you an idea of how they don’t match up.
Ok, now to your actual issue. You’re asking about getting output from a PowerShell script when executing it via a cmd file, but what you actually need is just a simple way to execute a PowerShell script (e.g. by double-clicking an icon). This is an example of an XY problem.
There is a better solution - you can create a shortcut that will launch your PowerShell script in the Windows PowerShell console. Here’s a discussion from stackoverflow. To make this work, do the following:
- On your desktop: right-click > New > Shortcut
- Under "Type the location of the item:" set the location to your script, then click "Next"
- Give the shortcut a useful name, then click "Finish"
(you should now have a shortcut that looks like text file with a PowerShell ISE icon - if you double click this it will just open in Notepad for editing - we'll fix that next)
- Right-click your new shortcut icon and select Properties
- "Target:" should contain the path to your script - something like this C:\path\script.ps1. Edit it so that it looks like this:
powershell -Command "& 'C:\path\script.ps1' " -NoProfile
then click OK
(your shortcut icon should now look like the PowerShell console icon)
- Double-click the shortcut. It should open a new PowerShell window and run your script.
DISCLAIMER & WARNING
Double-click execution of PowerShell scripts is normally prevented in Windows for good reason. It creates security issues for scripts to be executable without oversight. If possible, you should change the Write permissions on the shortcut and the script so that they can only be edited with administrative privileges, to prevent the shortcut from being edited to launch other scripts, and to prevent the script from being edited to do things that you don’t want. Setting this up for your one script is effectively the same as trying to do it with a cmd file as you were, and it’s probably an acceptable risk for this use case.
I don’t recommend that you use the registry change solution that is discussed in that stackoverflow thread, because it will make PowerShell scripts double-click executable across the entire operating system. Setting this up for only one script at a time is much more secure.
Finally, don’t set ExecutionPolicy to unrestricted, ever. Set it to RemoteSigned instead. This will prevent unsigned scripts from being remotely executed on your system, but will still allow execution of local scripts.