Skip to content

Instantly share code, notes, and snippets.

@dancing-groot
Last active May 10, 2023 13:09
Show Gist options
  • Save dancing-groot/caba8c6305cd776df997e15de6e1889a to your computer and use it in GitHub Desktop.
Save dancing-groot/caba8c6305cd776df997e15de6e1889a to your computer and use it in GitHub Desktop.
<#
.SYNOPSIS
A brief description of the function or script
.DESCRIPTION
A longer description
.NOTES
Version: yyyy.mm.dd
Author: Author Name
Info: Release Notes
#>
[cmdletBinding()]
param()
#region FUNCTIONS
function Test-Function
{
[cmdletBinding()]
param
(
[Parameter(ValueFromPipeline,ValueFromPipelinebyPropertyName)]
[int[]]$MyVar = 0
)
begin
{
if ($PSBoundParameters['Debug']) { $DebugPreference = 'Continue' }
}
process
{
foreach ($variable in $MyVar)
{
Write-Debug "Testing $variable"
if ($variable -eq 1)
{
$true
}
else
{
$false
}
}
}
} # Test-Function
#endregion FUNCTIONS
#region DECLARATION
$Var = 1
#endregion DECLARATION
#region MAIN
Write-Host "Calling function with no argument: $(Test-Function)"
Write-Host "Calling function with argument value `$Var: $(Test-Function -MyVar $Var)"
Write-Host "First pipe test:"
0,1,2,"a" | Test-Function -Debug -ErrorAction SilentlyContinue
Write-Host "Second pipe test:"
Test-Function -MyVar -1,0,1
#endregion MAIN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment