I create an array like this:
$Array = @()
$Item = New-Object PSObject
$Item | Add-Member -Type NoteProperty -Name item1 -Value test
$Item | Add-Member -Type NoteProperty -Name item2 -Value test
$Array += $Item
Now I want to add a check to determine if $Item
is empty before adding it in $Array
. How can I get the member count of $Item
?
I tried stuff like :
$Item.count
$Item.length
@($Item).count
($Item | Measure).count
($Item | Get-Member).count
$Item.psobject.members.count
But none of them gives me the actual member count.