Difference between revisions of "PowerShell"
(→Pipes) |
|||
Line 8: | Line 8: | ||
− | <source> | + | <source lang="Powershell"> |
Get-Service | Sort-Object -property Status | Get-Service | Sort-Object -property Status | ||
</source> | </source> | ||
== Fucntion == | == Fucntion == | ||
− | <source> | + | <source lang="Powershell"> |
Send-Greeting -name Claude | Send-Greeting -name Claude | ||
Revision as of 08:59, 4 June 2022
Pipes
$_ Variable
Get-Service | WHERE {$_.status -eq "Running"} | SELECT displayname
# “$_.” defines current element in the pipe
Get-Service | Sort-Object -property Status
Fucntion
Send-Greeting -name Claude
function Send-Greeting
{
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true)]
[string] $Name
)
Process
{
Write-Host ("Hello " + $Name + "!")
}
}