Skip navigation
Enable aliases in restricted PowerShell session

Enable aliases in restricted PowerShell session

Q. How do I enable aliases to work in a restricted custom PowerShell endpoint?

A. If you connect to a constrained PowerShell endpoint and try to exit it will fail, instead you have to type exit-pssession. This is because the exit alias is not available however aliases can be enabled through VisibleAlises parameter. Note you should also ensure -LanguageMode is not set to NoLanguage and instead is something like ConstrainedLanguage. An example below enables the exit alias.

New-PSSessionConfigurationFile –ModulesToImport OneMOD, ActiveDirectory `
  -VisibleCmdLets ('*OneMOD*','*AD*') `
  -VisibleFunctions ('TabExpansion2') -VisibleAliases ('exit') –LanguageMode 'ConstrainedLanguage' `
  -SessionType 'RestrictedRemoteServer' –Path 'c:\onemodonly.pssc'


Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.