I have a debug log which spits out certain numbers that follow a preset error message.
For instance

> 
> 08:29:25.178 [DEBUG] Error lookup ID 2834
> 
> 
> 08:29:25.179 [DEBUG] Error lookup ID 2834
> 
> 
> 

The main reason I want to do this is to be able to then just output the unique instances of this ID (in above example would be just one 2834). It is not possible otherwise as the timestamp in the line makes it unique. So therefore I need to only output the id at the end (in this case 2834).

I currently have following script which works but I am wondering if there is not a more efficient/elegant way to do all this.

```
    $tempfile='tempfile.txt'
    $tempfile2='tempfile2.txt'
    $tempfile3='tempfile3.txt'
    $finalfile='missingIDs.txt'

    get-content 20180131.log -ReadCount 1000 |
    foreach { $_ -match " Error lookup ID" } > $tempfile

    get-content $tempfile | % { $_.Split(' ')[-1] } >$tempfile2
    gc $tempfile2 | sort | get-unique > $tempfile3

    gc $tempfile3| get-unique > $finalfile

```