I have a batch file that starts a PowerShell script.
Batch file:
START Powershell -executionpolicy RemoteSigned -noexit -file "MyScript.ps1"
MyScript.ps1 :
Write-Output "Hello World!"
It works fine, with one exception. The appearance of the window is like the old cmd.exe (black background) and not the PowerShell (blue background).
How can I get the true PowerShell window, if I start it from a batch file?
Thanks.
If you really want a blue background, in your script add code to change the background color.
#save the original
$original=$host.ui.RawUI.BackgroundColor
$front=$host.ui.RawUI.ForegroundColor
$host.ui.RawUI.BackgroundColor="DarkBlue"
$host.ui.RawUI.ForegroundColor="White"
cls
#run your code
dir c:\scripts
#set it back
$host.ui.RawUI.BackgroundColor=$original
$host.ui.RawUI.ForegroundColor=$front
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With