Jump to content


Search the Community

Showing results for tags 'Maintenance Mode Reminder'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Cloud
    • Azure
    • Microsoft Intune
    • Office 365
  • General Stuff
    • General Chat
    • Events
    • Site News
    • Windows News
    • Suggestion box
    • Jobs
  • MDT, SMS, SCCM, Current Branch &Technical Preview
    • How do I ?
    • Microsoft Deployment Toolkit (MDT)
    • Official Forum Supporters
    • SMS 2003
    • Configuration Manager 2007
    • Configuration Manager 2012
    • System Center Configuration Manager (Current Branch)
    • Packaging
    • scripting
    • Endpoint Protection
  • Windows Client
    • how do I ?
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows Vista
    • Windows XP
    • windows screenshots
  • Windows Server
    • Active Directory
    • Microsoft SQL Server
    • System Center Operations Manager
    • KMS
    • Windows Deployment Services
    • NAP
    • Failover Clustering
    • PKI
    • Windows Server 2008
    • Windows Server 2012
    • Windows Server 2016
    • Windows Server 2019
    • Hyper V
    • Exchange
    • IIS/apache/web server
    • System Center Data Protection Manager
    • System Center Service Manager
    • System Center App Controller
    • System Center Virtual Machine Manager
    • System Center Orchestrator
    • Lync
    • Application Virtualization
    • Sharepoint
    • WSUS

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

Found 1 result

  1. HI Guys I have bee studing the code from this guys here, I want to implement a similar reminder email, Can anyone help to make sence of it? I dont know where to start. h**p://syscenterstuff.blogspot.com/2010/02/maintenance-mode-reminder-emails.html 1) A SQL Linked Server connection to Active Directory - this allows us to lookup the email address of the AD user who put the machine into maintenance mode. In our company we make use of a centralised server details page (with MM integration). If this page is used to put the machine into maintenance mode, another "service" account is used, but the username is stored in the comments section as follows: DOMAIN\USER: Comments 2) SQL Mail will need to be setup. 3) There is another portion to this - a Web Service which receives the request to extend the maintenance mode. You may choose to omit this portion but it's nice functionality to have. This is in C#. SQL Code: DECLARE @now datetime; DECLARE @LocalGMTOffset int; DECLARE @MMWindowAlertThresholdPerc int; DECLARE @startPos int; DECLARE @endPos int; DECLARE @userName varchar(200); DECLARE @sql nvarchar(4000); DECLARE @AD varchar(200); DECLARE @WebServer varchar(200); DECLARE @actionAccount varchar(200); SET @LocalGMTOffset = +2 SET @MMWindowAlertThresholdPerc = 75; SET @NOW = dateadd(hour,(@LocalGMTOffset * -1),getdate()); SET @AD = 'http://' + @WebServer + '/mm/Default.aspx?bmid='+ @BmeId + '&extend=1&DisplayName='+@DisplayName+'" class="button">1 hour</a> <a href="http://' + @WebServer + '/mm/Default.aspx?bmid='+ @BmeId + '&extend=2&DisplayName='+@DisplayName+'" class="button">2 hours</a> <a href="http://' + @WebServer + '/mm/Default.aspx?bmid='+ @BmeId + '&extend=4&DisplayName='+@DisplayName+'" class="button">4 hours</a> <a href="http://' + @WebServer + '/mm/Default.aspx?bmid='+ @BmeId + '&extend=8&DisplayName='+@DisplayName+'" class="button">8 hours</a> Other options: <a href="http://' + @WebServer + '/mm/Default.aspx?bmid='+ @BmeId + '&extend=0&DisplayName='+@DisplayName+'" class="button">Take out of maintenance mode</a> </BODY> </HTML>' EXEC msdb.dbo.sp_send_dbmail @recipients=@mail, @subject = @subjectVal, @body = @bodyVal, @body_format = 'HTML'; SET @startPos = @startPos + 1 END --MUST REMOVE THIS WHEN LIVE - this is left here for testing purposes so it'll always send --delete from [monitor].[dbo].[tb_MMWindows] --------------------------- C# Web Service Code: using System; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using Microsoft.EnterpriseManagement; using Microsoft.EnterpriseManagement.Configuration; using Microsoft.EnterpriseManagement.Monitoring; using System.Collections.ObjectModel; using System.Collections.Generic; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { int gmtOffset = 2; string bmid = Request.QueryString["bmid"]; int extendHours = System.Convert.ToInt32(Request.QueryString["extend"]); string pcDisplayName = Request.QueryString["displayname"]; if (bmid != null && pcDisplayName != null) { ManagementGroup mg = new ManagementGroup("RMS1"); string mcCriteria = "Name = 'Microsoft.Windows.Computer'"; string query = "Id = '" + bmid + "'"; MonitoringClassCriteria criteria = new MonitoringClassCriteria(mcCriteria); MonitoringClass monClass = mg.GetMonitoringClasses(criteria)[0]; MonitoringObjectCriteria objCriteria = new MonitoringObjectCriteria(query, monClass); List<monitoringobject> monObjects = new List<monitoringobject>(mg.GetMonitoringObjects(objCriteria)); if (monObjects.Count == 0) { litOutput.Text = "Could not find an object with that display name. System Center has been notified."; } foreach (MonitoringObject monObject in monObjects) { if (extendHours == 0) { DateTime scheduledEndTime = DateTime.UtcNow; try { monObject.StopMaintenanceMode(scheduledEndTime, Microsoft.EnterpriseManagement.Common.TraversalDepth.Recursive); litOutput.Text = pcDisplayName + " has successfully been taken out of maintenance mode."; } catch(Exception Ex) { litOutput.Text = "Encountered an error stopping maintenance mode. System Center has been notified. " + Ex.Message; } } else { if (!monObject.InMaintenanceMode) { try { DateTime startTime = DateTime.UtcNow; DateTime scheduledEndTime = DateTime.UtcNow.AddHours(extendHours); string comments = extendHours + " hour maintenance mode window requested"; monObject.ScheduleMaintenanceMode(startTime, scheduledEndTime, 0, comments, Microsoft.EnterpriseManagement.Common.TraversalDepth.Recursive); litOutput.Text = pcDisplayName + " has already been taken out of maintenance mode. Starting a new maintenance mode window for " + extendHours + " hours." + " Scheduled end time is: " + scheduledEndTime.AddHours(gmtOffset).ToString(); } catch(Exception Ex) { litOutput.Text = "Encountered an error placing machine into maintenance mode. System Center has been notified. " + Ex.Message; } } else { try { MaintenanceWindow myWindow = monObject.GetMaintenanceWindow(); DateTime scheduledEndTime = myWindow.ScheduledEndTime.ToUniversalTime().AddHours((extendHours + gmtOffset)); string updatedComments = myWindow.Comments + " || " + extendHours + " hour extension requested"; monObject.UpdateMaintenanceMode(scheduledEndTime, 0, updatedComments, Microsoft.EnterpriseManagement.Common.TraversalDepth.Recursive); litOutput.Text = pcDisplayName + " has had its maintenance mode extended by the requested " + extendHours + " hours" + " New scheduled end time is: " + scheduledEndTime.AddHours(gmtOffset).ToString(); } catch(Exception Ex) { litOutput.Text = "Encountered an error extending maintenance mode. System Center has been notified. " + Ex.Message; } } } } } } } </monitoringobject></monitoringobject> And that's it... this works nicely once it's setup. It may take you a while to get all the components right - if you need help give me a shout.
×
×
  • Create New...