Example Code:
$test=@()
$new = New-Object PSObject
$new | Add-Member -type NoteProperty -name name -Value 'test'
$new | Add-Member -type NoteProperty -name nummer -Value "17580-10"
$new | Add-Member -type NoteProperty -name datum -Value "10.08.23"
$test += $new
$test
$test_filtered=@()
$test_filtered=$test | Where-Object {($_.nummer -match '175')}
Output:
PS C:\Users\cm> $test.GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Object[] System.Array
PS C:\Users\cm> $test_filtered.GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True False PSCustomObject System.Object
As you can see, the type get's changed. I need to keep the Object as it is (before). How to workaround that?
Thanks for any idea.