azureautomation / runbooks

Sample Automation runbooks
MIT License
150 stars 128 forks source link

Bug in Azure Automation Powershell Version #70

Open georgedavid29 opened 3 years ago

georgedavid29 commented 3 years ago

the version of powershell run in azure automation has a bug for ps objects count when the value is 1.

sample code:

$myHashtable1 = @{ Name = 'Bob' State = 'New York' }

$myHashtable2 = @{ Name = 'Bob' State = 'New York' }

$myHashtable3 = @{ Name = 'Joe' State = 'New Jersey' }

$PSVersionTable

$MyPSObject = @()

$MyPSObject += [pscustomobject]$myHashtable1 $MyPSObject.Count $MyPSObject += [pscustomobject]$myHashtable2 $MyPSObject.Count $MyPSObject += [pscustomobject]$myHashtable3 $MyPSObject.Count

$justJoe = $MyPSObject | Where-Object { $_.Name -eq "Joe" } $justJoe.Count # this will not return a value when it should $justJoe | measure-object