How do I type a TAB character in PowerShell? How do I type a TAB character in PowerShell? windows windows

How do I type a TAB character in PowerShell?


If it helps, you can embed a tab character in adouble-quoted string:

"`t hello"


Test with [char]9, such as:

$Tab = [char]9Write-Output "$Tab hello"

Output:

     hello


In the Windows command prompt you can disable tab completion, by launching it thusly:

cmd.exe /f:off

Then the tab character will be echoed to the screen and work as you expect. Or you can disable the tab completion character, or modify what character is used for tab completion by modifying the registry.

The cmd.exe help page explains it:

You can enable or disable file name completion for a particular invocation of CMD.EXE with the /F:ON or /F:OFF switch. You can enable or disable completion for all invocations of CMD.EXE on a machine and/or user logon session by setting either or both of the following REG_DWORD values in the registry using REGEDIT.EXE:

HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\CompletionCharHKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\PathCompletionChar    and/orHKEY_CURRENT_USER\Software\Microsoft\Command Processor\CompletionCharHKEY_CURRENT_USER\Software\Microsoft\Command Processor\PathCompletionChar

with the hex value of a control character to use for a particular function (e.g. 0x4 is Ctrl-D and 0x6 is Ctrl-F). The user specific settings take precedence over the machine settings. The command line switches take precedence over the registry settings.

If completion is enabled with the /F:ON switch, the two control characters used are Ctrl-D for directory name completion and Ctrl-F for file name completion. To disable a particular completion character in the registry, use the value for space (0x20) as it is not a valid control character.