命令支持管道
来源:互联网 发布:淘宝店加权重有哪些 编辑:程序博客网 时间:2024/06/06 14:15
命令支持管道
支持管道,需要为参数加
[Parameter(ValueFromPipeline)]
特性。
Function Test-Something { [Alias("ts")] [CmdletBinding(SupportsShouldProcess)] param( [Parameter(ValueFromPipeline)] $What) begin{ } Process { if ($pscmdlet.ShouldProcess($What)) { foreach ($item in $what) { dir $item } } } # End Process end { }} # End如果命令支持数组,比如 dir,就可把 foreach ($item in $What) { dir $item } 换成dir $What
调用
ts c:, d:\
可以使用管道:
“c:\”, “d:\” | ts
使用管道时,必须加引号。
如果是不支持数组的命令,比如, Write-Host,就要注意了,这时的输出结果就不一样了。
Write-Host “Output $What”
ts c:, d:\
Output c:\ d:\
这并不是我们想要的结果。
“c:\”, “d:\” | ts
Output c:\
Output d:\
0 0
- 命令支持管道
- Linux中的Xargs命令,支持|管道传递参数
- 管道命令
- 管道命令
- 管道命令
- 管道命令
- 管道命令
- 管道命令
- 管道命令
- 管道命令
- 管道命令
- 管道命令
- 管道命令
- 管道命令
- 10.管道、脚本支持
- 匿名管道、命令管道、管道容量以及管道组织方式
- 管道和xargs命令
- linux 管道命令
- 通过inotify监控linux文件系统变化
- 第三周项目(8):顺序表应用(2)
- .a 静态库
- SDUTOJ3309----乱七八糟的图
- poj 1330
- 命令支持管道
- HDU——5281 Senior's Gun
- 多线程篇 概念混淆面试常考问题
- Android SharedPreferences在不同应用模块里通信
- HDU 1527 取石子游戏(威佐夫博弈)
- 串口mcu:重新编写的ldisc
- ubunt 下搭建ftp服务器
- H5学习之旅-H5列表(8)
- CentOS7安装.tar.gz包