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'
0 comments
Hide comments