How to add hashtable to multidimensional array? Cannot assign values via member-access enumeration

tl;dr Setting a key / property value via member-access enumeration is not supported (see below). Instead, you must obtain the specific object whose .Bücher property you want to modify explicitly: ($Data.BIBs.BIB1 | ? Bücher).Bücher += @{ BuchName=”neues Buch”; Autor=”Johann Doe” } Note: This assumes that: only one element of array $Data.BIBs.BIB1 has a .Bücher property … Read more

Get-ChildItem.Length is Wrong

PetSerAl, as many times before, has provided the crucial pointer in a terse comment on the question (and he’s also assisted in refining this answer): $pathChildren = @(Get-ChildItem -Path $strPath) The use of @(…), the array subexpression operator, ensures that whatever the enclosed command outputs is treated as an array, even if only 1 object … Read more

Unable to completely parse XML in PowerShell

XML is a structured text format. It knows nothing about “folders”. What you see in your screenshots is just how the the data is rendered by program you use for displaying it. Anyway, the best approach to get what you want is using SelectNodes() with an XPath expression. As usual. [xml]$xml = Get-Content ‘X:\folder\my.xml’ $xml.SelectNodes(‘//Product/Item[@Class=”Patch”]’) … Read more

Powershell: null file always generated (output of Compare-Object)

PetSerAl, as he routinely does, has provided the crucial pointer in a comment on the question: Member-access enumeration – the ability to access a member (a property or a method) on a collection and have it implicitly applied to each of its elements, with the results getting collected in an array, was introduced in PSv3.[1] … Read more