Sha*_*tin 5 powershell powershell-3.0
一些PowerShell命令行开关接受管道输入ByProperyName,一些做ByValue,其他人为它们做.这是什么意思?它如何影响我们的PowerShell脚本?
的ValueFromPipeline参数属性将映射的参数值的任何对象类型是从管道传递到.如果使用ValueFromPipelineByPropertyName参数属性,则将使用通过管道传递到命令+参数的对象使用特定属性.
Get-Process | Stop-Process; # Stop-Process expects to receive a Process object
<#
-InputObject <Process[]>
Stops the processes represented by the specified process objects. Enter a variable that contains the objects, or
type a command or expression that gets the objects.
Required? true
Position? 1
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false
#>
Run Code Online (Sandbox Code Playgroud)
# Get-Process looks for a ComputerName property on the incoming objects
[PSCustomObject]@{
ComputerName = 'localhost';
} | Get-Process;
<#
-ComputerName <String[]>
Gets the processes running on the specified computers. The default is the local computer.
Type the NetBIOS name, an IP address, or a fully qualified domain name of one or more computers. To specify the
local computer, type the computer name, a dot (.), or "localhost".
This parameter does not rely on Windows PowerShell remoting. You can use the ComputerName parameter of Get-Process
even if your computer is not configured to run remote commands.
Required? false
Position? named
Default value Local computer
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
#>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2145 次 |
| 最近记录: |