<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>System Center Operations Manager &#8211; XtremeOwnage</title>
	<atom:link href="https://xtremeownage.com/category/technology/system-center/system-center-operations-manager/feed/" rel="self" type="application/rss+xml" />
	<link>https://xtremeownage.com</link>
	<description>Cars, Computers, and Code.</description>
	<lastBuildDate>Sun, 08 Jan 2023 02:09:05 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.4.3</generator>

<image>
	<url>https://xtremeownage.com/wp-content/uploads/2019/09/cropped-Turbo-512-2-100x100.png</url>
	<title>System Center Operations Manager &#8211; XtremeOwnage</title>
	<link>https://xtremeownage.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>SCOM &#8211; Locate Computers in Maintenance</title>
		<link>https://xtremeownage.com/2019/10/01/scom-locate-computers-in-maintenance/</link>
		
		<dc:creator><![CDATA[XO]]></dc:creator>
		<pubDate>Tue, 01 Oct 2019 16:46:03 +0000</pubDate>
				<category><![CDATA[System Center Operations Manager]]></category>
		<guid isPermaLink="false">https://xtremeownage.com/?p=431</guid>

					<description><![CDATA[A simple powershell function to quickly find out which objects are in maintenance mode, and who placed the object into maintenance mode.]]></description>
										<content:encoded><![CDATA[
<p>I ran into an issue today where a important production server was not being monitored. As well- when the user placed the object into maintenance mode, they did not include comments. Lastly- the UI does not show who performed the action by default without digging.</p>



<p>So- today, I present to you, a simple powershell function to find all Windows Computers in maintenance mode, and to output a table showing the computer&#8217;s name, who placed it into maintenance mode, the start and end time, and comments if available.</p>



<p>Here is the simple script:</p>



<pre title="Get-ObjectsInMaintenanceMode Function" class="wp-block-code"><code lang="powershell" class="language-powershell line-numbers">function Get-ObjectsInMaintenance
{
    Param(
        [Parameter(Mandatory=$false)][string[]]$excludeFromAccount = $null,
        [Parameter(Mandatory=$false)][string]$ManagementPackClass = "Microsoft.Windows.Computer"
    )
    
    $class = Get-SCOMClass -Name $ManagementPackClass
    $ComputersInMaintenance = Get-SCOMClassInstance -Class $class | Where InMaintenanceMode -eq $true
    ForEach($com in $ComputersInMaintenance)
    {
        $mm = $com | Get-SCOMMaintenanceMode

        #If there are values in excludeFromAccount, match the values against the User field.
        if($excludeFromAccount -ne $null -and $excludeFromAccount -contains $mm.User)
        {
            continue
        }

        
        [pscustomobject]@{
            Name = $com.Name
            Who = $mm.User
            StartTime = $mm.StartTime
            EndTime = $mm.ScheduledEndTime
            Comments = $mm.Comments
        } | Write-Output
    }
}

#Connect to your management group
New-SCOMManagementGroupConnection scom.mydomain.com

#Example 1. Show all Windows Computers in Maintenance Mode.
Get-ObjectsInMaintenance | Format-Table

##Example 2. Show all Windows Computers in Maintenance Mode, EXCEPT, if my account performed the action.
Get-ObjectsInMaintenance -excludeFromAccount 'MyDomain\AccountToExclude1' | Format-Table

##Example 3. Show all Windows Computers in Maintenance Mode, EXCEPT, by multiple accounts
Get-ObjectsInMaintenance -excludeFromAccount 'MyDomain\AccountToExclude1','MyDomain\AccountToExclude2' | Format-Table

#Example 4. Show all Unix objects in Maintenance Mode
Get-ObjectsInMaintenance -ManagementPackClass "Microsoft.Unix.Computer" | Format-Table</code></pre>



<p>For the above script, it is capable of filtering out any number of potential accounts, which is handy if you don&#8217;t want to audit yourself, or a trusted service-account.</p>



<p>As well- while it defaults to microsoft.windows.computer, you can specify any separate management pack class to view.</p>



<p>Lastly- the above script does not include any error handling to validate you provided a valid class, or you have a valid connection&#8230; etc. Just sharing my simple cmdlet for anybody who may benefit from it.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
