Tuesday, February 11, 2014

Pool Manager Issues

When an OpsMgr 2012 architecture is « big » and when we have Pool manager issues, the following keys should be created on all MS HKLM\System\CurrentControlSet\Services\HealthService\Parameters\PoolManager PoolLeaseRequestPeriodSeconds DWORD 600 PoolNetworkLatencySeconds DWORD 120

Taken from below link.

http://support.microsoft.com/kb/2714482

Wednesday, September 18, 2013

Manually run partitioning and grooming on SCOM database

The following query if run on the SCOM db will run the grooming on all the partition tables. There are 122 partition tables in SCOM 2012. This will run for each one of them as their Iscurrent value is set to 1.

/*-------------------------------*/

declare @counter int  set @counter = 0  while @counter < 122

begin

exec p_PartitioningAndGrooming

set @counter = @counter + 1

print 'The counter is ' + cast(@counter as char)

end

/*-----------------------------*/

Friday, August 23, 2013

Change authentication account in NTLM Webapplication

#Usage:.Change-NTLMAccount -rms "rms.contoso.com" -currentaccount 'curracct' -newAccount 'newacct'

param([string] $rms,$currentAccount,$newAccount)

function DisplayUpdate ($str, $color = "white") {
$now = [DateTime]::Now

Write-Host "[$now]" -ForegroundColor white -NoNewline
Write-Host " $str`r" -ForegroundColor $color
}

$scriptPath = split-path -parent $MyInvocation.MyCommand.Path
$managementGroupRmsName = $rms
$newActionAccountName = $newAccount
#Load Dll's
Displayupdate "Loading SDK dll's"
$void1 = [System.Reflection.Assembly]::LoadFrom("$scriptPathMicrosoft.EnterpriseManagement.Core.dll")
if(!$void1) {Displayupdate "DLL's not found..exiting..." "red";break;}
$void2 = [System.Reflection.Assembly]::LoadFrom("$scriptPathMicrosoft.EnterpriseManagement.OperationsManager.dll")
if(!$void2) {Displayupdate "DLL's not found..exiting..." "red";break;}
$void3 = [System.Reflection.Assembly]::LoadFrom("$scriptPathMicrosoft.EnterpriseManagement.Runtime.dll")
if(!$void3) {Displayupdate "DLL's not found..exiting..." "red";break;}
$mg = New-Object Microsoft.EnterpriseManagement.ManagementGroup($managementGroupRmsName)
Displayupdate "connected to MG:$Mg.name"
Displayupdate "Getting mps.."
$mps = $mg.getmanagementpacks() | where{$_.name -match "NTLM"}
if($mps.count -gt 0 ) {
$count = $mps.count
Displayupdate "[$count] number of mp's found" "yellow"
$healthServices = dir -R | where {$_.UniquePathName -like "Microsoft.SystemCenter.HealthService*"}
$Srs = $mg.getmonitoringSecurereferences() | where{$_.name -match "WebApplication"}
$healthServices = dir -R | where {$_.UniquePathName -like "Microsoft.SystemCenter.HealthService*"}
$newActionAccount = $mg.GetMonitoringSecureData() | where {$_.UserName -eq $newActionAccountName -and $_.Type -eq "Windows" -and $_.name -notmatch "Data Warehouse Report Deployment Account"}

foreach($sr in $Srs)
{
$secureDataHSRefs = $mg.GetMonitoringSecureDataHealthServiceReferenceBySecureReferenceId($sr.Id)
foreach($secureDataHSRef in $secureDataHSRefs){
$healthService = $mg.GetMonitoringObject($secureDataHSRef.HealthServiceId)
$currentActionAccount = $mg.GetMonitoringSecureData($secureDataHSRef.MonitoringSecureDataId)
DisplayUpdate "Changing Action Account on $($sr.GetManagementpack().Displayname)" "yellow"
$secureDataHSRef.MonitoringSecureDataId = $newActionAccount.Id
$secureDataHSRef.Update()
}
}
}

else
{
Displayupdate "No NTLM mp's found..exiting.." "red"
break;
}

DisplayUpdate "Script finished"

Tuesday, August 20, 2013

My frequently used SCOM Queries

I won't take the credit for most of these queries. I have compiled them overtime from different blogs, sites

/* Database size */

SELECT DB_NAME() AS DbName,
name AS FileName,
size/128.0 AS CurrentSizeMB,
size/128.0 - CAST(FILEPROPERTY(name, 'SpaceUsed') AS INT)/128.0 AS FreeSpaceMB
FROM sys.database_files;.

/*PERFORMANCE related queries*/

select top 20 pcv.ObjectName, pcv.CounterName, count (pcv.countername) as Total from performancedataallview as pdv, performancecounterview as pcv where (pdv.performancesourceinternalid = pcv.performancesourceinternalid) group by pcv.objectname, pcv.countername order by count (pcv.countername) desc

select top 2000 Path,ObjectName, count(ObjectName) from PerformanceDataAllView pdv with (NOLOCK) inner join PerformanceCounterView pcv with (NOLOCK) on pdv.performancesourceinternalid = pcv.performancesourceinternalid inner join BaseManagedEntity bme with (NOLOCK) on pcv.ManagedEntityId = bme.BaseManagedEntityId where  pcv.ObjectName like 'Processor' group by Path,ObjectName order by count(ObjectName) desc

 

/* Top Noisy Rules in the last 24 hours */

select ManagedEntityTypeSystemName, DiscoverySystemName, count(*) As 'Changes' from (select distinct MP.ManagementPackSystemName, MET.ManagedEntityTypeSystemName, PropertySystemName, D.DiscoverySystemName, D.DiscoveryDefaultName, MET1.ManagedEntityTypeSystemName As 'TargetTypeSystemName', MET1.ManagedEntityTypeDefaultName 'TargetTypeDefaultName', ME.Path, ME.Name, C.OldValue, C.NewValue, C.ChangeDateTime from dbo.vManagedEntityPropertyChange C inner join dbo.vManagedEntity ME on ME.ManagedEntityRowId=C.ManagedEntityRowId inner join dbo.vManagedEntityTypeProperty METP on METP.PropertyGuid=C.PropertyGuid inner join dbo.vManagedEntityType MET on MET.ManagedEntityTypeRowId=ME.ManagedEntityTypeRowId inner join dbo.vManagementPack MP on MP.ManagementPackRowId=MET.ManagementPackRowId inner join dbo.vManagementPackVersion MPV on MPV.ManagementPackRowId=MP.ManagementPackRowId left join dbo.vDiscoveryManagementPackVersion DMP on DMP.ManagementPackVersionRowId=MPV.ManagementPackVersionRowId AND CAST(DefinitionXml.query('data(/Discovery/DiscoveryTypes/DiscoveryClass/@TypeID)') AS nvarchar(max)) like

'%'+MET.ManagedEntityTypeSystemName+'%' left join dbo.vManagedEntityType MET1 on MET1.ManagedEntityTypeRowId=DMP.TargetManagedEntityTypeRowId left join dbo.vDiscovery D on D.DiscoveryRowId=DMP.DiscoveryRowId where ChangeDateTime > dateadd(hh,-24,getutcdate()) ) As #T group by ManagedEntityTypeSystemName, DiscoverySystemName order by count(*) DESC

and

/* Modified properties in the last 24 hours */

select distinct MP.ManagementPackSystemName, MET.ManagedEntityTypeSystemName, PropertySystemName, D.DiscoverySystemName, D.DiscoveryDefaultName, MET1.ManagedEntityTypeSystemName As 'TargetTypeSystemName', MET1.ManagedEntityTypeDefaultName 'TargetTypeDefaultName', ME.Path, ME.Name, C.OldValue, C.NewValue, C.ChangeDateTime from dbo.vManagedEntityPropertyChange C inner join dbo.vManagedEntity ME on ME.ManagedEntityRowId=C.ManagedEntityRowId inner join dbo.vManagedEntityTypeProperty METP on METP.PropertyGuid=C.PropertyGuid inner join dbo.vManagedEntityType MET on MET.ManagedEntityTypeRowId=ME.ManagedEntityTypeRowId inner join dbo.vManagementPack MP on MP.ManagementPackRowId=MET.ManagementPackRowId inner join dbo.vManagementPackVersion MPV on MPV.ManagementPackRowId=MP.ManagementPackRowId left join dbo.vDiscoveryManagementPackVersion DMP on DMP.ManagementPackVersionRowId=MPV.ManagementPackVersionRowId     AND CAST(DefinitionXml.query('data(/Discovery/DiscoveryTypes/DiscoveryClass/@TypeID)') AS nvarchar(max)) like

'%'+MET.ManagedEntityTypeSystemName+'%' left join dbo.vManagedEntityType MET1 on MET1.ManagedEntityTypeRowId=DMP.TargetManagedEntityTypeRowId left join dbo.vDiscovery D on D.DiscoveryRowId=DMP.DiscoveryRowId where ChangeDateTime > dateadd(hh,-24,getutcdate()) ORDER BY MP.ManagementPackSystemName, MET.ManagedEntityTypeSystemName

/*Discovery frequencies in the management packs*/

select       ds.DiscoveryName,       mp.MpName,       CAST(md.ModuleConfiguration as XML).value('/Frequency[1]','int') as 'Frequency' from Module (nolock) as md inner join Discovery (nolock) as ds       on md.ParentId = ds.DiscoveryId inner join ManagedType (nolock) as mt       on mt.ManagedTypeId = ds.DiscoveryTarget inner join ManagementPack (nolock) as mp       on mp.ManagementPackId = ds.ManagementPackId

Monday, August 19, 2013

Who is connected to my SCOM console

The following command will help to find who is connected to your SCOM console. This works for SCOM 2012.

(Get-SCOMManagementGroup).getconnectedusernames()

For SCOM 2007 you will have to use the ones below. I have not tested the below commands, though.

Get-ManagementGroupConnection | foreach-object {$_.ManagementGroup.getConnectedUserNames()}
Get-ManagementGroupConnection | foreach-object {$_.ManagementGroup.getConnectedUserNames()} | measure-object

 

Friday, July 19, 2013

Adding or removing a new SCOM zone from Om12 agent

Using Powershell:

Remove Management group

$OMCfg = New-Object -ComObject AgentConfigManager.MgmtSvcCfg;

$OMCfg.RemoveManagementGroup("zonetoberemoved")

 

Add management group

$OMCfg = New-Object -ComObject AgentConfigManager.MgmtSvcCfg;

$OmCfg.AddmanagementGroup(‘zonenametobeadded’,'MSNamewithFQCN',5723)

Thursday, January 17, 2013

Running a powershell script as a Scheduled Task

I found this link to run a powershell script using the Task Scheduler.

http://techhead.co/using-task-scheduler-to-run-a-powershell-script/

To create a simple task to copy a directory from one location to another.Open task scheduler and click Create Basic task.Give the name as Copy task. You can specify and select whether you want to run the task only when you login or keep it running whether a user logs in or not. Once that is done then click the Actions tab and click new. Let the Action be as Start a program. In the Settings text box enter this.

%windir%\System32\WindowsPowerShell\v1.0\powershell.exe

And in the Add arguments enter this after replacing the script path.

–Noninteractive –Noprofile –Command "&{Path to your Script}"

Open notepad and edit the Script file. Enter these lines and save it.

copy-item c:\yourfolderpath -destination c:\destinationpath -recurse

You can start the task and check if the copy is happening. Check the folder permissions and don't add any spaces in the directory names if your copy is not working.

Monday, October 8, 2012

IE9 32-bit crashing.

My internet explorer started crashing one day. And this error was logged in the applicaiton log.

Faulting application name: iexplore.exe, version: 9.0.8112.16450, time stamp: 0x503723f6

Faulting module name: unknown, version: 0.0.0.0, time stamp: 0x00000000

Exception code: 0xc00000fd

Fault offset: 0x739ae2d4

Faulting process id: 0x4ac

Faulting application start time: 0x01cda5cf238949d0

Faulting application path: C:\Program Files (x86)\Internet Explorer\iexplore.exe

Faulting module path: unknown

Report Id: 617f9fb0-11c2-11e2-b050-002713b3ec0b

After lot of surfing and reading through blogs. I stumbled on this solution myself. I was comparing the registry keys from my machine and another one which had IE-9 installed. I found that this key was different.

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\UnattendBackup\ActiveSetup\Home_Page]. On my machine it was set to an intranet site of our organization.I changed that to http://www.google.com. The internet explorer started working again. On the first launch it still went to the intranet default site. But was not crashing anymore.

Sunday, September 23, 2012

SCOM 2007 authoring console crash

When i was checking the rules on my console.I had set the scope to all objects and since then it kept on crashing on me. It would load the other views but never the authoring console.Followed this link http://blog.tyang.org/2010/07/06/scom-console-crashes/

And this gave me a fair idea of what could be happening.My scom zone had many management packs loaded. By many i mean many, more that 500.So I just checked this reg key on another zone and the classes that were scoped in that. This console had only the root management server scoped. I copied the reg key from this RMS and imported on the problematic one. Woo hoo!! My console was not crashing anymore and it opened at the RMS scope here too. Here is the reg key.

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Microsoft Operations Manager\3.0\Console\Navigation\MonitoringConfigNavSettings] "SelectedViewNodeId"="91aaa624-bebf-21db-858c-76d50a6a8d99" "ScopedClasses"="1a9387f0-6fe5-5527-a2cb-73f2f6be6bc7" "AuthoringSpaceViewedFirstTime"=dword:00000000 "UseDefaultScoping"=dword:00000000

Thursday, June 7, 2012

Export all jobs from a SQL server

To export all jobs from a SQL server.

Open ssms,connect to your sql server.Navigate to SQL Server Agent-- jobs.

Click View and select Object Explorer Details or press F7. The Object explorer details window should open on the right. Select all the jobs,right click  select Script job as-Create to -- File. Select a location and give any file name and save.

All the jobs would be exported as a single file and you can run that on any other database to restore all the jobs.