Is there a way to add Alias to Powershell Cmdlet programmatically?

淺唱寂寞╮ 提交于 2019-12-05 14:41:39

You need to create a psm1 file (powershell module) where you specific your dll with yours cmdlets to load and add aliases in this way:

In your module folder ( Get-ModuleFolder give a list of all if you have more that the default one, in my example I use the first one) create a folder with same name of your .dll and a SameNameOfYourDll.psm1 with this content:

Import-module "$((Get-ModulePath)[0])mycustomcmdlet\mycustomcmdlet.dll"
set-alias gdl Get-DirectoryListing -scope Global

For more raffinate module building look also at module manifest

Module manifest is the preffered way for .dll with custom cdmlets.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!