@Bonus12 That's what the editing in MS Q&A does when it spots a "$" followed by a "" -- it removes the "" when code is posed as text. Using the "Code Sample" avoids that. BTW the same problem existed on the "Add-Member" line.
Here's what the code should look like:
$ArrayList = New-Object System.Collections.ArrayList
Get-WinEvent -logname security -FilterXPath "*[System[EventID=4907]]" -MaxEvents 10 |
ForEach-Object{
$XML = [xml]$_.toXml()
$PsObject = New-Object psobject
$XML.Event.EventData.Data |
ForEach-Object{
$PsObject |
Add-Member -MemberType NoteProperty -Name $_.Name -Value $_."#text"
}
$ArrayList.add($PsObject) | out-null
}
$ArrayList | Select-Object *