Difference between revisions of "PowerShell"

From no name for this wiki
Jump to: navigation, search
(Pipes)
Line 2: Line 2:
 
$_ Variable
 
$_ Variable
  
<source>
+
<source lang="Powershell">
 
Get-Service | WHERE {$_.status -eq "Running"} | SELECT displayname
 
Get-Service | WHERE {$_.status -eq "Running"} | SELECT displayname
 
# “$_.” defines current element in the pipe
 
# “$_.” defines current element in the pipe

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