- edited description
Allow control of PowerShell session used in executable
I'm not sure if this is possible but thought I would put this out there in the event it is...
When I'm building an executable that will wrap up commands used with dbatools (PowerShell module for SQL Server) there are times conflicts can occur with variables or other modules used in a user's profile.
An example is in my day-to-day work I will setup $PSDefaultParameterValues
and set the SQL Login I use to access the SQL Server instances I am working with at the time; or for container instance I'm using for development. I have found though when I build an executable and try to use that given executable it is pulling in my PowerShell profile. I know this because if I set the parameter defaults for authentication, it is failing to connect to instances.
I would like the ability to enforce that when the PowerShell process starts up the executable will enforce -NoProfile
so it does not have conflicts like default parameter values (as an example).
System information:
Visual Studio 2019 RC.2
PoshTools 4.2.1
Name Value
---- -----
PSVersion 5.1.17134.590
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17134.590
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Comments (5)
-
reporter -
This should be possible. I will see about getting it implemented.
-
This would be really handy as we run customized profiles that relaunch the session as a different user. this kicks the execution out.
-
- changed status to resolved
Fixes
#94→ <<cset 11491e7ebec9>>
-
You’ll be able to specify default PowerShell.exe parameters in the next version. So you could do something like “-NoProfile -NoExit -ExecutionPolicy Unrestricted” and then when the user runs the compiled exe, it will automatically apply these parameters.
- Log in to comment