Skip to content

Instantly share code, notes, and snippets.

@goyalmohit
Last active November 28, 2021 18:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goyalmohit/5f324c934330cbb40aa60d5b2f314667 to your computer and use it in GitHub Desktop.
Save goyalmohit/5f324c934330cbb40aa60d5b2f314667 to your computer and use it in GitHub Desktop.
Function Get-Sum {
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[int] $Number1,
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[int] $Number2
)
Begin {
Write-Verbose "In Begin Block: Get-Sum"
$Sum = 0
}
Process{
Write-Verbose "In Process Block: Get-Sum"
$Sum = $Number1 + $Number2
}
End{
Write-Verbose "In End Block: Get-Sum"
return $Sum
}
}
$Sum = 0
$Sum = Get-Sum -Number1 5 -Number2 7
Write-Host $Sum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment