in

code4ward

code4ward.net

information technologies | consulting | development
  • Availability

    The last couple of days I am experiencing major outages. My provider has big troubles to stabalize my line. I hope that they get it done soon and I am also considering moving my site somewhere else.

    Does anyone know a good hosting company?

  • Royal TS 1.5

    It's (almost) done! "Why almost?" you may ask. I just released Royal TS 1.5. Yes

    And this time a lot of things changed. Not only inside the App, also the way Royal TS 1.5 was built, tested and delivered. It was the first time that I organized a small "private" beta which was overwhelming. I got a lot of great feedback and a lot of very detailed bug reports. Thanks to all of you who helped with that.

    I also worked with a small but effective Sharepoint based bug database. It's nice to see what can be done with little effort.

    I asked a friend of mine who happened to be a graphics designer to give Royal TS a special look. If you ask me, it worked out great!

    The burger is gone! OMG - did you see that...

    Of course, besides the usual bug fixes, some great new features can be found in Royal TS 1.5. The release notes have all the details but here a short list of the most important ones:

    • Encryption: password protect the file when using the autologon feature
    • Read-only access to files: by assigning a read-only password you can give users the ability to use some predefined connections
    • Minimize to sys-tray
    • Experimental TS Gateway support
    • many more

    So why "almost" done? Huh?

    One planned feature was providing help. I prepared Royal TS for that help but writing all that stuff was completely underestimated. So clicking the help buttons is not very useful right now, but I will work on that...

    So, go ahead and download the latest bits: http://code4ward.net/cs2/files/folders/rts1/entry1548.aspx

  • Royal TS 1.5 Teaser

    In a couple of weeks Royal TS 1.5 will be released. So, let me tease you a bit...

    Royal TS 1.5 will sport strong encryption. You can (optionally) protect your .rts file with a master password:

    image

    Additionally some new options:

    image

    Possibility to filter for connected, not connected or all connections in the quick search panel:

    image

     

    So stay tuned...

    cheers

  • Royal TS 1.4.4 Released

    Just to growl it out to the world. Nothing really special or new in this release, only just minor bugs were fixed.

    cheers

  • Better Windows Service Monitoring with Operations Manager 2007

    CheckServiceState Script CheckServiceState Script

    If you ever wanted more control how to monitor windows services with Operations Manager 2007 you most likely realized, that you have to do it all by yourself with a custom script.

    I had at least two major problems which forced me to use a custom script:

    • It seems that you cannot monitor the status of a service which has the startup type set to "Manual". (There is a parameter in the overrides dialog called "Alert only if service startup type is automatic" but it doesn't have any effect, the health state simply doesn't change)
    • When using templates to monitor a windows service you cannot override the monitor to only monitor a subset of services using a group. The group just doesn't show up in the list

    So this is my approach to windows service monitoring:

    First of all, let's set up a Windows Service monitoring using the standard Management Pack Templates Wizard. In this example: "Print Spooler". In the monitoring wizard select or create a destination management pack, here: "Windows Service Monitoring".

    I use the template wizard because I can use the discovered service class to target my own script and I get all the other goodies (performance monitors, baseline rules, etc).

    After a while the service you just configured to monitor will be discovered. Now let's setup a group:
    Create a new group with a name like "Print Spooler Service Group" in the "Windows Service Monitoring" management pack. In this example I use explicit group members but you can also use dynamic membership of course. The beauty is, that your group can (and should) contain the discovered service instances:
    image

    Next, bring up the monitors the template wizard creates for us:
    image

    There you should see the (very inflexible and buggy) availability monitor:
    image

    Right-click on the "Service Running State" monitor and select "Overrides > Override the Monitor > For all objects of type: Print Spooler". In the Override Properties, disable the monitor (check "Override" for the Parameter Name "Enabled" and change the "Override Setting" to "False").

    Next, right-click on the "Availability" node and select "Create a monitor > Unit Monitor...". In the unit monitor dialog, select the "Scripting > Generic > Timed Script Two State Monitor" as monitor type and place it in the same Management Pack "Windows Service Monitoring".

    In the General properties page we can now target the script to the "Print Spooler" class. Also be sure to disable the monitor by default (We enable it later using a group override).
    image

    Pick a schedule which makes sense to you (I recommend every 5 minutes but depending on your environment I suggest that you don't go below 2 minutes).

    In the Script page, provide a script name, like CheckServiceState.vbs and paste the attached script into the script area.

    The script takes 3 parameters (documented in the script) but for a standard scenario you can just use:
    "$Target/Property[Type="MicrosoftSystemCenterNTServiceLibrary!Microsoft.SystemCenter.NTService"]/DisplayName$" "Running" "Auto"

    Because we already target the print spooler class we can use a dynamic parameter to pass on the service name. Parameter 2 and 3 (which is optional) can be used to define the desired status and startup type. Please be sure to encapsulate each parameter in double-quotes - just to be on the safe side.

    Next let's define the health expressions:
    image
    image
    image

    And finally the alert:
    image

    I suggest an alert description like:
    The state of the monitored service '$Target/Property[Type="MicrosoftSystemCenterNTServiceLibrary!Microsoft.SystemCenter.NTService"]/DisplayName$' on '$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$' is invalid: $Data/Context/Property[@Name='AlertText']$

    After you created your monitor, enable it using an override for the group we created earlier.

    As last (optional) step I suggest to create a state view containing the Print Spooler instances and scoped to the group where we enabled the monitor.
    image

    Of course, it would be much better if that functionality and flexibility is provided by OpsMgr out of the box...

    cheers

  • Merry Christmas and a happy, healthy and successful Year 2008

    2007 was a roller coaster ride: my business and work was all about monitoring and operations manager 2007. My personal life changed dramatically when my son got 2 little sisters in August. Now we are preparing all the gifts for our first Christmas as a gang of five!

    For 2008 I am considering to make a commercial (shareware) version of Royal TS or whatever it will be called. If I really do this, you can expect a first class, versatile and powerful tool! There will always be a free (maybe somehow limited) version and Royal TS will eventually just get bug fixes but no new features.

    Anyway, I wish you all nice and relaxing holidays.

    cu

    cheers 

  • Operations Manager Powershell Tasks

    Once again, a little post to share with you guys about Operations Manager Tasks - this time using Powershell. First a little background story: Current version of Operations Manager 2007 (SP1RC) has still some nasty bugs and it seems that especially the events view doesn't get much attention from the product team.

    The event view doesn't HTML-Encode the event description in the details pane. Which is bad if you have to look at events (published exceptions for example) with fragments of XML or HTML included. This information just doesn't appear in the preview pane.

    So, the first thing which came to my mind is: Ok, then. How about some kind of console task which executes a quick Powershell command to dump out the event details using the Get-Event Cmd-Let.

    Next Problem: You can create an event task and put a dynamic parameter $ID$ in it. However, starting the task using the actions pane on the right always passes the same ID (I guess the ID from the first event selected when the view gets loaded) to the task - regardless which event was selected!

    Lucky me, there is a workaround: When you execute the task using the Actions menu in the console, the task will always get the ID from the selected event.

    So, now the interesting stuff: How to setup such a task?

    • First create a console task for events using the authoring section in the console.
    • When defining the command, set the application to: C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe
    • Set the parameter to: -PSConsoleFile Microsoft.EnterpriseManagement.OperationsManager.ClientShell.Console.psc1 -NoExit .\Microsoft.EnterpriseManagement.OperationsManager.ClientShell.Startup.ps1;Get-Event -Id $ID$
    • Set the working directory to: C:\Program Files\System Center Operations Manager 2007
    • Finally, uncheck the "Display output when the task is run" checkbox

    That's it. Enjoy...

  • Royal TS 1.4

     So I did it...

    I just released Version 1.4 and I'm totally excited what my user base or any new user will think of this release. I hope I will get a lot of feedback.

     Have fun...
     

  • Set-NotificationForAlert

    In MOM 2005 it was easy to notify someone on specific alerts. SCOM 2007 - with it's subscription based system - cannot handle these kind of notifications. But the limitation is the user interface. Jakub from the SCOM 2007 product team released some very useful code which helped to implement a notification based on the alert name. One problem of Jakubs code is, that it's a C# program which is not very handy and that he creates most of the stuff in code which can be created with the UI.

    I translated the script to power shell, which should be much friendlier to use, deploy and let's you quickly tweak some settings. The code below works for me (at least working with email notifications), but I have to admit, I didn't test it that much. The script usage is pretty simple, but you have to do some stuff first:

    • Setup email notification
    • Create at least one recipient
    • The alert has to be raised at least once
    • Change the $RMS variable in the script to your root management server

    Then, just execute it in Power Shell: ".C:\Set-NotificationForAlert.ps1 "This is a test alert" "This is a test notification recipient"

    Parameter 1: The name of the alert

    Parameter 2: The name of the recipient

    ## check for parameters
    param(
    [string]$AlertName = $(throw write-host "You did not specify the -AlertName parameter."),
    [string]$NotificationRecipientName = $(throw write-host "You did not specify the -NotificationRecipientName parameter. Use the Get-NotificationRecipient command to get a list of all registered notification recipients")
    )
     
    $RMS = "RootManagementServerName"
     

    write-Host
    write-Host "Executing Set-NotificationForAlert.ps1 ..."
    write-Host

    ## prepare OpsMgr shell

    if ((Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.EnterpriseManagement.OperationsManager.Client'}) -eq $null) {
    Write-Host
    Write-Host "File OpsMgrV3.ps1 loaded."
    Write-Host "Initializing shell for operations manager..."
    Write-Host "Add Microsoft.EnterpriseManagement.OperationsManager.Client snap in."
    Add-PSSnapin Microsoft.EnterpriseManagement.OperationsManager.Client -ErrorAction SilentlyContinue -ErrorVariable Err
    if ($Err) { $(throw write-Host $Err) }
    }

    if ((Get-ManagementGroupConnection | Where-Object {$_.ManagementServerName -eq $RMS}) -eq $null) {
    Write-Host "Connect to Management Server: $RMS"
    New-ManagementGroupConnection $RMS -ErrorAction SilentlyContinue -ErrorVariable Err
    if ($Err) { $(throw write-Host $Err) }
    }

    if ((Get-PSDrive | Where-Object {$_.Name -eq 'Monitoring'}) -eq $null) {
    Write-Host "Create Monitoring drive from Provider."
    New-PSDrive -Name: Monitoring -PSProvider: OperationsManagerMonitoring -Root: \ -ErrorAction SilentlyContinue -ErrorVariable Err
    if ($Err) { $(throw write-Host $Err) }
    Write-Host "Operations manager shell initialized."
    Write-Host
    }

    Set-Location Monitoring:\$RMS

    $Alerts = Get-Alert | where {$_.Name -eq $AlertName}
    if ($Alerts.ProblemId -eq $null)
    {
    if ($Alerts.Count -gt 0)
    {
    $ProblemID = $Alerts[0].ProblemId.ToString()
    }
    else
    {
    throw write-host "No alert was found with the specified name"
    }
    }
    else
    {
    $ProblemId = $Alerts.ProblemId.ToString()
    }


    ## load SDK assemblies
    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.EnterpriseManagement")
    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.EnterpriseManagement.Configuration")
    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.EnterpriseManagement.ConnectorFramework")
    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.EnterpriseManagement.Monitoring")

    ## connect to management group
    $ManagementGroup = New-Object Microsoft.EnterpriseManagement.ManagementGroup($RMS)
    $ManagementGroup.Reconnect()

    $smtpAction = $ManagementGroup.GetNotificationAction("DefaultSmtpAction")
    $recipient = $ManagementGroup.GetNotificationRecipient($NotificationRecipientName)
    $config          = New-Object Microsoft.EnterpriseManagement.Administration.AlertChangedSubscriptionConfiguration([Microsoft.EnterpriseManagement.Administration.AlertSubscriptionConfigurationType]::Any)

    $config.Criteria = "<SimpleExpression><ValueExpression><Property>ProblemId</Property></ValueExpression><Operator>Equal</Operator><ValueExpression><Value>$ProblemId</Value></ValueExpression></SimpleExpression>"

    $config.ExpirationStartTime = Get-Date
    $config.PollingIntervalMinutes = 1

    $NewGuid = [System.Guid]::NewGuid()
    $NewGuid = $NewGuid.ToString().Replace('-', '_')

    $Subscription = New-Object Microsoft.EnterpriseManagement.Administration.AlertNotificationSubscription("STACustomSubscription$NewGuid", $config)

    $Subscription.DisplayName = $NotificationRecipientName + " - " + $AlertName
    $Subscription.ToRecipients.Add($recipient)
    $Subscription.Actions.Add($smtpAction)
    $ManagementGroup.InsertNotificationSubscription($Subscription)

     

    So, hopefully I can ease some pain with this...

  • Royal TS 1.4 Coming Soon...

    RTS14

    I got a lot of feedback recently about Royal TS, mostly about the .NET Framework 1.1 requirement. Because of my poor involvement in the Royal TS 2.0 project, I decided to dig out the "old" code base and do some dirty hacks to get some of your requested features out in the wild. So what changed?

    • Requires .NET Framework 2.0
    • User Interface Upgrade
      I got rid of all 3rd Party controls and used only built-in controls (except for the Remote Desktop Control of course)
    • No more duplicate connection names or folder names possible
    • Connection list when a folder or the document is selected
    • The connection list also features a search function
    • Bulk-Edit (includes the ability to re-apply credentials to multiple connections - which is handy when you changed the password)
    • Ability to send a message to a remote session and log off a remote session
    • Some basic logging (double-click on the status bar)
    • and more...

    So stay tuned, this beast will be released soon...

  • Just testing Windows Live Writer

    Page authoring

    Really, setting it up was a pain in the a**. I guess because it's still beta. However, I've done it and it's working - hopefully...

  • SCOM 2007 Audit Collector in Untrusted Location

    Clive Eastwood has an excellent article how to setup Audit Collector Service using certificate based authentication.

  • Short Downtime, Community Server Update...

    As some of you may already have noticed, code4ward was down for a couple of minutes. Now sporting a shiny, new Community Server 2007 installation and some minor design changes. A big Kudos to the guys at telligent for the great piece of software...

  • IE Dev Toolbar - downloading right now...

    Microsoft released their IE Add-On: Developer Toolbar

     

    Overview


    The Internet Explorer Developer Toolbar provides several features for exploring and understanding Web pages. These features enable you to:


    • Explore and modify the document object model (DOM) of a Web page.
    • Locate and select specific elements on a Web page through a variety of techniques.
    • Selectively disable Internet Explorer settings.
    • View HTML object class names, ID's, and details such as link paths, tab index values, and access keys.
    • Outline tables, table cells, images, or selected tags.
    • Validate HTML, CSS, WAI, and RSS web feed links.
    • Display image dimensions, file sizes, path information, and alternate (ALT) text.
    • Immediately resize the browser window to a new resolution.
    • Selectively clear the browser cache and saved cookies. Choose from all objects or those associated with a given domain.
    • Display a fully featured design ruler to help accurately align and measure objects on your pages.
    • Find the style rules used to set specific style values on an element.
    • View the formatted and syntax colored source of HTML and CSS.

    The Developer Toolbar can be pinned to the Internet Explorer browser window or floated separately.
  • Programmatic Group Membership Manipulation in SCOM 2007

    Someone might ask: why the heck do I need that? And yes, I never thought that I will need it but I learned that in SCOM 2007 a group is not always a group.

    Jakub Oleksy helped me to understand and solve my problem and I am happy to share this information with you.

    The problem is, that groups created by the web application wizard can not be tweaked using the UI in SCOM 2007. It's not possible to create a dynamic membership rule. It's also not possible to assign a subgroup to such a group. So having a lot of servers and a lot of web applications it's not really fun to pick every single server in every single web application.

    Here my workaround:

    • Create a web application using the wizard
      A group named after your web application with the suffix "watcher computers group" will be created
    • Create your own computer group using the UI and define a dynamic membership rule
    • Configure the script (the 3 lines at the beginning) and test (DO NOT RUN THIS UNTESTED IN PRODUCTION ENVIRONMENT!)

    This is just a proof-of-concept script to show how you can do stuff like this. According to Jakub there may be a fix in SP1 which enables you to utilize the group created by the web application wizard in a way to either create a dynamic membership rule or attaching a subgroup, or both.

    Disclaimer:
    USE THIS AT YOUR OWN RISK. I AM NOT RESPONSIBLE FOR ANY DAMAGE THIS SCRIPT MAY CAUSE. THAT SAID, HAVE FUN!

    PowerShell Source Code:

    $ManagementServer = "ServerNameHere!"
    $SourceGroupID = GetComputerGroupIDFromDisplayName("DisplayName of SourceGroup")
    $DestinationGroupID = GetComputerGroupIDFromDisplayName("WebAppName watcher computers group")
    
    if (CompareComputerGroupMembership($SourceGroupID, $DestinationGroupID) -eq 0)
    {
        SyncComputerGroupMembership($SourceGroupID, $DestinationGroupID, $ManagementServer)
    }
    
    function SyncComputerGroupMembership([string] $SourceGroupID, [string] $DestinationGroupID, [string] $ManagmentServer)
    {
        ## load SDK assemblies
        [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.EnterpriseManagement")
        [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.EnterpriseManagement.Configuration")
        [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.EnterpriseManagement.ConnectorFramework")
        [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.EnterpriseManagement.Monitoring")
        
        ## connect to management group
        $ManagementGroup = New-Object Microsoft.EnterpriseManagement.ManagementGroup($ManagementServer)
    
        ## build include list xml items from source group childs
        $IncludeListXML = ""
        $SourceGroupChilds = Get-ChildItem (Get-MonitoringClass | where {$_.Name -eq $SourceGroupID}) | Sort DisplayName
        foreach ($SourceGroupChild in $SourceGroupChilds) { $IncludeListXML = $IncludeListXML + ("<MonitoringObjectId>" + $SourceGroupChild.Id.ToString() + "</MonitoringObjectId>")}
    
        ## get destination group's discovery configuration
        $DestinationGroup = $ManagementGroup.GetMonitoringClasses($DestinationGroupID)[0]
        $Discovery = $DestinationGroup.GetMonitoringDiscoveries()[0]
        $DiscoveryConfiguration = $DestinationGroup.GetMonitoringDiscoveries()[0].DataSource.Configuration
    
        ## create new discovery configuration
        $NewConfiguration = ""
        if ($DiscoveryConfiguration.IndexOf("<IncludeList>") -lt 0)
        {
            ## include list present
            $Start = $DiscoveryConfiguration.IndexOf("<MembershipRules>") + 17
            $NewConfiguration = '<MembershipRule><MonitoringClass>$MPElement[Name="Windows!Microsoft.Windows.Computer"]$</MonitoringClass><RelationshipClass>$MPElement[Name="SC!Microsoft.SystemCenter.ComputerGroupContainsComputer"]$</RelationshipClass><IncludeList>'
            $NewConfiguration = $NewConfiguration + $IncludeListXML + "</IncludeList></MembershipRule>"
            $NewConfiguration = $DiscoveryConfiguration.Substring(0, $Start) + $NewConfiguration + $DiscoveryConfiguration.Substring($Start)
        }
        else
        {
            ## include list not present
            $Start = $DiscoveryConfiguration.IndexOf("<IncludeList>") + 13
            $End = $DiscoveryConfiguration.IndexOf("</IncludeList>")
            $NewConfiguration = $DiscoveryConfiguration.Substring(0, $Start) + $IncludeListXML + $DiscoveryConfiguration.Substring($End)
        } 
        
    
        ## set new discovery configuration
        $Discovery.Status = [Microsoft.EnterpriseManagement.Configuration.ManagementPackElementStatus]::PendingUpdate
        $Discovery.DataSource.Configuration = $NewConfiguration
        $Discovery.GetManagementPack().AcceptChanges()
        
    }
    
    function GetComputerGroupIDFromDisplayName([string] $GroupDisplayName)
    {
        ## returns the ID (name property) of the computer group specified by display name
        return (Get-MonitoringClass | where {$_.DisplayName -eq $GroupDisplayName}).Name
    }
    
    function CompareComputerGroupMembership([string] $GroupID1, [string] $GroupID2)
    {
        ## use this function to compare the membership of 2 computer groups
        ## 2 parameters, IDs of the groups to compare
        ## returns 1 if the membership of the groups is identical, otherwise 0
        
        $GroupID1Members = Get-ChildItem (Get-MonitoringClass | where {$_.Name -eq $GroupID1}) | Sort Id
        $GroupID2Members = Get-ChildItem (Get-MonitoringClass | where {$_.Name -eq $GroupID2}) | Sort Id
        
        $GroupID1MembersString = ""
        foreach ($Member1 in $GroupID1Members) { $GroupID1MembersString = $GroupID1MembersString + " " + $Member1.Id.ToString() }
    
        $GroupID2MembersString = ""
        foreach ($Member2 in $GroupID2Members) { $GroupID2MembersString = $GroupID2MembersString + " " + $Member2.Id.ToString() }
    
        if ($GroupID1MembersString -eq $GroupID2MembersString) { return 1 }    else { return 0 }
        
    }
More Posts Next page »
Copyright © by Stefan Koell | code4ward | All rights reserved
Disclaimer   Terms of Use   Privacy Statement  Imprint
Powered by Community Server (Non-Commercial Edition), by Telligent Systems