How can I start Powershell script as noprofile in Visual Studio Code, I can run the Powershell Ise with noprofile with command PowerShell_Ise -NoProfile . B
You can go in powershell extension settings and remove check box at "PowerShell: Enable Profile Loading", i think it help. Also check task for runs powershell scripts with some parameters discussion about task
In the context of Visual Studio Code:
3 different types of shells apply intrinsically:
The default shell for the integrated terminal (the TERMINAL
tab of the panel).
tasks.json
) instead of the default integrated-terminal shell.The default shell for opening an external terminal (> Open New External Terminal
)
With the PowerShell extension installed, yet another shell applies:
These shells:
-NoProfile
in your case.The following excerpt from a Settings.json
file (> Preferences: Open Settings (JSON)
) shows the relevant settings for each (as of VSCode v1.42 / PowerShell Extension 2020.3.0):
{
// ...
// **General-purpose integrated-terminal shell**:
// Mere file *names* work for executables that are in %PATH%; e.g., "cmd.exe"
// If you need to specify a file *path*, use "\\" or "/" as the path separator.
// On Unix-like platforms, replace ".windows" with ".osx" or ".linux",
// as appropriate.
"terminal.integrated.shell.windows": "powershell.exe",
// Startup parameters to pass to the specified shell.
// On Unix-like platforms, replace ".windows" with ".osx" or ".linux",
// as appropriate.
"terminal.integrated.shellArgs.windows": "-NoProfile",
// **Automation-tasks shell**,
// for the tasks defined in "tasks.json" and for debugging:
// This overrides the default shell configured above.
// Note: There is NO way to pass startup arguments.
"terminal.integrated.automationShell.windows": "cmd.exe",
// **External-terminal shell**:
// The executable to use for opening an external terminal window
// (> Open New External Terminal).
// Note: There is NO way to pass startup arguments,
// so you cannot suppress profile loading, for instance.
"terminal.external.windowsExec": "powershell.exe",
// **PowerShell Integrated Console**:
// Profile loading is *disabled* by default; you can enable it here, but
// note that the PowerShell Integrated Console has its own,
// separate $PROFILE location, which differs from the one in a
// regular console window. If you want to load your regular profile,
// place the following statement in the $PROFILE file of
// the Integrated Console:
// . ($PROFILE -replace '\.VSCode', '.PowerShell')
// (Open the profile file for editing by submitting the following command
// from the Integrated Console:
// code $PROFILE
// )
"powershell.enableProfileLoading": false,
// ...
}
If you want to configure the PowerShell Integrated Console to use a different PowerShell edition / version:
GUI method: With the PowerShell Integrated Console active in the Terminal
tab in VSCode's panel (lower half of the screen), click on the version number icon in the bottom right corner (e.g., )
Switch to:
Settings.json
file (see next point).Via settings.json
(> Preferences: Open Settings (JSON)
):
The array-valued powershell.powerShellAdditionalExePaths
property allows you to add the full executable paths of PowerShell versions that the extension couldn't find automatically - see example below.
The powershell.powerShellDefaultVersion
property determines which version to use by default; since you must specify it by its display name, which includes the automatically chosen display name for auto-discovered versions, it's simplest to make the selection via the GUI, as shown above.
{
// ...
// The paths to any PowerShell executables that the extension cannot auto-discover.
// The "versionName" is a self-chosen name that is offered in the
// version-selector menu that pops up when you click on the version number
// near the right edge of the status bar when the
// PowerShell Integrated Console is active.
// (The currently active version is displayed by its actual characteristics,
// not by its "versionName" property; e.g.,
// "PowerShell 7.0 (X64) Core Edition [7.0.0]")
"powershell.powerShellAdditionalExePaths": [
{
"versionName": "Latest Preview",
"exePath": "C:\\Users\\jdoe\\AppData\\Local\\Microsoft\\powershell\\pwsh.exe"
}
],
// The "versionName" property of the PowerShell executable to use by default.
// Note: To switch to an executable that the extension found automatically,
// it is simplest to use the version-selector menu.
"powershell.powerShellDefaultVersion": "Latest Preview",
// ...
}