LeVeilleur.net

Subscribe

SCOM2007 : Installation de Sql Server 2005

novembre 24, 2008 By: Christopher Keyaert Category: Scom 2007, Windows No Comments →

Voici la première partie du guide d’installation de Microsoft System Center Operations Manager 2007. La première partie consiste à installer Microsoft Sql Server 2005 sur un serveur dédié.

La plupart des screenshoots ci-dessous se passe de commentaires :


  (Lire la suite…)

Scom2007 : Scripts pour Maintenance Mode

novembre 23, 2008 By: Christopher Keyaert Category: Scom 2007 No Comments →

Hello tout le monde,

En tant qu’utilisateur de Microsoft System Center Operations Manager 2007, vous avez déjà certainement été confronté au problème ci-dessous

 A computer agent unexpectedly generates heartbeat alerts after you put it into Maintenance mode in System Center Operations Manager 2007

La description détaillée de cela se trouve sur le site de Microsoft : http://support.microsoft.com/kb/942866

En fait, pour mettre un serveur en Maintenance Mode, il faut mettre en réalité trois objets en Maintenance :

  • Computers
  • Health Service
  • Health Service Watcher

Plutot que de faire cela à la main à chaque fois que vous souhaitez mettre un odirnateur completement en Maintenance Mode, voici deux scripts que j’ai écris.


# ==============================================================================================
#
# Microsoft PowerShell Source File
#
# NAME: StartMaintenanceMode.ps1
#
# AUTHOR: Christopher Keyaert
# EMAIL: christopher.keyaert@ucb-group.com
#
# DATE  : 11/19/2008
# VERSION : 1.0
#
# COMMENT: This script will start the maintenance mode for the specified computer
#
# PARAMETERS: rootMS, computerPrincipalName, minutes, comment, reason
#
#
#
# ==============================================================================================

param($rootMS,$computerPrincipalName,$minutes,$comment,$reason)

Add-PSSnapin "Microsoft.EnterpriseManagement.OperationsManager.Client" -ErrorVariable errSnapin;
Set-Location "OperationsManagerMonitoring::" -ErrorVariable errSnapin;
new-managementGroupConnection -ConnectionString:$rootMS -ErrorVariable errSnapin;
set-location $rootMS -ErrorVariable errSnapin;

$computerClass = get-monitoringclass -name:Microsoft.Windows.Computer
$healthServiceClass = get-monitoringclass -name:Microsoft.SystemCenter.HealthService
$healthServiceWatcherClass = get-monitoringclass -name:Microsoft.SystemCenter.HealthServiceWatcher
$computerCriteria = "PrincipalName='" + $computerPrincipalName + "'"
$computer = get-monitoringobject -monitoringclass:$computerClass -criteria:$computerCriteria
$healthServices = $computer.GetRelatedMonitoringObjects($healthServiceClass)
$healthService = $healthServices[0]
$healthServiceCriteria = "HealthServiceName='" + $computerPrincipalName + "'"
$healthServiceWatcher = get-monitoringobject -monitoringclass:$healthServiceWatcherClass -criteria:$healthServiceCriteria
$startTime = [System.DateTime]::Now
$endTime = $startTime.AddMinutes($minutes)

"Putting " + $computerPrincipalName + " into maintenance mode"
New-MaintenanceWindow -startTime:$startTime -endTime:$endTime -monitoringObject:$computer -comment:$comment -Reason:$reason

"Putting the associated health service into maintenance mode"
New-MaintenanceWindow -startTime:$startTime -endTime:$endTime -monitoringObject:$healthService -comment:$comment -Reason:$reason

"Putting the associated health service watcher into maintenance mode"
New-MaintenanceWindow -startTime:$startTime -endTime:$endTime -monitoringObject:$healthServiceWatcher -comment:$comment -Reason:$reason

Le second, pour arrêter le Maintenance Mode


# ==============================================================================================
#
# Microsoft PowerShell Source File
#
# NAME: StopMaintenanceMode.ps1
#
# AUTHOR: Christopher Keyaert
# EMAIL: christopher.keyaert@ucb-group.com
#
# DATE  : 11/19/2008
# VERSION : 1.0
#
# COMMENT: This script will stop the maintenance mode for the specified computer
#
# PARAMETERS: rootMS, computerPrincipalName
#
#
#
# ==============================================================================================

param($rootMS,$computerPrincipalName)

Add-PSSnapin "Microsoft.EnterpriseManagement.OperationsManager.Client" -ErrorVariable errSnapin;
Set-Location "OperationsManagerMonitoring::" -ErrorVariable errSnapin;
new-managementGroupConnection -ConnectionString:$rootMS -ErrorVariable errSnapin;
set-location $rootMS -ErrorVariable errSnapin;

$computerClass = get-monitoringclass -name:Microsoft.Windows.Computer
$healthServiceClass = get-monitoringclass -name:Microsoft.SystemCenter.HealthService
$healthServiceWatcherClass = get-monitoringclass -name:Microsoft.SystemCenter.HealthServiceWatcher
$computerCriteria = "PrincipalName='" + $computerPrincipalName + "'"
$computer = get-monitoringobject -monitoringclass:$computerClass -criteria:$computerCriteria
$healthServices = $computer.GetRelatedMonitoringObjects($healthServiceClass)
$healthService = $healthServices[0]
$healthServiceCriteria = "HealthServiceName='" + $computerPrincipalName + "'"
$healthServiceWatcher = get-monitoringobject -monitoringclass:$healthServiceWatcherClass -criteria:$healthServiceCriteria

$endTime = [System.DateTime]::Now

"Stopping " + $computerPrincipalName + " maintenance mode"
Set-MaintenanceWindow -endTime:$endTime -monitoringObject:$computer

"Stopping the associated health service maintenance mode"
Set-MaintenanceWindow -endTime:$endTime -monitoringObject:$healthService

"Stopping the associated health service watcher maintenance mode"
Set-MaintenanceWindow -endTime:$endTime -monitoringObject:$healthServiceWatcher

Et voici comment appeller ces deux scripts

Start maintenance mode
 C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe C:\MaintenanceMode\StartMaintenanceMode.ps1 –rootMS: ‘localhost’ -computerPrincipalName: 'SERVERNAME' -minutes:30 -comment: 'Maintenance Mode' -reason: 'PlannedOther'
Stop maintenance mode
 C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe C:\MaintenanceMode\StopMaintenanceMode.ps1 –rootMS: ‘localhost’ -computerPrincipalName: 'SERVERNAME'

Voilà, si vous avez des questions, ne pas hésiter à les poser dans les commentaires.