I would like to run my powershell script in v2 mode. Is it possible to do this without having a wrapper script?
So for example, I can do this now if I can two files.
MainContent.ps1
write-output 'run some code'
Read-Host -Prompt "Scripts Completed : Press any key to exit"
Wrapper.ps1
powershell -version 2 -file 'MainContent.ps1'
This will work but I'm hoping I don't need to have this second wrapper file because I'm creating a whole bunch of these ps1 scripts, and having wrapper files will double the amount of scripts I'll need.
I'm hoping I can do something like this.
MainContent.ps1
Set-Powershell -version 2
write-output 'run some code'
Read-Host -Prompt "Scripts Completed : Press any key to exit"
Later on, I would also like each script to ask for a set of credentials as well without using a wrapper file.
Is this currently possible?
To be clear, I'm using version 2 of powershell