Enable aliases in restricted PowerShell session

Enable aliases for restricted endpoint.

John Savill

April 9, 2017

1 Min Read
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'

 

About the Author(s)

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like