Show Maintenance Windows information for a device in ConfigMgr 2012
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:
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.
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.
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.