问题描述
如果您发现这是一个非常la脚的问题,请原谅,但是由于我正在学习Powershell,因此我需要提出疑问。
Please excuse me if you find this a very lame questions, but since I am learning Powershell I need to ask.
这是本书的下一部分发布问题并在收到答案。
This is a sort of next part of the question posted and answer received here.
我有一个自定义名为Get-DirectoryListing的cmdlet,我添加了别名 gdl(在.psm1文件中使用New-Alias命令)。因此,用户可以使用Get-DirectoryListing或gdl触发同一命令。现在,我想在我的代码(.NET,C#)中检测出用于执行命令的文本。可以说如果用户使用别名'gdl'来执行命令,我想显示类似
I have a custom cmdlet named Get-DirectoryListing and I added an alias 'gdl' (using New-Alias command in .psm1 file). So user can use either Get-DirectoryListing or gdl to fire the same command. Now I want to detect in my code (.NET, C#) which text was used to execute the command. Lets say if user used alias 'gdl' to execute the command, I want to show message like
但是如果用户使用Get-DirectoryListing执行命令,我不想显示此消息。
But I do not want to show this message if user uses Get-DirectoryListing to execute the command.
实现此目标的最佳方法是什么?
What is the best way to achieve this?
推荐答案
检查
您的PSCmdlet实例上的属性。
property on your PSCmdlet instance.
这篇关于如何查找用户使用了哪个Cmdlet Alias?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!