Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Issue] Powershell scripts should be executed with the -NoProfile switch #4592

Open
markwragg opened this issue Nov 27, 2024 · 1 comment
Open
Labels
customer-reported identify a customer issue question

Comments

@markwragg
Copy link

Output from azd version

azd version 1.11.0 (commit 5b92e06)

Describe the bug

When PowerShell hook scripts are executed, if the user has a profile.ps1 then the profile script is executed. It would be better to call pwsh.exe with the -noprofile switch to ensure profile scripts are not loaded.

To Reproduce

Execute azd with a PowerShell hook script configured on a machine where a profile.ps1 exists in one of the standard directories: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles?view=powershell-7.4

Expected behavior

The profile script should not be executed.

Environment
Information on your environment:
* PowerShell 7.4.6, Windows 11
* IDE and version : Visual Studio Code

Additional context

The -noprofile switch for pwsh.exe is documented here: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_pwsh?view=powershell-7.4#-noprofile---nop

@Yionse
Copy link
Member

Yionse commented Dec 2, 2024

@rajeshkamal5050, We can reproduce the issue and are currently attempting to fix it.

The currently planned solution is to check if the user explicitly passed the -NoProfile parameter before executing the PowerShell hook command. If the user passed the -NoProfile parameter, then manually pass the -NoProfile parameter when calling pwsh.exe to execute the hook command. If the user did not pass the -NoProfile parameter, pwsh.exe will not include it when executing and will load the profile.ps1 configuration file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer-reported identify a customer issue question
Projects
None yet
Development

No branches or pull requests

2 participants