Assigning an Object's Property to Variable
<p>In my script, $queryResult.events has a property called SourceFile (so $queryResult.events.SourceFile) and I'm trying to pass this property if $queryResult.events.event_name = "File Copy", etc.... I want these results stored in a variable called $UniqueUSBFileNames.  Currently, I'm trying to do this with the following line in my script:</p>

<pre><code>$UniqueUSBFileNames += $queryResult.events.event_name.GetEnumerator() | Where-Object {$_.name -eq "File Move" -or "File Copy" -or "Save As"}
</code></pre>

<p>I'm essentially trying to parse through each element of $queryResult.events, see if $queryResult.events.event_name is "File Move" -or "File Copy" -or "Save As", and if it is, I want $queryResult.events.SourceFile to be saved in the variable $UniqueUSBFileNames.</p>

<p>I've been at this forever and any help is appreciated.</p>

<p>Thanks in advance.</p>

<p><strong>Edit:</strong>
Adding more code as requested:</p>

<pre><code>$UniqueUSBFileNames = $null
$UniqueUSBFileNames += $queryResult.events.event_name.GetEnumerator() | Where-Object {$_.name -eq "File Move" -or "File Copy" -or "Save As"}
$UniqueUSBFileNames | Sort-Object -Unique | Out-File C:\Users\hubt\Documents\Scripts\tmp\$USBEvents
</code></pre>

<p>Just initializing $UniqueUSBFileNames, seeing if the current element through the pipeline equals "File Move" -or "File Copy" -or "Save As", and then sorts only by unique file names (so no duplicates) and prints the results to a file. In the end, I need each $queryResult.events.SourceFile in $UniqueUSBFileNames if $aqlQueryResult.events.event_name equals "File Move" -or "File Copy" -or "Save As".</p>

<p>Sorry if that doesn't make much sense, let me know if it needs clarification.</p>