Skip to content

Instantly share code, notes, and snippets.

@goyalmohit
Created June 26, 2019 06:46
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/c52228f9ed8f22386e81f8e8a67045e0 to your computer and use it in GitHub Desktop.
Save goyalmohit/c52228f9ed8f22386e81f8e8a67045e0 to your computer and use it in GitHub Desktop.
Function Get-PersonDetails {
Begin {
Write-Verbose "In Begin Block: Get-PersonDetails"
$PersonName = @()
$PersonAge = @()
}
Process{
Write-Verbose "In Process Block: Get-PersonDetails"
$PersonName = "Keith", "Eddy", "Kevin", "Kate"
$PersonAge = 29, 34, 23, 15
}
End{
Write-Verbose "In End Block: Get-PersonDetails"
$PersonName
$PersonAge
}
}
$PersonName = @()
$PersonAge = @()
$returnedData = Get-PersonDetails
$PersonName = $returnedData[0], $returnedData[1], $returnedData[2], $returnedData[3]
$PersonAge = $returnedData[4], $returnedData[5], $returnedData[6], $returnedData[7]
foreach($item in 0..3){
Write-Host "$($PersonName[$item]) is $($PersonAge[$item]) years old"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment