Maintenance Windows in ConfigMgr can help you a great deal to determine when installations will occur on your clients. Since the Maintenance Windows are configured per a collection basis, it’s recommended to have dedicated Maintenance Windows collection where you use the Include rule for collection membership. But this may not always be the case, and in some environments Maintenance Windows can be configured on a variety of collection, and in the end it might be quite hard to find out the enabled Maintenance Windows the device has. It would be nice if you’d have such a tab in the Device properties window, but unfortunately we don’t have such a luxury (yet).

This is where our friends PowerShell and the SMS Provider comes to the rescue. Since we can determine what collections the device is a member of by querying the SMS_FullCollectionMembership WMI class, it’s from there on quite easy to see which collections the device is a member of. And when we know that, we can query each collection for the Maintenance Window it has configured.

So I decided to create a right-click console extension that can show all the Maintenance Windows that affects a specific device. But since this functionality is already present in Peter van der Woude’s great tool, Peter gave me the idea to also show the upcoming Maintenance Windows. I figured this was a great addition to what I had decided to go with from the start, and set out for trying to figure out how to accomplish the upcoming Maintenance Windows part. It proved to be a difficult task from the start, but now when I look back at the code, it wasn’t really that hard after all.

Download the script

I’ve made the code available on the TechNet Gallery, and the direct link can be found here.

How to use the script from the ConfigMgr console

Previously when I made my Dell Warranty Extension Tool, I created a small executable that would install the tool automatically. This time around, I’ve decided not to do that but instead guide you through the steps. It’s actually really easy and doesn’t take very long.

1. Download the script from the TechNet Gallery and save it as Get-MaintenanceWindows.ps1.
2. Put the script in any desired location, for the purpose of this demonstration, I’ll put it in C:\Scripts.
3. Browse to the location below and create a folder called ed9dee86-eadd-4ac8-82a1-7234a4646e62.

<ConfigMgr console installation location>\XmlStorage\Extensions\Actions

Tip: You can always get the location of where the ConfigMgr console is installed by running the following PowerShell command:

(($env:SMS_ADMIN_UI_PATH).Substring(0,$env:SMS_ADMIN_UI_PATH.Length-9))

4. Copy the XML data from below and create a XML file called MW.xml and save it in the ed9dee86-eadd-4ac8-82a1-7234a4646e62 folder. You may have to create the MW.xml file somewhere on the system where UAC won’t interfere and then copy it to the folder mentioned above. What I mean is that you may have to create MW.xml in your Documents folder and then copy it from there to the ed9dee86-eadd-4ac8-82a1-7234a4646e62 folder.

<ActionDescription Class="Executable" DisplayName="Show Maintenance Windows" MnemonicDisplayName="Show Maintenance Windows" Description="Show Maintenance Windows" SqmDataPoint="53">
	<ShowOn>
		<string>ContextMenu</string>
	</ShowOn>
    <ResourceAssembly>
		<Assembly>AdminUI.CollectionProperty.dll</Assembly>
			<Type>Microsoft.ConfigurationManagement.AdminConsole.CollectionProperty.Properties.Resources.resources</Type>
	</ResourceAssembly>
		<ImagesDescription>
			<ResourceAssembly>
				<Assembly>AdminUI.UIResources.dll</Assembly>
				<Type>Microsoft.ConfigurationManagement.AdminConsole.UIResources.Properties.Resources.resources</Type>
			</ResourceAssembly>
		<ImageResourceName>Information</ImageResourceName>
	</ImagesDescription>
	<Executable>
		<FilePath>"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"</FilePath>
		<Parameters>-noninteractive -windowstyle hidden -executionpolicy bypass -file "C:\Scripts\Get-MaintenanceWindows.ps1" -SiteServer "##SUB:__SERVER##" -SiteCode "##SUB:SiteCode##" -ResourceID "##SUB:ResourceID##"</Parameters>
	</Executable>
</ActionDescription>

If you take a look at the XML data, you’ll notice the Parameters section just below FilePath, is looking for the file I saved the PowerShell script as. For this to work in your environment, change the location to where you’ve saved the script downloaded from the TechNet Gallery.

5. Relaunch any already open ConfigMgr console.
6. When you go to the Devices node in Assets and Compliance, right-click on any device you’ll now get a new option called Show Maintenance Windows.

90_2

7.  When you click on this option, a new window will open showing you what Maintenance Windows the device is affected by and show the date for the next upcoming one for each recurrence type.

90_1

Nickolaj Andersen
Principal Consultant and Enterprise Mobility MVP since 2016. Nickolaj has been in the IT industry for the past 10 years specializing in Enterprise Mobility and Security, Windows devices and deployments including automation. Currently working for TrueSec as a Principal Consultant. Awarded as PowerShell Hero in 2015 by the community for his script and tools contributions. Creator of ConfigMgr Prerequisites Tool, ConfigMgr OSD FrontEnd, ConfigMgr WebService to name a few. Frequent speaker at conferences and user groups.

(3794)

comments
  • Eric
    Posted at 17:06 October 31, 2014
    Eric
    Reply
    Author

    Great script Nickolaj!! You just saved me a ton of time for something we needed to do here. Now if only I can figure out how to make this work on a whole collection, I can modify it and save even more time. Thanks again!

    • Nickolaj
      Posted at 09:10 November 5, 2014
      Nickolaj
      Reply
      Author

      Hi Eric,

      I’m happy to help 🙂

      If you manage to modify the script to work for a collection instead, please share it here so that others are able to make use of it (if you’re OK with that of course).

      Regards,
      Nickolaj

  • Turker
    Posted at 13:10 December 10, 2014
    Turker
    Reply
    Author

    Hello. Thank you for this precious extension. Is it possible to use it on any collection? Because the context menu does not appear in collections except “Devices”. It’d be much more useful this way 😉

    • Nickolaj
      Posted at 13:29 December 10, 2014
      Nickolaj
      Reply
      Author

      Hi Turker,

      Unfortunately, the extension is only per a device basis. At this moment I’ve no plans on re-writing this extensions. Maybe in the future 🙂

      Regards,
      Nickolaj

  • Turker
    Posted at 14:21 December 10, 2014
    Turker
    Reply
    Author

    Wow for the fast reply! 🙂 No, you got me wrong. I’m ok with the per device basis. But when I try to get a maintenance window of a specific system in a custom collection, your extension does not appear in right click menu. It only appears in “Devices” node, not in collections. Thank you any way 🙂

    • Nickolaj
      Posted at 14:28 December 10, 2014
      Nickolaj
      Reply
      Author

      I’m not sure what you mean, have you put it in the correct GUID folder? Please attach a screenshot of where you want it to be 🙂

      Regards,
      Nickolaj

  • Turker
    Posted at 09:17 December 11, 2014
    Turker
    Reply
    Author

    Hello again. Here is the image. Image on the left is taken when I right click a computer in “Devices” node. The other is taken when I’m in a collection and right click a computer. Hope this describes my situation I’m in 🙂

    http://www.tiikoni.com/tis/view/?id=46903b1

    • Nickolaj
      Posted at 09:40 December 11, 2014
      Nickolaj
      Reply
      Author

      I see, you’d then need to create a folder called 3fd01cd1-9e01-461e-92cd-94866b8d1f39 and put the XML file in that and restart the Console for it to work 🙂

      Regards,
      Nickolaj

  • Turker
    Posted at 09:55 December 11, 2014
    Turker
    Reply
    Author

    Let the drums roll! And that magic did the trick! Thank you Nickolaj for your your time and effort 🙂

    • Nickolaj
      Posted at 09:57 December 11, 2014
      Nickolaj
      Reply
      Author

      No problem, great to see that you got it to work as you wanted to 🙂

      Regards,
      Nickolaj

  • Najam
    Posted at 06:33 March 1, 2015
    Najam
    Reply
    Author

    Mate,

    You are a super star. I was looking for this kind of option for ages.

    Thanks heaps.

  • Tata
    Posted at 13:58 March 26, 2015
    Tata
    Reply
    Author

    Great tool,

    One question though, If I have a Maintenance Window that is recurring Monthly, ex. the 3rd Saturday every month, the “Upcoming Maintenance Windows” returns nothing. Is this a known feature?

    Thanks,
    Tata

    • Nickolaj
      Posted at 14:36 March 28, 2015
      Nickolaj
      Reply
      Author

      Hi Tata,

      That’s not a know feature, and I’d assume it should at least try to calculate the next upcoming one. I’ll have to review the code and see if I can re-create the issue.

      Regards,
      Nickolaj

      • Bert Pinoy
        Posted at 12:25 January 24, 2017
        Bert Pinoy
        Reply
        Author

        Hi,

        I’ve experienced the same problem and I’ve edited the script to solve this. This happens when the maintenance window for the present month has already passed (date in the past, in the same month). I’ve edited the script to add additional months if needed, my maintenance window occurs every 3 months the third Tuesday. If you are interested, let me know and I’ll provide you with the script.

        • poschpa
          Posted at 11:12 March 22, 2017
          poschpa
          Reply
          Author

          Hi Bert, it would be a pleasure if you can share your script with me, we´ve got the same Scenario. BR

    • Ryan
      Posted at 20:07 March 30, 2015
      Ryan
      Reply
      Author

      I also have this issue, a recurring maintenance window with the “monthly” recurrence, say every last Saturday doesn’t work with the script.

  • Leif
    Posted at 17:26 May 21, 2015
    Leif
    Reply
    Author

    Thank you, this is great!!!

  • Zilva
    Posted at 12:00 June 1, 2015
    Zilva
    Reply
    Author

    Idea is really great, but script shows wrong information.
    E.g. I have collection which has maintenance window once per 6 months, but script shows that this window is for every month..
    I think it should work much deeper with information from DB about service windows..

    • Nickolaj
      Posted at 12:36 June 1, 2015
      Nickolaj
      Reply
      Author

      Hi Zilva,

      Yeah I’m aware of that this is not working for all scenarios. I’ll see if there’s time to take a look at the script again and rewrite it.

      Regards,
      Nickolaj

  • DJ
    Posted at 20:46 June 24, 2015
    DJ
    Reply
    Author

    Is there a way to have the script display the status of devices within a collection? I.E – right-click a collection and have it output MW for each device in the collection.

  • Kevin
    Posted at 19:02 June 29, 2015
    Kevin
    Reply
    Author

    Awesome right-click tool. Thanks for sharing!!!!!

  • erich
    Posted at 20:32 October 5, 2015
    erich
    Reply
    Author

    How would I make this appear when right-clicking a device displayed in a “sub-collection” of Devices? I can only see it when right-clicking a device from the huge list that appears when viewing all devices.

    Thanks for what it does do though.

  • Paul
    Posted at 22:00 October 26, 2015
    Paul
    Reply
    Author

    You do not know how much this tool is helping me! I couldn’t find where the maintenance windows I had applied were. I was trying to troubleshoot Patch Management but the maintenance window was blocking this.

    • Nickolaj
      Posted at 22:49 October 26, 2015
      Nickolaj
      Reply
      Author

      Hi Paul,

      I’m glad that the tool helped you out!

      Regards,
      Nickolaj

  • Nalin
    Posted at 15:58 May 18, 2016
    Nalin
    Reply
    Author

    Hi ,

    thanks for the script. I get the action in the context manu, however I only get a blank form – no data.

    I am using sccm 2012 1511. Not sure if this is the problem. Just so that you know

    I have Peter’s script working without any problems. thanks for the link to that one.

    I would be grateful if you could point me in the right direction here please.

  • Jason
    Posted at 17:25 December 7, 2016
    Jason
    Reply
    Author

    Hello,

    I copied the instruction exactly but when I right click Show Maintenance Windows the form comes up blank with no information.

  • Leave a Reply