Created
July 1, 2019 09:35
-
-
Save goyalmohit/ca346954181b6fb64b2eda8c34e3a3c3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Get-Sum { | |
[CmdletBinding()] | |
Param( | |
[Parameter(Mandatory=$true)] | |
[ValidateNotNullOrEmpty()] | |
[int] $Number1, | |
[Parameter(Mandatory=$true)] | |
[ValidateNotNullOrEmpty()] | |
[int] $Number2 | |
) | |
Begin { | |
Write-Verbose "Inside Begin Block: Get-Sum" | |
} | |
Process{ | |
Write-Verbose "Inside process block: Get-Sum" | |
Write-Verbose "Adding both numbers: $Number1 and $Number2" | |
$Sum = $Number1 + $Number2 | |
return $Sum | |
} | |
end { | |
Write-Verbose "In end block: Get-Sum" | |
} | |
} | |
# calls function without using verbose parameter | |
Write-host "Calling Get-Sum without using verbose parameter" | |
Get-Sum -Number1 10 -Number2 7 | |
# calls function with using verbose parameter | |
Write-Host "Calling Get-Sum with using verbsose parameter" | |
Get-Sum -Number1 10 -Number2 7 -Verbose |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment