powershell - Get-MsolUser 的所有参数放入数组
问题描述
想要将 Get-MsolUser 支持的所有参数的名称扔到一个数组中,以便能够动态地从用户那里获取不同的信息。
Get-Command Get-MsolUser
上面的命令不显示参数,只显示命令本身。
解决方案
您可以运行以下命令,它只是链接成员访问运算符.
$array = (Get-Command Get-MSolUser).Parameters.Values.Name
Parameters
是具有内置Values
属性的 Dictionary 对象。该属性是一个集合,其中包含有关每个参数的属性。由于您只需要名称,因此您可以简单地访问该Name
属性。
如果你想排除某些参数,我只是介绍一个排除列表。
$exclude = 'Debug','ErrorAction','ErrorVariable','InformationAction','InformationVariable','OutVariable','OutBuffer','PipelineVariable','Verbose','WarningAction','WarningVariable'
((Get-Command Get-MSolUser).Parameters.Values | Where Name -notin $exclude).Name
推荐阅读
- scala - Scala-还有另一种方法来编写这个 foreach 方法吗?
- action - 如何在销售确认时将操作从报价转换为销售订单 For odoo 10
- java - 无法在 Spring MVC 中使用 Controller 自动装配 Dao
- c++ - 在 Mac 上使用 cmake for Musecore 找不到 QT5 模块
- c# - 使用 Navigation.Push 打开页面时,异步是否提供任何优势?
- android - 获取默认浏览器代码在 Android <=4.4 中返回不正确的包
- javascript - 返回语句中的 OR 条件
- jmeter - 如何使用 1000 个用户(1 个命令/用户)使用 1 个 ssh 连接使用 jmeter 达到 1000 个 ssh 命令
- reactjs - react-stockcharts:以小宽度(< 150px)渲染会破坏聊天
- android - ObservableField 还是 LiveData?哪一个是最好的?