Powershell custom object in array with hashtable

$result = @()

$navn1 = "Henrik"
$alder1 = "34"
$navn2 = "Peter"
$alder2 = "44"

# New object with hash table
$properties = @{'Navn'=$navn1;'Alder'=$alder1}
$object = New-Object –TypeName PSObject –Prop $properties
$result += $object

# Short version
$result += New-Object –TypeName PSObject –Prop (@{'Navn'=$navn2;'Alder'=$alder2})

$result

Powershell custom object in array

$resultat = @()

$navn1 = "Henrik"
$alder1 = "34"
$navn2 = "Peter"
$alder2 = "44"

$object = New-object System.Object
$object | Add-Member -type NoteProperty -name Navn -value $navn1
$object | Add-Member -type NoteProperty -name Alder -value $alder1
$resultat += $object

$object = New-object System.Object
$object | Add-Member -type NoteProperty -name Navn -value $navn2
$object | Add-Member -type NoteProperty -name Alder -value $alder2
$resultat += $object

$resultat