Today I got a question from my fellow Premier Field Engineer Anders Bengtsson if I could help him with an OpsMgr PowerShell script he was creating for an Orchestrator Runbook he started to create. And while waiting for a PowerShell workshop I was about to deliver I booted my OM2012 servers and had a look at his PowerShell script.
He wanted to be able to delete an OpsMgr Rule using PowerShell. As you may know there is no Remove-SCOMRule Cmdlet or function available in the PowerShell OperationsManager Module. Let’s check to be sure.
No, we can disable, enable and get a SCOMRule but there is no Remove-SCOMRule Cmdlet.
So, if there is none, let’s create one!
First let’s have a look at the parameters for the Get-SCOMRule, we may could use the same parameters in our Remove-SCOMRule Function.
Get-Help Get-SCOMRule -Detailed
Looking at the list of parameters the Get-SCOMRule is using we start simple using the DisplayName and Name parameters for our new Remove-SCOMRule function.
Here is a function you can use and tweak to Remove SCOM Rules in your OM2012 environment.
<# .Synopsis Removes a list of monitoring rules. .DESCRIPTION The Remove-SCOMRule removes a list of monitoring rules. .EXAMPLE Remove-SCOMRule -DisplayName "test rule" .EXAMPLE Get-SCOMRule -Name "MomUIGeneratedRule2c30f12ddfb6493fbd0c92e41db94495" | Remove-SCOMRule -Verbose #> function Remove-SCOMRule { [CmdletBinding(SupportsShouldProcess=$true)] Param ( # Specifies the name of the object [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$true, Position=0)] [string[]]$Name, # Specifies the displayname of the object [Parameter(Mandatory=$false, ValueFromPipelineByPropertyName=$false, Position=1)] [string]$dislayname ) Begin { Write-Verbose "Starting Function Remove-SCOMRule" } Process { #Create Hashtable for Get-SCOMRule Cmdlet parameters if ($name) { $parms = @{'name'=$name} } else { $parms = @{'displayname'=$displayname} } Write-Debug "`$parms: $parms" $Rule = Get-SCOMRule @parms Write-Verbose "Removing Rule: $($Rule.DisplayName)" $MP = Get-SCOMManagementPack -Name ($Rule.ManagementPackName) $MPObject = $MP.FindManagementPackElementByName($Rule.Name); $MPObject.Status = [Microsoft.EnterpriseManagement.Configuration.ManagementPackElementStatus]::PendingDelete $MP.AcceptChanges() } End { Write-Verbose "Finished Function Remove-SCOMRule" } }
How to use this function?
Now we can use the Get-SCOMRule Cmdlet to retrieve the Rule and pipe it to the Remove-SCOMRule Function. You can even remove multiple Rule in one go if you retrieve multiple rules using the Get-SCOMRule Cmdlet.
Remarks:
Sitting at the McCarran International Airport waiting for my flight to Amsterdam (the Netherlands) I had some time to kill so I wrote a simpel PowerShell script which helps to easily download the MMS 2013 sessions from the Channel 9 RSS feed.
Using the Out-GridView Cmdlet you can easily select the sessions you are interested in. Click on Ok when finished selecting the sessions you are interested in downloading.
After creating my initial version I got some feedback that sometimes the script did not work and with the help of Jamie Moyer (also a Senior PFE like me) we made the script more robust and added extra features like a HTML Report overview.
You can even use the –verbose switch and other parameters to tweak the download folder. We hope you like the improvements.
####################################################################################################################### # Description: Download MMS 2013 Channel 9 videos # PowerShell version: 3 # Author(s): Stefan Stranger (Microsoft) # Jamie Moyer (Microsoft # Example usage: Run Get-MMS2013Channel9Videos.ps1 -path c:\temp -verbose # Select using the Out-Gridview the videos you want to download and they are stored in your myvideos folder. # You can multiple select videos, holding the ctrl key. # Disclamer: This program source code is provided "AS IS" without warranty representation or condition of any kind # either express or implied, including but not limited to conditions or other terms of merchantability and/or # fitness for a particular purpose. The user assumes the entire risk as to the accuracy and the use of this # program code. # Date: 04-13-2012 # Name: Get-MMS2013Channel9Videos.ps1 # Version: v1.001 - 04-14-2012 - Stefan Stranger - initial release # Version: v1.005 - 04-29-2013 - Jamie Moyer, Stefan Stranger - added more robustness and HTML Report ######################################################################################################################## #requires -version 3.0 [CmdletBinding()] Param ( # Path where to store video's locally [Parameter(Mandatory=$false, Position=0)] $Path = [environment]::getfolderpath("myvideos") + "\MMS2013", [Parameter(Mandatory=$false, Position=1)] $rssfeed = "http://channel9.msdn.com/Events/MMS/2013/RSS" ) function Get-NewFileName($name) { Write-Verbose "Calling Get-NewFileName Function" $r=$Path+"\"+(($name -replace "[^\w\s\-]*") -replace "\s+") + ".wmv";$r } Write-Verbose "Remove last slash if added using the downloaddirectory Parameter" if ($path.EndsWith("\")){$path = $path.Substring(0,$path.Length-1)} write-verbose "Path is: $path" Write-Verbose "Checking if Download directory $Path exists" if(!(test-path $Path -PathType Container)) { Write-Verbose "Creating $Path" New-Item -ItemType Directory $Path | Out-Null } Write-Verbose "Downloading RSS Feed Items from $rssfeed" $feeditems = Invoke-RestMethod $rssfeed [array]$feeditemsWithDetails = $feeditems | select Title, Summary, Duration, Enclosure,creator | Add-Member -MemberType ScriptProperty -Name AlreadyDownloaded -Value {(test-path("$Path\$($this.enclosure.url.split('/')[6])"))} -PassThru -Force | Add-Member -MemberType ScriptProperty -Name Destination -Value {("$Path\$($this.enclosure.url.split('/')[6])")} -PassThru -Force | Add-Member -MemberType ScriptProperty -Name Source -Value {$this.enclosure.url} -PassThru -Force | select AlreadyDownloaded,Title, Summary, Duration, Enclosure,Source,Destination,creator | sort Title Write-Verbose "Add all already downloaded items back to the list" $duplicateVideoNames = $feeditemsWithDetails |sort name| group destination | where-object {$_.Name -ne "" -and $_.Count -gt 1} | ForEach-Object {$_.Group} Write-Verbose "Remove the posts with duplicate file names from the feeditemsSelected array" $feeditemsSelected = @($feeditemsSelected | Where-Object {$duplicateVideoNames -notcontains $_}) Write-Verbose "Change video names to filenames, check to see if they are downloaded already and added them back to the array with updated details" $duplicateVideoNames | foreach-object { $newDestination = Get-NewFileName $_.Title $_.Destination = $newDestination $_.AlreadyDownloaded = (Test-Path $newDestination) $feeditemsWithDetails += $_ } Write-Verbose "Open Out-GridView to select vidoes to download" [array]$feeditemsSelected = $feeditemsWithDetails| Out-GridView -PassThru | select AlreadyDownloaded,Title, Summary, Duration, Enclosure,Source,Destination Write-Verbose "Downloading videos" $feeditemsSelected |Where-Object{!(Test-Path $_.Destination)} | select Source,Destination | Start-BitsTransfer -Priority Normal | Out-Null Write-Verbose "Add all already downloaded items back to the list" $feeditemsWithDetails | where-object {$_.AlreadyDownloaded} | foreach-object { if(-not [bool]($feeditemsSelected | Select-String $_.Title -Quiet)) { $feeditemsSelected += $_ } } Write-Verbose "Create HTML Report" $feeditemsSelected | sort Name | Out-Null $html = $feeditemsSelected |?{Test-Path "$($_.Destination)"} | % {@" <H4><a href="$($_.Destination)">$($_.Title)</a></H4> <H5>Speaker(s): $($_.creator)</H5> <H5>$($_.Summary)</H5> "@} Write-Verbose "Open HTML Report" ConvertTo-Html -Head "<h1>My Downloaded MMS Videos - $($feeditemsSelected.Count) Downloaded</h1>" -Body $html | Out-File $Path\MyMMSContent.html;start "$Path\MyMMSContent.html"
Have fun!
In between my PowerShell activities, I’ll visiting the Microsoft Management Summit in Las Vegas next week. This week I’m delivering a PowerShell workshop in the Netherlands, and when returning from MMS I’ll again be teaching a PowerShell workshop before going to the PowerShell Summit in Redmond. So it’s going to be a busy month traveling to the US and back.
While preparing my PowerShell workshop this week I wanted to have a look at the sessions for MMS 2013 and went to the Sessions catalog on the www.2013mms.com website.
Because I could not find an option to export all sessions to a Excel sheet, I created a PowerShell script which retrieves all sessions and makes it possible to export the result to a csv file using the Export-CSV cmdlet.
If you want you can do many more fun things with the results, let me know what you created.
####################################################################################################################### # Description: Get-MMS2013 Sessions. This script retrieves the sessions from the http://www.2013mms.com website # You need to have access to the website to retrieve the sessions. # Example usage: Export all sessions to cvs file using the export-csv cmdlet. # Get-MMS2013Session.ps1 | export-csv -path c:\temp\mms2013sessions.csv -NoTypeInformation # Author: Stefan Stranger (Microsoft) # Example usage: Run Get-MMS2013Session.ps1 # Disclamer: This program source code is provided "AS IS" without warranty representation or condition of any kind # either express or implied, including but not limited to conditions or other terms of merchantability and/or # fitness for a particular purpose. The user assumes the entire risk as to the accuracy and the use of this # program code. # Date: 04-02-2013 # Name: Get-MMS2013Session.ps1 # Version: v1.000 - 04-02-2013 - Stefan Stranger - initial release ######################################################################################################################## $mms = Invoke-WebRequest -Uri "http://www.2013mms.com/Topic/List?format=html&Keyword=&Categories=&Timeslot=&Speaker=&Day=&Start=&Finish=&oc=&take=-1&skip=0&_=1364899913083" $sessions = $mms.ParsedHtml.getElementsByTagName("div") | Where "classname" -match "^topic" | Select -ExpandProperty InnerText foreach ($session in $sessions) { #$count++; $count; $session; $session = $session.split("`n",6); #Check Sessiontype. Switch -Wildcard ($session[0]) { '*-B*' {#Check for missing products if ($session[4] -like "Product(s)*"){ $session | &{ [pscustomobject]@{ Session = $session[0] Speaker = $session[1] Track = $session[2] SessionType = $session[3] Product= $session[4] Description = $session[5] } #End pscustomobject } #end call } #end if else { $session | &{ [pscustomobject]@{ Session = $session[0] Speaker = $session[1] Track = $session[2] SessionType = $session[3] Product= "" Description = $session[4] } #End pscustomobject } #end call } #end else } '*-L*' {$session | &{ [pscustomobject]@{ Session = $session[0] Speaker = "" Track = $session[1] SessionType = $session[2] Product = "" Description = $session[3] } #End pscustomobject } #end call } '*-IL*' {$session | &{ [pscustomobject]@{ Session = $session[0] Speaker = "" Track = $session[1] SessionType = $session[2] Product = "" Description = $session[3] } #End pscustomobject } #end call } 'BO*' {$session | &{ [pscustomobject]@{ Session = $session[0] Speaker = "" Track = "" SessionType = $session[1] Product = "" Description = $session[2] } #End pscustomobject } #end call } 'EXM*' {$session | &{ [pscustomobject]@{ Session = $session[0] Speaker = $session[1] Track = "" SessionType = $session[2] Product = $session[3] Description = $session[4] } #End pscustomobject } #end call } 'MMS*' {$session | &{ [pscustomobject]@{ Session = $session[0] Speaker = $session[1] Track = "" SessionType = $session[2] Product = "" Description = $session[3] } #End pscustomobject } #end call } 'KEY*' {$session | &{ [pscustomobject]@{ Session = $session[0] Speaker = $session[1] Track = "" SessionType = $session[2] Product = "" Description = $session[3] } #End pscustomobject } #end call } 'MSP*' {$session | &{ [pscustomobject]@{ Session = $session[0] Speaker = "" Track = "" SessionType = $session[1] Product = "" Description = $session[2] } #End pscustomobject } #end call } Default {#Write-Host "$($session[0]) session id not specified in script" -ForegroundColor Red; $session | &{ [pscustomobject]@{ Session = $session[0] Speaker = $session[1] Track = "" SessionType = $session[2] Product = "" Description = "$($session[0]) session id not specified in script" } #End pscustomobject } #end cal } } }
Do you want to contact me during MMS or the PowerShell summit just send me a message on Twitter and who knows we can talk about Operations Manager or PowerShell or some other great topic!
Today I was playing around with some MP Authoring automation using PowerShell and I needed to retrieve the Management Pack Reference Alias within a Management Pack. If you export a Management Pack to XML using the Get-SCOMManagementPack Cmdlet you can view the XML file and its contents.
Get-SCOMManagementPack -Name Stefan.Test.MP | Export-SCOMManagementPack -Path c:\temp
If you look at the exported MP XML file you can see the Management Pack Reference Aliases.
<ManagementPack ContentReadable="true" SchemaVersion="2.0" OriginalSchemaVersion="1.1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <Manifest> <Identity> <ID>Stefan.Test.MP</ID> <Version>1.0.0.0</Version> </Identity> <Name>Stefan - Test MP</Name> <References> <Reference Alias="MicrosoftWindowsLibrary7585010"> <ID>Microsoft.Windows.Library</ID> <Version>7.5.8501.0</Version> <PublicKeyToken>31bf3856ad364e35</PublicKeyToken> </Reference> <Reference Alias="SystemLibrary7585010"> <ID>System.Library</ID> <Version>7.5.8501.0</Version> <PublicKeyToken>31bf3856ad364e35</PublicKeyToken> </Reference> <Reference Alias="SystemCenter"> <ID>Microsoft.SystemCenter.Library</ID> <Version>7.0.8432.0</Version> <PublicKeyToken>31bf3856ad364e35</PublicKeyToken> </Reference> <Reference Alias="Health"> <ID>System.Health.Library</ID> <Version>7.0.8432.0</Version> <PublicKeyToken>31bf3856ad364e35</PublicKeyToken> </Reference> <Reference Alias="MicrosoftSystemCenterInstanceGroupLibrary7585010"> <ID>Microsoft.SystemCenter.InstanceGroup.Library</ID> <Version>7.5.8501.0</Version> <PublicKeyToken>31bf3856ad364e35</PublicKeyToken> </Reference> </References>
But you know me, I don’t want to export the XML file and open it to see the Reference Aliases We have PowerShell so we are going to use it.
How can we retrieve this info using PowerShell in the PowerShell OperationsManager Console?
$mp = Get-SCOMManagementPack -name Stefan.Test.MP $alias = ($mp.References | where {$_.Value -like "*Microsoft.Windows.Library*"}).key $alias
This will give us the Alias for the Microsoft.Windows.Library.
Next time more on how we could use this information to do some MP Authoring automation.
Have a nice Easter weekend and maybe I see you at MMS in Las Vegas or the PowerShell Summit in Redmond!
Today I got a question from a co-worker about retrieving the monitored network devices by OM2012 using PowerShell. For Agents it’s pretty simple, you just use the Get-SCOMAgent Cmdlet and you have a nice overview of the Agents being monitored by OM2012.
But which Cmdlet should you use to get an overview of the monitored network devices? There is no Get-SCOMNetworkDevice Cmdlet.
To retrieve the network devices being monitored by OM2012, you need the following Cmdlets Get-SCOMClass and Get-SCOMClassInstance.
Get-SCOMClass -DisplayName "Network Device" | Get-SCOMClassInstance
If you want to retrieve some more info about the network devices being monitored you can use the following PowerShell commands.
$SCOMNetworkDevices = Get-SCOMClass -DisplayName "Network Device" | Get-SCOMClassInstance $SCOMNetworkDevices | Format-List * $SCOMNetworkDevices | select ManagementGroup, DisplayName, @{Label="AccessMode";Expression={$_.'[System.NetworkManagement.Node].AccessMode'}}, @{Label="Certification";Expression={$_.'[System.NetworkManagement.Node].Certification'}}, @{Label="SystemObjectId";Expression={$_.'[System.NetworkManagement.Node].SystemObjectId'}}
DISCLAMER: This Sample Code is provided for the purpose of illustration only. THIS SAMPLE CODE AND ANY RELATED INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
We grant You a nonexclusive, royalty-free right to use and modify the Sample Code and to reproduce and distribute the object code form of the Sample Code, provided that You agree: (i) to not use Our name, logo, or trademarks to market Your software product in which the Sample Code is embedded; (ii) to include a valid copyright notice on Your software product in which the Sample Code is embedded; and (iii) to indemnify, hold harmless, and defend Us and Our suppliers from and against any claims or lawsuits, including attorneys' fees, that arise or result from the use or distribution of the Sample Code.
I don’t know if you noticed but Daniel Savage started a blog series about how we are raising the bar with respect to Management Packs. Daniel is responsible for all things related to Operations Manager Management Packs including customer satisfaction related to MPs for Microsoft server workloads.
In his first blogpost he also references a Wiki Management Pack page on Microsoft Technet.
So I thought it would be cool to be able to scrape some of the information about Management Packs using PowerShell. With some help from Jeff Wouters it turned out not to be that difficult.
$hsg = Invoke-WebRequest -Uri "http://social.technet.microsoft.com/wiki/contents/articles/16174.microsoft-management-packs.aspx" $hsg.Links | Where-Object {($_.href -like "*http://www.microsoft.com/*download*") -and ($_.outerText -notlike "*Link to download page*") -and ($_.InnerHTML -like "*This link*")} | Select @{Label="Management Pack";Expression={$_.InnerText}}, @{Label="Download Link";Expression={$_.href}}
[xml]$hsg = Invoke-WebRequest "http://social.technet.microsoft.com/wiki/contents/articles/16174.microsoft-management-packs/rss.aspx" $hsg.rss.channel.item | select Title, pubDate, creator
You could use some of the code to create some monitor to check for new Management Pack updates, using the RSS feed or some other fun stuff.
There is a new Update Rollup 1 for System Center 2012 Service Pack 1 available for System Center 2012 Service Pack 1.
http://www.microsoft.com/download/details.aspx?id=29696
Operations Manager (KB2784734) Download the update package now. (http://catalog.update.microsoft.com/v7/site/Search.aspx?q=2784734)
Service Provider Foundation (KB2785476) Download the update package now. (http://catalog.update.microsoft.com/v7/site/Search.aspx?q=2785476)
Virtual Machine Manager (KB2792925 - Console, KB2792926 – VMM Server) Download the Console update package now. (http://catalog.update.microsoft.com/v7/site/Search.aspx?q=2792925)
Download the VMM Server update package now. (http://catalog.update.microsoft.com/v7/site/Search.aspx?q=2792926)
To manually install the update packages, run the following command from an elevated command prompt: msiexec.exe /update packagename
For example, to install the Virtual Machine Manager Server Update (KB2792926), run the following command: msiexec.exe /update KB2792926-AMD64-Server.msp
Remark: You can also read my blogpost OpsMgr 2012: Update Rollup 3 ships, and my experience installing it, to see what has changed for updates since UR3.
This is part 2 in a two blog post series about configuring Windows Phone Push Notifications for OpsMgr 2012. Please read blog post part 1 first, if you have not read this.
Disclamer: I’ve this only tested on OM2012 SP1 and you need PowerShell v3 to have the script working.
In this blog post we are going configure the Notification. These are the high-level steps to configure OM2012 Notifications:
Step 1. Create the PowerShell script which sends the OM2012 Alerts as Windows Phone Push Notifications.
We need to create a PowerShell script which sends the OM2012 Alerts as Windows Phone Push Notifications. We store this script on the Management Server in a location of your own choice.
In this example I store the WindowsPhonePushNotifications_v0.1.ps1 script in the C:\Scripts folder on the Management Server.
The script has three parameters which are show in the Windows Phone Push Notifications:
#Requires -Version 3 ####################################################################################################################### # Using the Notify my Windows Phone API using PowerShell # Author: Stefan Stranger # Disclamer: This program source code is provided "AS IS" without warranty representation or condition of any kind # either express or implied, including but not limited to conditions or other terms of merchantability and/or # fitness for a particular purpose. The user assumes the entire risk as to the accuracy and the use of this # program code. # Date: 01-05-2012 # Name: NotifyMyWindowPhone_v0.1.ps1 # v0.01 - 01-05-2012 - Stefan Stranger - sstranger's initial release # v0.02 - 01-07-2012 - Stefan Stranger - Added Notification Channel Subscriptions ######################################################################################################################## Param($alertname,$alertseverity,$alertTimeRaised) # Enter your own API Key from http://www.nmwp7.com/user/apikeys $apikey = "[enter here your api key]" # Enter the name of the application the notification originates from. $application = "OM2012" # Enter The event that occured. Depending on your application, this might be a summary, subject or a brief explanation. $event = "OM2012 Alert" # The full body of the notification. $description = @" AlertName: $alertname AlertSeverity: $alertseverity AlertTimeRaised: $alertTimeRaised "@ #You can enable the write-eventlog for logging purposes. #write-eventlog -LogName Application -source MSIInstaller -EventId 999 -entrytype Information -Message $description # An optional value representing the priority of the notification. $priority = "-2" # Specifies the responsetype you want. You can currently choose between JSON or XML (default) $type = "json" $uri = "http://notifymywindowsphone.com/publicapi/notify?event=$event&priority=$priority&application=$application&description=$description&apikey=$apikey&type=$type" Invoke-WebRequest -Uri $uri
Step 2. Create the Command Channel
Go to Administration -> Notifications -> Channels and choose New Channel.
Give your Channel a name. (example Windows Phone Push Notifications)
Enter the Command Notification Channel Settings.
Full path of the command file:
C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe
Command line parameters:
C:\Scripts\WindowsPhonePushNotifications_v0.1.ps1 '$Data/Context/DataItem/AlertName$' '$Data/Context/DataItem/Severity$' '$Data/Context/DataItem/TimeRaisedLocal$'
Startup folder for the command line:
C:\Scripts
Step 3. Create the Subscriber
Right click "Subscribers" and choose "New Subscriber"
Enter a easily to identify Subscriber name, like Windows Phone Push Notifications.
Configure the Schedule.
Enter a non-existing address
Configure the Channel
Click Next, click Finish
Step 4. Create the Subscription
We now need to create a new subscription. Right-click on "Subscriptions" and choose New Subscription.
Enter the Subscription Notification fields.
Click Next and Configure the Criteria.
In this test we will configure each alert with a Resolution State of New.
Click Next and add the previously created Subscriber
Click Next and add previously created Channel.
Click Next and Finish.
Now we test our Command Channel with a test Alert Rule and watch our Windows Phone for the Push Notifications.
If everything is working as expected you will see the following Windows Phone Push Notifications.
Have fun configuring Windows Phone Push Notifications!
Did you know you can easily create your own Windows Phone Push Notifications using the Notify My Windows Phone app?
NMWP is a platform that helps you push information to virtually any Windows Phone 7 (and 8) device you own.
What do you need to get started?
First we need to install the The NMWP app from the Microsoft Store on our Windows Phone. Open the Windows Store app on your Windows Phone and install the app.
Next we need to Sign up at http://www.nmwp7.com/user/register and create a username and password.
After registering you need to enter your username and password at the Notify my Windows Phone app on your Windows Phone.
And at last we need to request an API key on the http://www.nmwp7.com/user/apikeys website.
After requesting the API key you can test the key using the Send testmessage button.
Hopefully now everything is working as expected.
Testing Notify My Windows Phone from PowerShell
If you look at the API help it’s pretty simple to call the API. With PowerShell v3 you can use the Invoke-WebRequest cmdlet to call the Web API.
A simple PowerShell script to call the Web API can look something like this:
#Requires -Version 3 ####################################################################################################################### # Using the Notify my Windows Phone API using PowerShell # Author: Stefan Stranger # Disclamer: This program source code is provided "AS IS" without warranty representation or condition of any kind # either express or implied, including but not limited to conditions or other terms of merchantability and/or # fitness for a particular purpose. The user assumes the entire risk as to the accuracy and the use of this # program code. # Date: 01-05-2012 # Name: NotifyMyWindowPhone.ps1 # v0.01 - 01-05-2012 - Stefan Stranger - sstranger's initial release ######################################################################################################################## # Enter your own API Key from http://www.nmwp7.com/user/apikeys $apikey = "[enter here your api key]" # Enter the name of the application the notification originates from. $application = "WindowsPowerShell" # Enter The event that occured. Depending on your application, this might be a summary, subject or a brief explanation. $event = "Push Message sent from PowerShell" # The full body of the notification. $description = "This message was sent as a test" # An optional value representing the priority of the notification. $priority = "-2" # Specifies the responsetype you want. You can currently choose between JSON or XML (default) $type = "json" $uri = "http://notifymywindowsphone.com/publicapi/notify?event=$event&priority=$priority&application=$application&description=$description&apikey=$apikey&type=$type" Invoke-WebRequest -Uri $uri
If you run above PowerShell script you will see the following result returned in your console.
Now you would see the push notification on your Windows Phone.
In my next blog post I’ll explain how you can use above to create Windows Phone Push Notifications for your OpsMgr Alerts using the Notification Command Channel.
W00t! My Protect Your PowerShell Scripts with Version Control blog article I wrote for the Hey, Scripting Guy! Blog, got published today
Check it out!
Some days ago I read a blog post from Bjorn Houben called SCOM2012 – Quick test lab setup OpsMgr 2012 SP1 Beta using prepared VHD.
In that blog post he described how he had used the pre-configured System Center 2012 SP1 Beta downloadable evaluation VHDs to quickly install a test lab setup for OpsMgr 2012 SP1 beta.
And that’s exactly what I needed to do too, but I wanted to take it one step further also using the Windows Server 2012 Evaluation VHD for the needed Domain Controller in my test lab setup. And to top it off, use PowerShell as much as possible.
On the 24th of December I posted a tweet with a picture showing the installation of the Domain Controller using some PowerShell scripts to automate the installation.
And since I’ve been getting requests to publish the PowerShell script I used to install the roles needed on the Domain Controller for the OpsMgr 2012 SP1 Beta test lab environment. And because Mats Wigle told me that “Sharing is caring”, I decided to share my experiences setting up a test lab environment with PowerShell and the steps outlined by Bjorn Houben. He should get most credits for this article, because he got me inspired.
Pre-requisites:
* I used a PowerShell script to create these Hyper-V switches, but this is an internal script we use for our workshops, so I cannot share this script.
Now we have the Virtual Machines ready, we can start with the installation. First we need to start with the Domain Controller (OM2012SP1DC)
Installation of Domain Controller
For the Domain Controller we need to configure the following:
After starting the Virtual Machine you need to go through the walk-through of the setup.
Enter Password for Administrator Account
Remark: If you want to convert the Eval version to a full version with a Product Key of your own, you need to run the DISM tool before installing the Domain Controller Role. Make sure you are connected to the internet!
DISM /online /Set-Edition:ServerDatacenter /ProductKey:[enter your key here] /AcceptEula
You can also continue to use the EVAL version till it expires if you want to.
To run a PowerShell script with the steps described below you need to configure the Execution Policy on the future Domain Controller.
Run the following PowerShell command from an elevated PowerShell console:
Set-ExecutionPolicy ByPass
In the following PowerShell script we are going to configure the following:
Pro-Tip: Store below script in an ISO so you can easily use the script from within your Virtual Machine.
#Configure a static IP address.$IPAddress="192.168.1.101"$SubnetMask="255.255.255.0"$DefaultGateway="192.168.1.1"$DNSServers="192.168.1.101"#enter here a DNS server which can resolve (exteral) addresses Get-WmiObject Win32_NetworkAdapterConfiguration -Filter"IPEnabled=TRUE"|ForEach-Object { $_.EnableStatic($IPAddress,$SubnetMask) $_.SetGateways($DefaultGateway) $_.SetDNSServerSearchOrder($DNSServers) } #Rename Computername$NewComputerName="OM2012SP1DC"$ComputerInfo= Get-WmiObject -Class Win32_ComputerSystem $ComputerInfo.rename($NewComputerName) #Reboot ComputerRestart-Computer -Force #Configure AD DS / domain controller role.Install-WindowsFeature AD-Domain-Services -IncludeManagementTools $Password= ConvertTo-SecureString "P@ssw0rd"-AsPlainText -Force #Enter the same password you used during the initial install of the server.Install-ADDSForest -DomainName "corp.contoso.com"-SafeModeAdministratorPassword $Password-Force #Install DHCP RoleInstall-WindowsFeature DHCP -IncludeManagementTools #Create ScopeAdd-DhcpServerv4Scope -ComputerName OM2012SP1DC -Name OM2012SP1Scope ` -StartRange 192.168.1.105-EndRange 192.168.1.110 ` -Description "Scope for OM2012SP1"-Type DHCP ` -State Active -SubnetMask 255.255.255.0 ` -LeaseDuration (New-TimeSpan -Days 1) #Set DNS Server Scope optionSet-DhcpServerv4OptionValue -OptionId 6-Value 192.168.1.101#Restart ComputerRestart-Computer -force #Authorize DHCP ServerAdd-DhcpServerInDC -DnsName OM2012SP1DC.CORP.CONTOSO.COM
We now have a Domain Controller ready for the test lab OM2012SP1 Beta Evalution VHD Virtual Machine.
Installation of the OM2012 SP1 Beta Management Server
Start the OM2012SP1 Beta Evalution VHD Virtual Machine from within Hyper-V and continue with the installation of OM2012 SP1 Beta Management Server.
When you connect with the OM2012SP1 Beta Evalution VHD Virtual Machine you need to use the Wizard to configure the Management Server.
After configuring the correct settings and clicking OK, you need to go get a cup of coffee, because the rest of the installation will take about 90 minutes to finish (on my Windows 8 Hyper-V machine).
You will see the following screens during the setup.
When finished you have your test lab OM2012 SP1 beta ready for testing. Now you only have to wait for the Public SP1 availability and upgrade to the latest version
And remember “Sharing is caring!”
What better way than using PowerShell to wish you all a Merry Christmas and Happy New Year!
Copy and paste script and run in PowerShell.
$frame1 = @" .----------------------_._------------------------------------------. | d888b . * | | . * _ ?888P_ . | | ,-~~-'-/_~~~\.'-~:8o. * | | ,' .:8bv' .:88. . | | / .:88 .:8b . . . | | . / .:8P .:8b | | ,' .:8P\ .:88. M | | ,=' .:88 \ __:88g_ | | -._ .:8| | _..-~,~ ~;' * | | ~o..__ .:8| | _-~ ?8b_ _.-' | | ~~ ~~--.:88 /:___...(888) | | * '^' . | | `-------------------------------------------------------------------' "@ $frame2 = @" .----------------------_._------------------------------------------. | d888b . * | | . * _ ?888P_ . | | ,-~~-'-/_~~~\.'-~:8o. * | | ,' .:8bv' .:88. . | | / .:88 .:8b . . . | | . / .:8P .:8b | | ,' .:8P\ .:88. Me | | ,=' .:88 \ __:88g_ | | -._ .:8| | _..-~,~ ~;' * | | ~o..__ .:8| | _-~ ?8b_ _.-' | | ~~ ~~--.:88 /:___...(888) | | * '^' . | | `-------------------------------------------------------------------' "@ $frame3 = @" .----------------------_._------------------------------------------. | d888b . * | | . * _ ?888P_ . | | ,-~~-'-/_~~~\.'-~:8o. * | | ,' .:8bv' .:88. . | | / .:88 .:8b . . . | | . / .:8P .:8b | | ,' .:8P\ .:88. Mer | | ,=' .:88 \ __:88g_ | | -._ .:8| | _..-~,~ ~;' * | | ~o..__ .:8| | _-~ ?8b_ _.-' | | ~~ ~~--.:88 /:___...(888) | | * '^' . | | `-------------------------------------------------------------------' "@ $frame4 = @" .----------------------_._------------------------------------------. | d888b . * | | . * _ ?888P_ . | | ,-~~-'-/_~~~\.'-~:8o. * | | ,' .:8bv' .:88. . | | / .:88 .:8b . . . | | . / .:8P .:8b | | ,' .:8P\ .:88. Merr | | ,=' .:88 \ __:88g_ | | -._ .:8| | _..-~,~ ~;' * | | ~o..__ .:8| | _-~ ?8b_ _.-' | | ~~ ~~--.:88 /:___...(888) | | * '^' . | | `-------------------------------------------------------------------' "@ $frame5 = @" .----------------------_._------------------------------------------. | d888b . * | | . * _ ?888P_ . | | ,-~~-'-/_~~~\.'-~:8o. * | | ,' .:8bv' .:88. . | | / .:88 .:8b . . . | | . / .:8P .:8b | | ,' .:8P\ .:88. Merry | | ,=' .:88 \ __:88g_ | | -._ .:8| | _..-~,~ ~;' * | | ~o..__ .:8| | _-~ ?8b_ _.-' | | ~~ ~~--.:88 /:___...(888) | | * '^' . | | `-------------------------------------------------------------------' "@ $frame6 = @" .----------------------_._------------------------------------------. | d888b . * | | . * _ ?888P_ . | | ,-~~-'-/_~~~\.'-~:8o. * | | ,' .:8bv' .:88. . | | / .:88 .:8b . . . | | . / .:8P .:8b | | ,' .:8P\ .:88. Merry C | | ,=' .:88 \ __:88g_ | | -._ .:8| | _..-~,~ ~;' * | | ~o..__ .:8| | _-~ ?8b_ _.-' | | ~~ ~~--.:88 /:___...(888) | | * '^' . | | `-------------------------------------------------------------------' "@ $frame7 = @" .----------------------_._------------------------------------------. | d888b . * | | . * _ ?888P_ . | | ,-~~-'-/_~~~\.'-~:8o. * | | ,' .:8bv' .:88. . | | / .:88 .:8b . . . | | . / .:8P .:8b | | ,' .:8P\ .:88. Merry Ch | | ,=' .:88 \ __:88g_ | | -._ .:8| | _..-~,~ ~;' * | | ~o..__ .:8| | _-~ ?8b_ _.-' | | ~~ ~~--.:88 /:___...(888) | | * '^' . | | `-------------------------------------------------------------------' "@ $frame8 = @" .----------------------_._------------------------------------------. | d888b . * | | . * _ ?888P_ . | | ,-~~-'-/_~~~\.'-~:8o. * | | ,' .:8bv' .:88. . | | / .:88 .:8b . . . | | . / .:8P .:8b | | ,' .:8P\ .:88. Merry Chr | | ,=' .:88 \ __:88g_ | | -._ .:8| | _..-~,~ ~;' * | | ~o..__ .:8| | _-~ ?8b_ _.-' | | ~~ ~~--.:88 /:___...(888) | | * '^' . | | `-------------------------------------------------------------------' "@ $frame9 = @" .----------------------_._------------------------------------------. | d888b . * | | . * _ ?888P_ . | | ,-~~-'-/_~~~\.'-~:8o. * | | ,' .:8bv' .:88. . | | / .:88 .:8b . . . | | . / .:8P .:8b | | ,' .:8P\ .:88. Merry Chri | | ,=' .:88 \ __:88g_ | | -._ .:8| | _..-~,~ ~;' * | | ~o..__ .:8| | _-~ ?8b_ _.-' | | ~~ ~~--.:88 /:___...(888) | | * '^' . | | `-------------------------------------------------------------------' "@ $frame10 = @" .----------------------_._------------------------------------------. | d888b . * | | . * _ ?888P_ . | | ,-~~-'-/_~~~\.'-~:8o. * | | ,' .:8bv' .:88. . | | / .:88 .:8b . . . | | . / .:8P .:8b | | ,' .:8P\ .:88. Merry Christ | | ,=' .:88 \ __:88g_ | | -._ .:8| | _..-~,~ ~;' * | | ~o..__ .:8| | _-~ ?8b_ _.-' | | ~~ ~~--.:88 /:___...(888) | | * '^' . | | `-------------------------------------------------------------------' "@ $frame11 = @" .----------------------_._------------------------------------------. | d888b . * | | . * _ ?888P_ . | | ,-~~-'-/_~~~\.'-~:8o. * | | ,' .:8bv' .:88. . | | / .:88 .:8b . . . | | . / .:8P .:8b | | ,' .:8P\ .:88. Merry Christm | | ,=' .:88 \ __:88g_ | | -._ .:8| | _..-~,~ ~;' * | | ~o..__ .:8| | _-~ ?8b_ _.-' | | ~~ ~~--.:88 /:___...(888) | | * '^' . | | `-------------------------------------------------------------------' "@ $frame12 = @" .----------------------_._------------------------------------------. | d888b . * | | . * _ ?888P_ . | | ,-~~-'-/_~~~\.'-~:8o. * | | ,' .:8bv' .:88. . | | / .:88 .:8b . . . | | . / .:8P .:8b | | ,' .:8P\ .:88. Merry Christma | | ,=' .:88 \ __:88g_ | | -._ .:8| | _..-~,~ ~;' * | | ~o..__ .:8| | _-~ ?8b_ _.-' | | ~~ ~~--.:88 /:___...(888) | | * '^' . | | `-------------------------------------------------------------------' "@ $frame13 = @" .----------------------_._------------------------------------------. | d888b . * | | . * _ ?888P_ . | | ,-~~-'-/_~~~\.'-~:8o. * | | ,' .:8bv' .:88. . | | / .:88 .:8b . . . | | . / .:8P .:8b | | ,' .:8P\ .:88. Merry Christmas | | ,=' .:88 \ __:88g_ | | -._ .:8| | _..-~,~ ~;' * | | ~o..__ .:8| | _-~ ?8b_ _.-' | | ~~ ~~--.:88 /:___...(888) | | * '^' . | | `-------------------------------------------------------------------' "@ $frame14 = @" .----------------------_._------------------------------------------. | d888b . * | | . * _ ?888P_ . | | ,-~~-'-/_~~~\.'-~:8o. * | | ,' .:8bv' .:88. . | | / .:88 .:8b . . . | | . / .:8P .:8b | | ,' .:8P\ .:88. Merry Christmas | | ,=' .:88 \ __:88g_ | | -._ .:8| | _..-~,~ ~;' & * | | ~o..__ .:8| | _-~ ?8b_ _.-' | | ~~ ~~--.:88 /:___...(888) | | * '^' . | | `-------------------------------------------------------------------' "@ $frame15 = @" .----------------------_._------------------------------------------. | d888b . * | | . * _ ?888P_ . | | ,-~~-'-/_~~~\.'-~:8o. * | | ,' .:8bv' .:88. . | | / .:88 .:8b . . . | | . / .:8P .:8b | | ,' .:8P\ .:88. Merry Christmas | | ,=' .:88 \ __:88g_ | | -._ .:8| | _..-~,~ ~;' & * | | ~o..__ .:8| | _-~ ?8b_ _.-' | | ~~ ~~--.:88 /:___...(888) H | | * '^' . | | `-------------------------------------------------------------------' "@ $frame16 = @" .----------------------_._------------------------------------------. | d888b . * | | . * _ ?888P_ . | | ,-~~-'-/_~~~\.'-~:8o. * | | ,' .:8bv' .:88. . | | / .:88 .:8b . . . | | . / .:8P .:8b | | ,' .:8P\ .:88. Merry Christmas | | ,=' .:88 \ __:88g_ | | -._ .:8| | _..-~,~ ~;' & * | | ~o..__ .:8| | _-~ ?8b_ _.-' | | ~~ ~~--.:88 /:___...(888) Ha | | * '^' . | | `-------------------------------------------------------------------' "@ $frame17 = @" .----------------------_._------------------------------------------. | d888b . * | | . * _ ?888P_ . | | ,-~~-'-/_~~~\.'-~:8o. * | | ,' .:8bv' .:88. . | | / .:88 .:8b . . . | | . / .:8P .:8b | | ,' .:8P\ .:88. Merry Christmas | | ,=' .:88 \ __:88g_ | | -._ .:8| | _..-~,~ ~;' & * | | ~o..__ .:8| | _-~ ?8b_ _.-' | | ~~ ~~--.:88 /:___...(888) Hap | | * '^' . | | `-------------------------------------------------------------------' "@ $frame18 = @" .----------------------_._------------------------------------------. | d888b . * | | . * _ ?888P_ . | | ,-~~-'-/_~~~\.'-~:8o. * | | ,' .:8bv' .:88. . | | / .:88 .:8b . . . | | . / .:8P .:8b | | ,' .:8P\ .:88. Merry Christmas | | ,=' .:88 \ __:88g_ | | -._ .:8| | _..-~,~ ~;' & * | | ~o..__ .:8| | _-~ ?8b_ _.-' | | ~~ ~~--.:88 /:___...(888) Happ | | * '^' . | | `-------------------------------------------------------------------' "@ $frame19 = @" .----------------------_._------------------------------------------. | d888b . * | | . * _ ?888P_ . | | ,-~~-'-/_~~~\.'-~:8o. * | | ,' .:8bv' .:88. . | | / .:88 .:8b . . . | | . / .:8P .:8b | | ,' .:8P\ .:88. Merry Christmas | | ,=' .:88 \ __:88g_ | | -._ .:8| | _..-~,~ ~;' & * | | ~o..__ .:8| | _-~ ?8b_ _.-' | | ~~ ~~--.:88 /:___...(888) Happy | | * '^' . | | `-------------------------------------------------------------------' "@ $frame20 = @" .----------------------_._------------------------------------------. | d888b . * | | . * _ ?888P_ . | | ,-~~-'-/_~~~\.'-~:8o. * | | ,' .:8bv' .:88. . | | / .:88 .:8b . . . | | . / .:8P .:8b | | ,' .:8P\ .:88. Merry Christmas | | ,=' .:88 \ __:88g_ | | -._ .:8| | _..-~,~ ~;' & * | | ~o..__ .:8| | _-~ ?8b_ _.-' | | ~~ ~~--.:88 /:___...(888) Happy N | | * '^' . | | `-------------------------------------------------------------------' "@ $frame21 = @" .----------------------_._------------------------------------------. | d888b . * | | . * _ ?888P_ . | | ,-~~-'-/_~~~\.'-~:8o. * | | ,' .:8bv' .:88. . | | / .:88 .:8b . . . | | . / .:8P .:8b | | ,' .:8P\ .:88. Merry Christmas | | ,=' .:88 \ __:88g_ | | -._ .:8| | _..-~,~ ~;' & * | | ~o..__ .:8| | _-~ ?8b_ _.-' | | ~~ ~~--.:88 /:___...(888) Happy Ne | | * '^' . | | `-------------------------------------------------------------------' "@ $frame22 = @" .----------------------_._------------------------------------------. | d888b . * | | . * _ ?888P_ . | | ,-~~-'-/_~~~\.'-~:8o. * | | ,' .:8bv' .:88. . | | / .:88 .:8b . . . | | . / .:8P .:8b | | ,' .:8P\ .:88. Merry Christmas | | ,=' .:88 \ __:88g_ | | -._ .:8| | _..-~,~ ~;' & * | | ~o..__ .:8| | _-~ ?8b_ _.-' | | ~~ ~~--.:88 /:___...(888) Happy New | | * '^' . | | `-------------------------------------------------------------------' "@ $frame23 = @" .----------------------_._------------------------------------------. | d888b . * | | . * _ ?888P_ . | | ,-~~-'-/_~~~\.'-~:8o. * | | ,' .:8bv' .:88. . | | / .:88 .:8b . . . | | . / .:8P .:8b | | ,' .:8P\ .:88. Merry Christmas | | ,=' .:88 \ __:88g_ | | -._ .:8| | _..-~,~ ~;' & * | | ~o..__ .:8| | _-~ ?8b_ _.-' | | ~~ ~~--.:88 /:___...(888) Happy New | | * '^' . | | Y `-------------------------------------------------------------------' "@ $frame24 = @" .----------------------_._------------------------------------------. | d888b . * | | . * _ ?888P_ . | | ,-~~-'-/_~~~\.'-~:8o. * | | ,' .:8bv' .:88. . | | / .:88 .:8b . . . | | . / .:8P .:8b | | ,' .:8P\ .:88. Merry Christmas | | ,=' .:88 \ __:88g_ | | -._ .:8| | _..-~,~ ~;' & * | | ~o..__ .:8| | _-~ ?8b_ _.-' | | ~~ ~~--.:88 /:___...(888) Happy New | | * '^' . | | Ye `-------------------------------------------------------------------' "@ $frame25 = @" .----------------------_._------------------------------------------. | d888b . * | | . * _ ?888P_ . | | ,-~~-'-/_~~~\.'-~:8o. * | | ,' .:8bv' .:88. . | | / .:88 .:8b . . . | | . / .:8P .:8b | | ,' .:8P\ .:88. Merry Christmas | | ,=' .:88 \ __:88g_ | | -._ .:8| | _..-~,~ ~;' & * | | ~o..__ .:8| | _-~ ?8b_ _.-' | | ~~ ~~--.:88 /:___...(888) Happy New | | * '^' . | | Yea `-------------------------------------------------------------------' "@ $frame26 = @" .----------------------_._------------------------------------------. | d888b . * | | . * _ ?888P_ . | | ,-~~-'-/_~~~\.'-~:8o. * | | ,' .:8bv' .:88. . | | / .:88 .:8b . . . | | . / .:8P .:8b | | ,' .:8P\ .:88. Merry Christmas | | ,=' .:88 \ __:88g_ | | -._ .:8| | _..-~,~ ~;' & * | | ~o..__ .:8| | _-~ ?8b_ _.-' | | ~~ ~~--.:88 /:___...(888) Happy New | | * '^' . | | Year `-------------------------------------------------------------------' "@ $allframes = ($frame1,$frame2,$frame3,$frame4,$frame5,$frame6,$frame7,$frame8,$frame9,$frame10 ` ,$frame11,$frame12,$frame13,$frame14,$frame15,$frame16,$frame17,$frame18,$frame19,$frame20 ` ,$frame21,$frame22,$frame23,$frame24,$frame25,$frame26) $JingleBells = {[console]::beep(659,400);sleep -m 50;[console]::beep(659,400);sleep -m 50;[console]::beep(659,800) ;sleep -m 50;[console]::beep(659,400);sleep -m 50;[console]::beep(659,400);sleep -m 50;[console]::beep(659,800);sleep -m 50;[console]::beep(659,400);sleep -m 50;[console]::beep(783,400);sleep -m 50;[console]::beep(523,400);sleep -m 50;[console]::beep(587,400);sleep -m 50;[console]::beep(659,800)} $newPowerShell = [PowerShell]::Create().AddScript($JingleBells) $handle = $newPowerShell.BeginInvoke() while ($handle.IsCompleted -eq $false) { $allframes | foreach {$_;sleep -m 120;cls} } $newPowerShell.EndInvoke($handle) $frame26
If you don’t want to run the PowerShell script yourself you can watch the video
Last Friday we had our first ever Dutch PowerShell User Group meeting and I could finally meet Ed Wilson and his wife Teresa.
Read more on the Hey, Scripting Guy! Blog
I finally found out the issue why this script was not working for everybody. It was because of the different versions of PowerShell. Now it should also work on PowerShell v2.
Another possible fix to the empty ComputerGroupsMembernames issue.
Last week I saw a request for a PowerShell script which would put all the members of a OM2012 Computer Group in Maintenance Mode, so this could be used with the Task Scheduler.
I know there are quite some alternative when it comes to putting instances in Maintenance Mode, but I thought it would be cool to create the mother-of-all maintenance mode PowerShell scripts for OM2012 :-)
This PowerShell script can be run standalone or scheduled with the Task Scheduler and has the following cool features:
Ok enough about the features, here is the script:
####################################################################################################################### # Puts a OM2012 Computer Group in Maintenance Mode using PowerShell # Author: Stefan Stranger (Microsoft) # Example usage: Run Get-Help Get-SCOMMaintenanceModeForGroups.ps1 -Examples # Disclamer: This program source code is provided "AS IS" without warranty representation or condition of any kind # either express or implied, including but not limited to conditions or other terms of merchantability and/or # fitness for a particular purpose. The user assumes the entire risk as to the accuracy and the use of this # program code. # Tested on PowerShell v3 and OM2012 environment # Date: 03-07-2012 # Name: Get-SCOMMaintenanceModeForGroups.ps1 # v1.000 - 03-07-2012 - Stefan Stranger - initial sstranger's release # v1.001 - 06-07-2012 - Stefan Stranger - Added Eventlog and WhatIf Switch # v1.003 - 07-11-2012 - Stefan Stranger - Fixed issue on PowerShell v2, Now works on v2 and v3 # v1.004 - 16-11-2012 - Stefan Stranger - Fixed issue with empty GroupMembershipNames issue######################################################################################################################## <# .SYNOPSIS Places all members of a SCOM Computer Group in into maintenance mode, and creates new active maintenance mode entries. .DESCRIPTION The Start-MaintenanceModeForGroups script places all members of a SCOM Computer Group into maintenance mode, and creates new active maintenance mode entries. When in maintenance mode, alerts, notifications, rules, monitors, automatic responses, state changes, and new alerts are suppressed for the class instance. .EXAMPLE Start-SCOMMaintenanceModeForGroup.ps1 -ComputerGroup "All Windows Computers" -EndTime 10 -Reason "UnplannedOther" -Comment "Testing Maintenance Mode" -Verbose Puts all Members of the "All Windows Computer" Group in Maintenance Mode for 10 minutes, with Reason "UnplannedOther" and with Comment "Testing Maintenance Mode". Adding Verbose information. .EXAMPLE Start-SCOMMaintenanceModeForGroup.ps1 -ComputerGroup "All Windows Computers" -EndTime 10 -Reason "UnplannedOther" -Comment "Testing Maintenance Mode" -Eventlog Puts all Members of the "All Windows Computer" Group in Maintenance Mode for 10 minutes, with Reason "UnplannedOther" and with Comment "Testing Maintenance Mode". Writing Eventlog information to the "Operations Manager" Eventlog (eventid 998 and eventid 999). Can be used for tracking and debugging when Task Scheduler is being used. .EXAMPLE Start-SCOMMaintenanceModeForGroup.ps1 -ComputerGroup "All Windows Computers" -EndTime 10 -Reason "UnplannedOther" -Comment "Testing Maintenance Mode" -WhatIf Using the WhatIf switch shows which Members of the "All Windows Computer" Group would be put in Maintenance Mode if you had run the script. So the members are not really put into maintenance mode. For testing purposes. .PARAMETER ComputerGroup The SCOM Computer Group name for which members you want to put in Maintenance Mode. .PARAMETER EndTime Specifies the time the maintenance will end. The minimum amount of time a resource can be in maintenance mode is 5 minutes. .PARAMETER Reason Specifies the reason for placing the resource into maintenance mode. Valid values are: UnplannedOther, PlannedHardwareMaintenance, UnplannedHardwareMaintenance, PlannedHardwareInstallation, UnplannedHardwareInstallation, PlannedOperatingSystemReconfiguration, UnplannedOperatingSystemReconfiguration, PlannedApplicationMaintenance, ApplicationInstallation, ApplicationUnresponsive, ApplicationUnstable, SecurityIssue, LossOfNetworkConnectivity .Parameter Comment Allows you to type a comment about the maintenance activity. .Parameter EventLog Writes information to the "Operations Manager" Eventlog to track what is happening. .Link http://blogs.technet.com/stefan_stranger#> #requires -version 2.0 [CmdletBinding(SupportsShouldProcess=$true)] param ( [Parameter(Mandatory=$True, ValueFromPipeline=$True, ValueFromPipelineByPropertyName=$True, HelpMessage='What is the ComputerGroup you want to put in Maintenance Mode?')] [Alias("Group")] [string[]]$ComputerGroup, [Parameter(Mandatory=$True, ValueFromPipeline=$false, ValueFromPipelineByPropertyName=$True, HelpMessage='Specifies the time the maintenance will end. The minimum amount of time a resource can be in maintenance mode is 5 minutes. This is a required parameter')] [int]$EndTime, [Parameter(Mandatory=$False, ValueFromPipeline=$True, ValueFromPipelineByPropertyName=$True, HelpMessage='UnplannedOther, PlannedHardwareMaintenance, UnplannedHardwareMaintenance, PlannedHardwareInstallation, UnplannedHardwareInstallation, PlannedOperatingSystemReconfiguration, UnplannedOperatingSystemReconfiguration, PlannedApplicationMaintenance, ApplicationInstallation, ApplicationUnresponsive, ApplicationUnstable, SecurityIssue, LossOfNetworkConnectivity')] [string]$Reason, [Parameter(Mandatory=$False, ValueFromPipeline=$True, ValueFromPipelineByPropertyName=$True, HelpMessage='Allows you to type a comment about the maintenance activity.')] [string]$Comment, [switch]$EventLog ) set-strictmode -version latest $start=Get-Date $currentlog = $start.ToString() Write-Verbose "Starting $($myinvocation.mycommand)" Write-Verbose "Ready to put ComputerGroup $ComputerGroup in Maintenance Mode" Function Start-SCOMMaintenanceModeForGroup { <# .SYNOPSIS Sets a SCOM Group in Maintenance Mode .DESCRIPTION Sets the members of a SCOM Group in Maintenance Mode .EXAMPLE Start-SCOMMaintenanceModeForGroup -ComputerGroup "All Windows Computers" -EndTime 10 -Reason "UnplannedOther" -Comment "Testing Maintenance Mode" -Verbose .PARAMETER ComputerGroup The SCOM Computer Group name for which members you want to put in Maintenance Mode. .PARAMETER EndTime Specifies the time the maintenance will end. The minimum amount of time a resource can be in maintenance mode is 5 minutes. .PARAMETER Reason Specifies the reason for placing the resource into maintenance mode. Valid values are: UnplannedOther, PlannedHardwareMaintenance, UnplannedHardwareMaintenance, PlannedHardwareInstallation, UnplannedHardwareInstallation, PlannedOperatingSystemReconfiguration, UnplannedOperatingSystemReconfiguration, PlannedApplicationMaintenance, ApplicationInstallation, ApplicationUnresponsive, ApplicationUnstable, SecurityIssue, LossOfNetworkConnectivity .Parameter Comment Allows you to type a comment about the maintenance activity. .Link http://blogs.technet.com/stefan_stranger #> [CmdletBinding(SupportsShouldProcess=$true)] param ( [Parameter(Mandatory=$True, ValueFromPipeline=$True, ValueFromPipelineByPropertyName=$True, HelpMessage='What is the ComputerGroup you want to put in Maintenance Mode?')] [Alias("Group")] [string[]]$ComputerGroup, [Parameter(Mandatory=$True, ValueFromPipeline=$false, ValueFromPipelineByPropertyName=$True, HelpMessage='Specifies the time the maintenance will end. The minimum amount of time a resource can be in maintenance mode is 5 minutes. This is a required parameter')] [int]$EndTime, [Parameter(Mandatory=$False, ValueFromPipeline=$True, ValueFromPipelineByPropertyName=$True, HelpMessage='UnplannedOther, PlannedHardwareMaintenance, UnplannedHardwareMaintenance, PlannedHardwareInstallation, UnplannedHardwareInstallation, PlannedOperatingSystemReconfiguration, UnplannedOperatingSystemReconfiguration, PlannedApplicationMaintenance, ApplicationInstallation, ApplicationUnresponsive, ApplicationUnstable, SecurityIssue, LossOfNetworkConnectivity')] [string]$Reason, [Parameter(Mandatory=$False, ValueFromPipeline=$True, ValueFromPipelineByPropertyName=$True, HelpMessage='Allows you to type a comment about the maintenance activity.')] [string]$Comment, [switch]$EventLog ) Begin { Write-Verbose "Starting Function Start-SCOMMaintenanceModeForGroup Function" #Check for minumum Maintenance mode period of 5 mins. if($endtime -lt 5) { Write-Error "The time span for the maintenance mode should be at least 5 minutes." -ErrorAction Stop } Write-Verbose "Following Group Members will be put in Maintenance Mode:" $ComputerGroupMembers = Get-SCOMMonitoringObject -DisplayName $ComputerGroup if($ComputerGroupMembers) { #$ComputerGroupMemberNames = ($ComputerGroupMembers.getrelatedMonitoringObjects() | select DisplayName).DisplayName $ComputerGroupMemberNames = ($ComputerGroupMembers.getrelatedMonitoringObjects() | select DisplayName) Write-Verbose "$ComputerGroupMemberNames" #Retrieve Management Servers so we can check if we don't put Management Servers in MM. $MSs = Get-SCOMManagementServer } else { Write-Error "No Members of ComputerGroup $ComputerGroup found" -ErrorAction Stop } } #End Begin Process { #Put Agents in Maintenance Mode foreach ($agent in $ComputerGroupMembers.getrelatedMonitoringObjects()) { Write-Verbose "Checking if ComputerGroup Member $agent is not a Management Server" if(($MSs | Select DisplayName) -eq $agent) { Write-Verbose "We don't want to put a Management Server in MM. Skipping" } else { Write-Verbose "Let's put Agent $Agent in Maintenance Mode" $Instance = Get-SCOMClassInstance -Name $Agent if ($PSCmdlet.ShouldProcess("Putting $Agent in Maintenande Mode for $($Endtime) minutes") ) { #Added 5 seconds to EndTime to prevent failing the Start-SCOMMaintenanceMode cmdlet. Min. 5 mins is needed. Start-SCOMMaintenanceMode -Instance $Instance -EndTime ([System.DateTime]::Now).AddSeconds(5).addMinutes($EndTime) -Reason $Reason -Comment $Comment }#End of whatif }#End of else }#End Foreach if ($PSBoundParameters['EventLog']) { write-eventlog -LogName "Operations Manager" -Source "OpsMgr SDK Service" -EventID 999 -message "The following Objects are put into in Maintenance Mode for $($EndTime) minutes: $($ComputerGroupMembers.getrelatedMonitoringObjects())" }#End if } #End Process End { Write-Verbose "Finished Function Start-SCOMMaintenanceModeForGroup Function" } } #Main try { if ($PSBoundParameters['EventLog']) { write-eventlog -LogName "Operations Manager" -Source "OpsMgr SDK Service" -EventID 998 -message "The $($myinvocation.mycommand) is used to put Objects in Maintenance Mode" } Write-Verbose "Checking if OperationsManager Module is loaded" #Check if OperationsManager Module is loaded. if(!(Get-Module OperationsManager)) { Write-Verbose "Importing OperationsManager Module" Import-Module OperationsManager -ErrorAction Stop } Write-Verbose "Checking for OM2012 environment" #Check if OM2012 is being used. if(!(Get-Module OperationsManager).Description -eq "Operations Manager OperationsManagerV10 Module") { Write-Error "This script is only for OM2012" } #Call Function if ($PSBoundParameters['EventLog']) { Start-SCOMMaintenanceModeForGroup -ComputerGroup $ComputerGroup -EndTime $EndTime -Reason $Reason -Comment $Comment -EventLog } else { Start-SCOMMaintenanceModeForGroup -ComputerGroup $ComputerGroup -EndTime $EndTime -Reason $Reason -Comment $Comment } } #End Try catch [System.IO.FileNotFoundException] { "OperationsManager Module not found" $_.Exception.Message } catch { Write-Warning "Oops something went wrong" $_.Exception.Message } $end=Get-Date Write-Debug ("Total processing time {0}" -f ($end-$start).ToString()) Write-Verbose "Ending $($myinvocation.mycommand)"
You can use the Get-Help Get-SCOMMaintenanceModeForGroups.ps1 –full command in PowerShell to see the complete help for this script.
Example using the –WhatIf switch
Let’s do the real deal and put some members of my “Stefan – OM2012 Maintenance Computer Group” in Maintenance Mode for 5 minutes.
Result:
How do use this cool PowerShell script to schedule Maintenance Mode using the Task Scheduler?
Steps:
Save script as: D:\Scripts\OM2012\Start-SCOMMaintenanceModeForGroups.ps1
Open TaskScheduler (on OM2012 Management Server or where you have installed the Operations Manager Console)
Create a new Task
Enter Name and make sure the user account under which the Scheduled Task is running is having enough permissions in SCOM. Select Run with Highest privileges.
Configure Trigger
Add action
Program/script: powershell.exe
Add argument (optional): D:\Scripts\OM2012\Start-SCOMMaintenanceModeForGroups.ps1 -ComputerGroup 'Stefan - OM2012 Maintenance Computer Group' -EndTime 5 -Reason "UnplannedOther" –Comment 'Testing MM' -Eventlog
Remark: Make sure you use single quotes of ComputerGroup, Reason or Comment Parameters if space are being used in the name.
Enter Credentials
If you have scheduled to script using the EventLog Switch toy can look in the Operations Manager Eventlog for auditing info.
You can download the script from the Script Center Repository: http://gallery.technet.microsoft.com/scriptcenter/Put-OM2012-Computer-Group-43902672
Wow, that is a cryptic blogtitle Did I already lost you people with this blogpost title? I hope not, because this blogpost is about how to use the Get-SCOMAlert Cmdlet using the Criteria parameter the correct way.
Credits for this blogpost go to my colleague Jens Morawietz, because he explained the implications of using the Get-SCOMAlert Cmdlet with the Criteria parameter to me.
Let’s first start at looking at the help for the Get-SCOMAlert Cmdlet.
If we look at the Examples for this Cmdlet we don’t find much information about the Criteria Parameter
So let’s explore the Criteria Parameter.
If we want to retrieve all New Alerts with a severity Critical and the Alert being generated by a Monitor we can use the following Command:
The reason we should use the Criteria parameter instead of filtering using the Where-Object Cmdlet is because of the impact on performance. If we use the Where-Object Cmdlet we first retrieve ALL Alerts before filtering.
Same result:
But if we compare the time it takes to complete both commands we see a difference.
Using the Criteria Parameter is much faster and less resource intensive.
Now we are convinced using the Criteria Parameter there is something you need to know when using this parameter and that is that the criteria parameter method will return only the alerts where the field is set to a value not equal to the given value and the PS method will return the alerts where the field is set to a value not equal to the given value OR is NULL, e.g.:
Let’s try to retrieve all New Alerts with a Severity Critical and the Alert being generated by a Monitor AND the Owner not being “Stefan”
We would think we could use the following statement to retrieve those Alerts:
But when we run these commands we see no Alerts being returned.
Wen we use the Where-Object Cmdlet we see that there are Alerts where the owner is not “Stefan”
Get-SCOMAlert | Where-Object {$_.ResolutionState -eq 0 -and $_.Severity -eq 2 -and $_.IsMonitorAlert -eq 1 -AND $_.Owner -ne "Stefan"}
So the resolution is to include OR <property> IS NULL in the criteria, which is in the end the WHERE clause of the SELECT statement on the Ops Mgr db, e.g.:
Get-SCOMAlert -Criteria "ResolutionState = 0 AND Severity = 2 AND IsMonitorAlert = 1 AND (Owner <> 'Stefan' OR Owner IS NULL)"
Btw, the last method is not only less resource consuming but much faster than the second one.
Have fun and thanks Jens for explaining.
Because Kevin Holman has not published a blog article on the latest release of the Update Rollup 3 for System Center 2012 for Operations Manager 2012 I thought why should not I do it this time
And to be honest this time was a little different then I’ve implemented updates in years. Why?
Because this UR3 is automatically installed via Windows Update if you have enabled Windows Updates on all your OpsMgr 2012 machines off course.
Let’s first have a look at what has been fixed in this UR3 for System Center Operations Manager 2012 (KB2750631)
Not that much has been fixed in the UR3 but we still want to check if our machines have these fixes installed and if we need to do some steps our selves.
How do I check if these fixes have been installed via Windows Update?
That’s pretty easy, just go to your OpsMgr 2012 servers and open Windows Update and have a look at the Update History
Let’s have a look at one of my Management Servers:
You can also use PowerShell if you want using the following commands:
Get-Content $env:windir\windowsupdate.log | Where-Object { $_ -like '*successfully installed*Update Rollup 3 for System Center 2012*'} | Foreach-Object { $_ | select @{L="InstallDate";E={$_.Split("`t")[0]}}, @{L="Description";E={$_.Split("`t")[16]}} } | Format-Table * -Wrap
And this is the result on my other Management Server:
You can also look at the file version for some of the updated files, just like Kevin showed you in his previous posts on Update Rollups.
Checking the updated files for the Management Server Role:
Get-ItemProperty -Path "c:\Program Files\System Center 2012\Operations Manager\Server\*.dll" | select -ExpandProperty VersionInfo | where {$_.FileVersion -eq "7.0.8560.1036"} | Format-List FileName, FileVersion
You should see files with a File Version of 7.0.8560.1036
This means that the Management Server UR3 update has been installed on this Management Server.
Checking the updated files for the Web Console Role:
Checking the updated files for the Console Role:
Checking if the following Management Packs are updated:
The Management Packs for UR3 can be found in the following folder:
C:\Program Files\System Center 2012\Operations Manager\Server\Management Packs for Update Rollups
In this folder you find the following Management Pack files:
Microsoft.SystemCenter.DataWarehouse.Library.mp (version 7.0.8427.1)
Microsoft.SystemCenter.Visualization.Library.mpb (version 7.0.8560.1036)
When you check if these Management Packs are already installed this does not seem the case.
So we need to install the latest Management Packs Microsoft.SystemCenter.Visualization.Library and Microsoft.SystemCenter.WebApplicationSolutions.Library from the UR3 update manually using PowerShell.
Remark: During one the previous Update Rollups my Microsoft.SystemCenter.DataWarehouse.Library.mp (version 7.0.8427.1) was already updated to version 7.0.8427.1.
PS C:\Program Files\System Center 2012\Operations Manager\Server\Management Packs for Update Rollups> Get-ChildItem -Filter *.mpb | Import-SCOMManagementPack -PassThru
Latest MPs have been installed.
Checking if the Agents are updated with the latest updates:
Check the Pending Management Pane for Agents that need an update.
Approve Agent using PowerShell
Now I only need to install manually the UR3 update on my Agent in my DMZ.
Have fun with UR3!
Links:
After posting some years ago a blog post with all the OpsMgr 2007 tools I thought it would be time for a new OM2012 Toolbox blog post.
The previous version 1.7 (that works with OpsMgr 2007 and 2007 R2) was released here. Version 2.1.2 has been updated to work with OpsMgr 2012, and now includes support for MPB files (MP Bundles) as well as the ability to Unseal and Unpack MP Bundles. Warning: only MP Bundles that contain a single ManagementPack are supported; there are some Service Manager MPBs that contain multiple ManagementPacks in a single bundle, and this tool currently cannot deal correctly with those.
This utility allows you to compare Management Packs between your Operations Manager and/or Service Manager environments.
Online catalog check is also available.
Changes in this version:
SCOMTypeView is a tool help MPAuthor visualize ManagementPackClass, ManagementPackRelationship, showing them in treeview. The most important, you can see how the specific MonitoringObject is connected with other MonitoringObject. This tool connect to your local ManagementGroup, showing real data in time.
Coretech XML Connector for SCOM 2012
The Alert Update Connector can modify alert custom fields with additional information useful for situations like controlling alert forwarding to incident management systems and help reduce noise in the incident creation process.
In OpsMgr 2012, we provided users the ability to create customized dashboards using the OpsMgr 2012 console. The GTM.exe tool provided in this blog allows you to build off these dashboard investments, in particular we allow you to accomplish three specific tasks that you cannot do via the console.
1. Turn IT Pro Console created dashboards into shippable MPs by stripping out management group specific parameters (removes MG GUIDs from dashboard MPs)
2. Provides the ability to have a custom dashboard show up under any Management Pack folder in the Monitoring view.
3. Have a custom dashboard be launched from the task pane when you pick a specific computer or object.
Let me please know if I’m missing some other great OM2012 tools.
We are very happy to announce the first DuPSUG meeting. This will be held at Master IT in Eindhoven (The Netherlands) on Friday the 23th of November at Master IT in Eindhoven (Netherlands). The speakers and their sessions are:
Speaker: Ed Wilson About: Ed Wilson, MCSE, MSCBA, MCT is the Microsoft Scripting Guy. As such, he writes the popular Hey Scripting Guy blog for Microsoft, speaks at conferences such as TechEd and TechReady. He is very active in the community and has spoken to numerous user groups around the world via Live Meeting and in person. Ed has written numerous books about VBScript, WMI, and Windows PowerShell scripting and his latest release is Windows PowerShell 2.0 Best Practices. In addition he wrote all the scripts for the Windows Vista, Windows Server 2008 and Windows 7 Resource kits. Ed lives in York, South Carolina and Ed has been with Microsoft since 2001. Prior to becoming the writer of the Hey Scripting Guy blog Ed taught scripting workshops worldwide to Microsoft Premier customers. Session: Using Windows PowerShell 3.0 to manage the remote Windows 8 workstation Description: There are four different ways to manage a remote Windows 8 workstation. The first is to use WMI remoting, the second is to use the computername cmdlets, the third is to use WinRm and Windows PowerShell native remoting, the last way is to use the CIM cmdlets. Each approach has advantages and disadvantages for the network administrator. In this session, I will examine each approach, and provide a checklist of criteria to aid the enterprise network administrator in choosing the appropriate technology for a variety of real world scenarios. This presentation combines live demo’s and interactive discussion to heighten learning.
Speaker: Richard Siddaway (PowerShell MVP) About: Richard has been working with Microsoft technologies for 25 years having spent time in most IT roles including analyst-programmer, server administration, support, DBA and architect. He has been interested in automation techniques (including automating job creation and submission on mainframes many years ago!). Richard has been using VBScript and WMI since it became available on NT 4. PowerShell caught his interest when he first heard about it and has been using it since the early beta versions. Richard’s blog is mainly about PowerShell. He founded the UK PowerShell User Group back in 2007 and he is a PowerShell MVP. Richard has given numerous talks on PowerShell at various events in the UK, Europe and the USA. He is a frequent speaker for PowerShell user groups worldwide and has had a number of articles on PowerShell published including expert commentaries on the Microsoft Scripting Games for which he has been a judge for the last three years. Richard has written two PowerShell books: PowerShell in Practice (Manning 2010) and PowerShell and WMI (Manning 2012). A further title PowerShell in Depth will be published towards the end of 2012 he’s currently writing an introductory book for Active Directory administrators that features PowerShell. Session: PowerShell and WMI Description: PowerShell and WMI are two great technologies that get even better when used together. Windows Server 2012 and Windows 8 introduce a whole new level of WMI – 60% of the PowerShell functionality in Windows Server 2012 is based on WMI! In this session Richard Siddaway, PowerShell MVP and author of the book ‘PowerShell and WMI’ will show you some of the the amazing things that are possible with PowerShell v3, Windows Server 2012 and Windows 8.
Speaker: Bert Wolters About: Bert Wolters is a Microsoft Certified Trainer with Master it Training. He focuses mainly on Virtualization, System Center products and Windows Server and client Operating Systems. Right after the Build Windows 8 conference in September 2011 he toured the Netherlands with knowledge talks about this new exciting product. Since he discovered the renewed Integrated Scripting Environment in Windows 8/Server 2012 he is convinced Powershell can make the professional life of any ITPro easier and more effective. Session: What’s new in PowerShell 3.0 Description: All of the new stuff demo’d and discussed in xx minutes… Powershell with Hyper-V? It’s in here… Remotely running powershell commands on a set of remote computers? We’ll cover that too. Want to run parallel and sequenced commands? We’ve got a Powershell workflow for you. Are you the IT guy that’s always travelling around and can only access the server through the web? Powershell Web Access is your thing! We’ll cover all of this and show you “Robust Session Connectivity” and the renewed Integrated Scripting Environment too… I’m sure this will inspire you to use Powershell on even more occasions than you imagined you could use it until now.
Speaker: Stefan Stranger About: Stefan Stranger is a Senior Premier Field Engineer at Microsoft Netherlands and is specialized in System Center Operations Manager and PowerShell. He likes to use PowerShell on the systems on which he works to manage, and where possible to automate the management. He shares his knowledge on his Technet Blog (http://blogs.technet.com/stefan_stranger). You can find him on twitter under @sstranger. Session: Protect your PowerShell scripts with version control Description: Software developers would not have to think about working on a project without some form of version control. So why is this so unusual for the IT Professional who is responsible for maintaining PowerShell scripts containing hundreds of lines of scripts? Version control or source control are terms used for the practice of tracking changes in the source code. There are several tools that can help you implement version control like GIT, Mercurial and Team Foundation Server. This session explains how you can protect your PowerShell scripts with Team Foundation Server (TFS) for version control. After this you will never have to worry that you do not copy your script after you had made so many changes in your script had made it no longer works.
Speaker: Jeff Wouters About: Jeff is a freelance Technology Specialist at Methos IT with a main focus on Hyper-V, System Center and has a great passion for PowerShell. Early 2012 Jeff started the Dutch PowerShell User Group, is an active Tweeter / blogger and speaker at IT events such as E2E Virtualization Converence, BriForum and NGN (Dutch). Session: From command, to script, to function, to advanced function, to tool. Description: Would it not be easy and cool to create your own cmdlets and/or tools? This session will be all about using your commands and oneliners to create scripts, go from those scripts to functions and as the final step to create advanced functions or even tools.
There are only 34 tickets left for this great PowerShell meeting, so hurry and register before it’s too late!
You all have installed Cumulative Update Rollup 2 (UR2) for OpsMgr 2012, right? If not just follow the steps Kevin described in his blogpost. After installing the UR2 on your agents you want to check if the patches are installed on all your agents.
You can just use the following PowerShell command to have a clear overview of the installed patches sorted by PatchList name.
Today I needed to check the SPN’s for my OM2012 environment and (again) I used some other blogs to confirm my SPN settings. Some of the blogs I always check are the following:
References:
This should really help you configure and check your configured SPN settings. But I also created a visual representation how you could check your own SPNs.
Hope this all helps configuring:
Today I installed Audit Collection Services (ACS) in my demo environment and after installing the ACS Collector and ACS Forwarder I wanted to start the AdtAdmin.exe tool. But where is AdtAdmin.exe installed?
And how do I run it next time from any location I’m in my (PowerShell) Command prompt?
AdtAdmin.exe is installed in: C:\Windows\System32\Security\AdtServer folder.
Now I knew the path I just added the path the path environment variable using Powershell.
$env:path = $env:path + ";C:\Windows\System32\Security\AdtServer"
Have fun Auditing your security events!
But would not it be cool to have a PowerShell wrapper around AdtAdmin.exe? Anybody?
In OpsMgr 2007 we had the option to create a RSS Feed for Alerts using the Operations Web Console.
Selecting the RSS button would return the following RSS Feed info.
In System Center 2012 Operations Manager (OM2012) we don’t have that option anymore. But this is not really an issue, because with a little bit of PowerShell magic, we can create our own OM2012 Alert RSS feed with all the Alert information we want. And that is exactly what I did when I saw an internal question about this feature missing in OM2012.
Environment information:
What is PowerShel PipeWorks?
PowerShell Pipeworks is a Framework for making Sites and Services with Windows PowerShell. Read more about Pipeworks here.
Installation steps for creating an OM2012 Alert RSS feed
1. Download PowerShell PipeWorks Module. 2. Copy Module to Management Server where you have installed:
3. Unblock PipeWorks.1.0.2.6.zip file before extracting (you can also use the PowerShell v3 unblock-file Cmdlet if you have PowerShell v3 installed)
4. Extract the PipeWorks Module to your default PowerShell Module folder. You can check the default folders where PowerShell is looking for PowerShell modules using the following PowerShell command:
I personally have created a D:\PowerShell\Modules folder to store the PipeWorks Module and added that path to my psmodulepath variable. You can add a new Module Path using the following Command in PowerShell:
5. Create an IIS Application Pool for PipeWorks Change the Identity of the Application Pool to use the OM2012 SDK Account (Microsoft System Center Data Access Service account).
6. Add PipeWorks Application
Enter Alias and Select previously created Application Pool. Enter Physical Path where to store the later to be created OM2012 RSS Alert files. Create Folder PipeWorks (C:\inetpub\wwwroot\PipeWorks) if that folder does not exist.
And configure the OM12_SDK Account to connect as configuration.
And finally Test Connection.
7. Use PipeWorks Module to create an OM2012 Alert Web Service, which we can use as an RSS Feed. a. Open PowerShell ISE b. Load PowerShell PipeWorks Module in PowerShell ISE.
c. Create the following Function in the PowerShell ISE:
function Get-MySCOMAlert { <# .Synopsis Shows SCOM Alerts .Description Shows SCOM Alerts for OM2012 .Example Get-MySCOMAlert .Example Get-MySCOMAlert -ResolutionState New .Example Get-MySCOMAlert -ResolutionState Closed #> [CmdletBinding()] param ( [Parameter(Mandatory=$True, ValueFromPipeline=$True, ValueFromPipelineByPropertyName=$True, HelpMessage='What is the ResolutionState of the Alerts you want to filter on?')] [string[]]$ResolutionState, [int]$First=50 ) process { if(!(Get-Module OperationsManager)) { Import-Module OperationsManager } #To convert string ResolutionStates to integers switch ($ResolutionState) { New {[int]$ResolutionState = 0} Closed {[int]$ResolutionState = 255} default {return "$($ResolutionState) is unknow ResolutionState"} } #end Switch Get-scomalert -ResolutionState $ResolutionState | sort -Property TimeRaised -Descending | select Severity, Priority, Name, TimeRaised -First $First } #end Process }
We can test the Function by selecting the function and hitting F8 Running the following command: Get-MySCOMAlert -ResolutionState "New" -First 2 returns the latest 2 OM2012 Alerts with ResolutionState New.
d. Convert Function to PipeWorks Web Service by running the following PipeWorks Command:
e. Check the Web Service in your Web browser by running the following command from the PowerShell ISE
You should see something like this:
You can now test the Get-MySCOMAlert Web Service by entering a ResolutionState and First (number of Alerts you want to return) Result:
8. Retrieve RSS feed URL. Now we have created the Get-MySCOMAlert Web Service we can add some parameters to retrieve the RSS Feed for the OM12 Alerts.
This will return the RSS Feed for all OM2012 Alerts with a ResolutionState of new and only shows the last 2 new Alerts.
Have fun and let me know some other cool things you have created using PowerShell PipeWorks!!
DISCLAIMER: THIS PROGRAM SOURCE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY REPRESENTATION OR CONDITION OF ANY KIND EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO CONDITIONS OR OTHER TERMS OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. THE USER ASSUMES THE ENTIRE RISK AS TO THE ACCURACY AND THE USE OF THIS PROGRAM CODE OR RESULTING EXECUTABLE CODE
We have published a new blogpost on the System Center: Operations Manager Engineering Team Blog about SQL Server Collation Requirements.
“There has been quite a bit of confusion over the requirements for SQL Server collation for the various components of System Center. We didn’t make a coordinated effort here to make this as easy as it could and should be. The documentation has conflicts within itself in some cases. We will be cleaning up the documentation over the next few days so that it is consistent and clear. Since the documentation is still component focused, we want to take this opportunity to provide a holistic view of the SQL Server collation requirement across the suite. This will hopefully clear things up and over time it will become even clearer as we make changes in the product itself to be consistent on this requirement.”
Read more here.
Our Private Cloud team published a blog post about building a cloud with PowerShell!
“Windows Server 2012 introduces vastly improved Windows PowerShell support with over 2,300 cmdlets to manage just about everything in the platform. This means you can now use Windows PowerShell to automate all of the IT tasks around cloud datacenter management, starting from deploying your cloud infrastructure servers, through on-boarding virtual machines onto that infrastructure, and ending with monitoring your datacenter environment and collecting information about how it performs. Practically everything is automatable!”
We already knew everything is automatable using PowerShell :-)
Yesterday we published a new KBArticle about Operations Manager Maintenance Mode.
It explains everything you want to know about Maintenance Mode.
What is Maintenance Mode? Maintenance mode is a feature in Operations Manager to suspend monitoring of an object during regular software or hardware maintenance activities like Software Update installations, Hardware replacements, etc.