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

PowerShell consol is terminated if choco.exe isn't found #1039

Open
DennisL68 opened this issue Aug 4, 2024 · 0 comments · May be fixed by #1092
Open

PowerShell consol is terminated if choco.exe isn't found #1039

DennisL68 opened this issue Aug 4, 2024 · 0 comments · May be fixed by #1092

Comments

@DennisL68
Copy link

What New Or Updated Would You Like To See?

In the section https://docs.chocolatey.org/en-us/guides/organizations/set-up-chocolatey-server/#setup-with-powershell-script, replace

if ($null -eq (Get-Command -Name 'choco.exe' -ErrorAction SilentlyContinue)) {
    Write-Warning "Chocolatey not installed. Cannot install standard packages."
    Exit 1
}

with

if ($null -eq (Get-Command -Name 'choco.exe' -ErrorAction SilentlyContinue)) {
    Write-Error  "Chocolatey not installed. Cannot install standard packages." -ErrorAction Stop
}

Why Is It Needed?

Exit will terminate the current PowerShell session, wiping any information needed or opportunity for troubleshooting for the user.
If the script is run from a PowerShell console, the console will be terminated as well.

Additional Context?

I assume Exit 1 is for legacy error handling if the PowerShell script is called from cmd.exe...

LeaDevelop added a commit to LeaDevelop/ChocolateyDocs that referenced this issue Oct 28, 2024
…ipt for cases when chocolatey is not installed
LeaDevelop added a commit to LeaDevelop/ChocolateyDocs that referenced this issue Oct 28, 2024
…ent-for-error-action' into (chocolatey#1039)-minor-improvement-for-error-action
LeaDevelop added a commit to LeaDevelop/ChocolateyDocs that referenced this issue Oct 28, 2024
LeaDevelop added a commit to LeaDevelop/ChocolateyDocs that referenced this issue Oct 28, 2024
…ipt for cases when chocolatey is not installed
LeaDevelop added a commit to LeaDevelop/ChocolateyDocs that referenced this issue Oct 28, 2024
…ent-for-error-action' into (chocolatey#1039)-minor-improvement-for-error-action
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant