PowerShell

From no name for this wiki
Revision as of 08:59, 4 June 2022 by Claude (talk | contribs)
Jump to: navigation, search

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 + "!")
    }
}