hi,
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 : http://dl.dropbox.com/u/17858935/Get_SCOM_Overrides_by_Day_Created.zip
Make sure you run this script in “Operations manager Shell”
1: ### I set $olddate to 2 Days ago date
2:
3: $olddate = (Get-Date).AddDays(-2)
4:
5: ## Select every Management pack and Piped it to "Get-Override)
6:
7: $Mp = Get-Managementpack | Get-Override
8:
9: ### Now it will show only overrides which are created after $oldDate
10:
11: $Mp| Where-Object { $_.TimeAdded -gt $olddate} | select ManagementGroupId,Name,TimeAdded | fl *
12:
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: http://dl.dropbox.com/u/17858935/Get_SCOM_Overrides_by_Day_Created.zip
Hope someone like it :)
Thanks
Aman Dhally
I like it, thank you. You should make it into a MP with a view and an alert?
ReplyDelete