96

This feature seems to have been added in PowerShell version 5.1, as I don't find it on my laptop still running 5.0.

When pressing Backspace in PowerShell, it will emit a 'beep' sound if there is no (more) text to delete. This is quite annoying if you accidentally hold down the key too long, as the sound will keep going for a short while after you release it.

I found this Super User question which suggests to disable the Beep service, which does work, but I would like to still be able to use beeps in scripts.

How do I disable the "beep on backspace" sound without disabling beeps completely?

FastEthernet
  • 5,246

3 Answers3

136

The beep is provided by the PSReadline module, which shipped with Windows 10. You need to change the PSReadline option to disable the bell:

Set-PSReadlineOption -BellStyle None

If you want this change for all future PowerShell sessions, then you need to add this command to your PowerShell profile. For example, to set the option for "Current User, Current Host" ($Profile):

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
if (!(Test-Path -Path "$Profile")) {New-Item -ItemType File -Path "$Profile" -Force}
Add-Content -Value "Set-PSReadlineOption -BellStyle None" -Path "$Profile"

The first line allows your profile run a startup script when PowerShell opens (About Execution Policies). The second line tests to see if you already have a startup script defined for "Current User, Current Host". The third line adds the bell option to your startup script.

MDMower
  • 1,054
user364455
  • 3,069
22

A more permanent solution that extends @PetSerAl's answer:

  1. Run PowerShell as administrator.
  2. Execute: set-executionpolicy remotesigned. This will allow PowerShell scripts to run on your computer. If you are not sure on what that is do not continue.
  3. Go to C:\Windows\System32\WindowsPowerShell\v1.0 if you are on Windows 10.
  4. Create a file named Microsoft.PowerShell_profile.ps1.
  5. Edit that file and add Set-PSReadlineOption -BellStyle None.
  6. Open a new PowerShell console and you should not hear the beep any more.

All (new) PowerShell consoles for all users on your computer are now silent.

This answer is for Windows 10.  For other versions of Windows, the folder might differ.

Odys
  • 1,711
  • 12
  • 36
  • 47
0

An adaptation of @Odys' answer using the Bash shell on the Windows Subsystem for Linux (assuming you have it enabled).

1 Open up a command prompt as an administrator, and run

set-executionpolicy remotesigned

2 Type bash to start the bash shell

3 Change to the proper directory

cd /mnt/c/Windows/System32/WindowsPowerShell/v1.0 

4 Make a file named "Microsoft.Powershell_profile.ps1" and write "Set-PSReadlineOption -BellStyle None" to it

echo "Set-PSReadlineOption -BellStyle None" >> Microsoft.Powershell_profile.ps1