Friday, November 18, 2011

Get-Overrides created on Specific Day .


yesterday one of our  SCOM admin created few overrides in SCOM and today he is on leave and the also not picking up the phone and I need to know which overrides he created.

Then i think that lets try to write a little basic PowerShell script which show the list of overrides created between specific number of days.

you can download the script from here :

Make sure you run this script in “Operations manager Shell”

   1: ### I set $olddate to 2 Days ago date
   3: $olddate = (Get-Date).AddDays(-2)
   5: ## Select every Management pack and Piped it to "Get-Override)
   7: $Mp = Get-Managementpack | Get-Override 
   9: ### Now it will show only overrides which are created after $oldDate
  11: $Mp| Where-Object { $_.TimeAdded -gt $olddate} | select ManagementGroupId,Name,TimeAdded | fl *
  13: ######## E N D of S C R I P T #############

in $olddate i minus 2 days so if today is 18 November then $olddate should have 16 November stored in variable


in variable $Mp in am storing all Management packs and piped them to Get-Overrides


lets run $Mp lets see what we will get.

It shows the list of all Overrides in all management packs. Now we need to sort them.


$Mp| Where-Object { $_.TimeAdded -gt $olddate} | select ManagementGroupId,Name,TimeAdded | fl *

in above command , we piping $MP to where-Object cmdlet and choosing TimeAdded property in Overrides and comparing them with our variable $OldDate , so if the TimeAdded is property is greater then 16 November then it show all the Overrides created between 17,18 November.

seems working … :)


Download Link:

Hope someone like it :)


Aman Dhally

1 comment:

  1. I like it, thank you. You should make it into a MP with a view and an alert?