I'm pulling some data from my EventViewer which returns the output as system.array:
$GetEvents = [regex]::Split((Get-EventLog -source $source -LogName $logname -EntryType Warning -InstanceId $id -Newest 1).Message, '\n')
the output can look like this:
10: 40
55: 3.4
I'm trying to use the Add function but i keep getting the following error:
Exception calling "Add" with "1" argument(s): "collection was of a fixed size."
this is how i'm trying to use the "Add" function:
foreach($item in $array)
{
$GetEvents.Add($item)
}
the $array is also based type as system.array
i know i can do the following:
$GetEvents = $array
but thats not what im trying to achieve, im comparing between the items i have in the array to the ones i have inside my $GetEvents.
for example:
$array = '22: 15','35: 4','10: 40'
$GetEvents = '10: 40','55: 3.4'
Every "item" that doesnt exist in the $GetEvents from $array needs to be added to $GetEvents.
also the $GetEvent += $item
wont do the trick.
also $GetEvents = New-Object System.Collections.ArrayList
will remove the data from this array.
I hope i was clear in my explanation and it's understandable.
Thanks in advance!