azureautomation/runbooks

Bug in Azure Automation Powershell Version

Opened this issue · 0 comments

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