I'm trying to monitor entries in a database (entries about status of an SCCM deployment).
For this I got a working script https://smsagent.wordpress.com/2015/07/ ... owershell/ = get-cmstatusmessages
I now would like to monitor the file and get only new items on top.
This is what I have so far but it is not working fully. I get results but first 10 rows then again first then rows below, not only the NEW ones and not on top of the result but at the bottom.
Please advise if this is the correct way to go. If yes, howto continue if no, how would you suggest to approach?
Thanks.
S.
#Elements of $Status => Severity Type SiteCode Date / Time System Component Module MessageID Description
- while($true)
- {
- $i++
- $status = Get-CMStatusMessages -ComputerName $computername | select -first 10
- $status | select 'Date / Time',description
- Get-CMStatusMessages -ComputerName $computername | select -first 10 | select 'Date / Time',description # | where-object Description -NotContains $($status.description) does not work
- #Items are put at the bottom whereas I'd like to have them on top
- }