$Args in PowerShell

Just a tip #3

In scripting, there are many things to experience in many ways, the traditional way is always the best practice though, the formal way is always an option…

Function Add
{
    param
    (
        [Parameter(Mandatory=$true)]
        [int] $Number1,
        [Parameter(Mandatory=$true)]
        [int] $Number2
    )

    [int] $Sum = 0
    $Sum = $Number1 + $Number2
    return, $Sum
}

Add -Number1 4 -Number2 5

Formal way


$Add = {$args[0] + $args[1]}

. $Add 4 5

Share it on     |   |   |   | 
  Prev:  

SQL Server PSObject - Working With SQL Server Using PowerShell

  :Next  

List Of Available Azure VM Image Skus Using New Azure PowerShell Module Az

comments powered by Disqus