title: Function is not populating global variable
body: <p>Here is the code snippet I am trying, the potential problem is the array which is declared outside of the function cannot be used in the <code>testobjarray()</code> function. It will display the count as zero in the function <code>testobjarray()</code>, but in <code>addobjects()</code> I am able to add the object to array and display the contents of the object.</p>
  
  <pre><code>$Global:objectorray = @()
  
  function addobjects() {
    $object = New-Object PSObject
    $object | Add-Member -MemberType NoteProperty -Name "Name" -Value "Pradeep RN"
    $object | Add-Member -MemberType NoteProperty -Name "Age" -Value 24
    $object | Add-Member -MemberType NoteProperty -Name "Profession" -Value "Software Engineer"
    $objectorray += $object
    Write-Host "in addobjects function" $objectorray
  }
  
  function testobjarray() {
    Write-Host "in the another function" $objectorray.Count
  }
  
  addobjects
  testobjarray
  </code></pre>