Dup Ver Goto 📝

PowershellFunctions1

PT2/lang/powershell/examples does not exist
To
30 lines, 77 words, 650 chars Page 'PowershellFunctions1' does not exist.

which example

# function with one mandatory argument
function Get-FileSize {
    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true)]
        [string]$Path
    )

    if (Test-Path $Path) {
        $size = (Get-Item $Path).Length
        Write-Output "The size of the file '$Path' is $size bytes."
    } else {
        Write-Output "The file '$Path' does not exist."
    }
}

# worked example
function Which-Command { 
    [CmdletBinding()] 
    param ( 
        [Parameter(Mandatory = $true)] 
        [string] $CommandName 
    ) 

    ( Get-Command $CommandName ).Path 
}
New-Alias -Name which -Value Which-Command