Category: Blog

  • A New Word: Mottleheaded

    mottleheaded – adj. feeling uneasy when socializing with odd combinations of friend and family, or friends and colleagues, or colleagues and family – mixing a medley of ingredients that don’t typically go together, which risks either watering down your identity into gray much or accidentally triggering some sort of explosion.

    Mixing groups of people from different situations has sometimes been a struggle for me. I’ve felt quite mottleheaded at times when I have people I work with in coaching, at Redgate, and from friends/neighbors/family. It seems that they can be very different people.

    I’m sure I’m overthinking this, but I’ve rarely invited different groups of people to the same place, precisely because I do worry that someone might not enjoy the time with those others. I know I’ve felt awkward at times at horse-related things for my wife. I don’t mind and am happy to support her, even if it’s strange for me.

    From the Dictionary of Obscure Sorrows

  • Parsing EXE Output in PowerShell

    I saw a post internally that asked this question: Anyone have a handy powershell script testing if the installed flyway version matches a specific string?

    That seemed simple, but getting program output from PoSh wasn’t something I’ve tried. So I tackled the challenge and this is what happened.

    Getting the Output

    The first thing I wanted to do was actually figure out what the output of checking the version was from the CLI. I looked at the help and noticed a version verb. When I run that, I see a bunch of lines of output.

    2024-09_0002

    A lot of output. I need to parse a bunch of strings, and then find a line.

    My first experiment was to run this to get a file with this output.

    flyway version > fwversion.txt

    Now, let’s parse this.

    Parsing Content

    It’s been awhile since I read stuff from a file, but I know Get-Content works to read the file. What about finding a line. I saw this post with an answer that noted Select-String can be used, so I decided to try that.

    Here’s a first cut of code:

    2024-09_0003

    That didn’t work. However, with some experiments, I tried this code:

    Get-content fwversion.txt | select-string 'Edition'

    That worked.

    2024-09_0004

    Now, I’ll assign that to a variable with this code:

    $a=Get-content fwversion.txt | select-string ‘Edition’

    Next, I’ll split this string by spaces into a new variable with this:

    $b = $a -split(‘ ‘)

    Then I can evaluate the various element of $b. You can see below the first and third elements are what I’m interested in. Really the third. Remember, PoSh is zero-based.

    2024-09_0005

    That let’s me parse the output, but I don’t want to save a file. Now on to the next step.

    Capturing the Output from a Program

    One of the things I know you can do in a PoSh ptompt is run a program. The redirection operator allows you to move output. When I tried it, I couldn’t quite get the output I wanted, but I did find this post that helped. With that, I ran this code:

    $a = & "flyway" --version  2>&1 | select-string 'Edition'

    This runs Flyway, captures the output in a stream and then uses the code above to find the right line. I assign this to a variable.

    Almost there.

    Adding a Parameter and a Test

    Since I want to call this from the CLI and pass i a parameter, I added a param() clause to my script and then a test that compares the version output from the flyway.exe to the parameter. That gest me this code:

    param(
        [string]$versionToCheck=""
    )
    $a = & "flyway" --version  2>&1 | select-string 'Edition'
    $b = $a -split(' ')
    if ($b[3] -eq $versionToCheck)
    { Write-Output("$($b) installed")}
    else {

    Write-Output(“wrong version – $($b) installed”)
    }

    
    

    Now I can call this from the CLI and check things. It works well. At least for now.

    2024-09_0001

    I am certainly not a PoSh expert, but this short script took me about 15 minutes to write with a little research. Then a little testing and I sent it off to the requester. Haven’t heard any complaints, so I’m hoping this actually works for them.

  • Monday Monitor Tips–Finding CUs for My Instance

    How can I quickly get a CU patch for a system that’s out of date? I’ll discuss that situation.

    You might think you get to patch every instance every few months, and you may be able to. But most of us have laggards in any decent-sized estate. Someone always wants to avoid patching, or skip patching on the day you’ve scheduled every other system.

    This is part of a series of posts on Redgate Monitor. Click to see the other posts

    Tracking Versions

    The Estate page in Redgate Monitor contains quite a few different views of your entire estate. This section is designed to aggregate data across all the systems you are monitoring. If I look at https://monitor.red-gate.com/Estate/Versions, I see this as a default.

    2024-08_0041

    This gives me an overview of what SQL Server versions I’m monitoring. As you can see, our test estate has a mix of versions, from 2008R2 through 2022 and one Managed Instance. The counts are in the pie chart, and we can see how many are up to date in the bars to the right of each version. As you can see, lots of our estate needs patching.

    I can also see at a glance for each version that the latest update is and its release date. The download link is a quick way to download the latest patch from Microsoft. We maintain this list and Redgate Monitor will update it on a regular basis.

    When I scroll down, I see the details of individual instances. These are grouped, though I can change that with the toggle in the upper left. For each instance, I have the name and the major version,

    2024-08_0042

    The current status and the latest patch are listed next to each other, with an icon and color coding that let’s me know I need to upgrade (yellow up arrow) or I’m patched (green checkmark). I once again have the latest patch, linked to the MS article as well as text that let’s me know how out of date I am.  You can see these patches are a month old. Auditors are potentially OK with that.

    2024-08_0043

    However, for my 2012 instances, I’m way out of date. No excuse for that. We keep these firewalled and protected, and they are available here only for demonstration purposes.

    2024-08_0045

    To the right of this we have our support dates. If a date is past, we mark it with a triangle to let you know that you have unsupported versions. That may or may not be an issue for your organization.

    2024-08_0044

    Summary

    This section of the Estate tab isn’t something I expect DBAs or sysadmins to check often, but I would schedule a reminder to do this quarterly. Knowing the state of our patching process is important, especially when there are security updates being released. We have had a few in the last year for SQL Server, and it is important to patch and apply those.

    Seeing not only the status, but having an easy download link makes this a very handy tab that I wish I’d have had in quite a few jobs during the 90s and early 2000s. If you haven’t checked your estate tab in Redgate Monitor, you might do that today.

    Redgate Monitor is a world class monitoring solution for your database estate. Download a trial today and see how it can help you manage your estate more efficiently.

  • A New Word: Fensiveness

    fensiveness – n. a knee-jerk territorial reaction  when a friend displays a casual interest in one of your obsessions.

    I think that some of us have some fensiveness about the things that we deeply care about if we worry about the friend taking a bigger interest or having more success when we do.

    I know I’ve felt fensiveness when I find a new game on mobile that I might enjoy and my wife sees it and is interested. Mostly because she’s a much better gamer and puts me to shame if we were really competing.

    We aren’t, but there have been times I’ve worked for a period of time to get to Level 100, and then my wife starts playing and is all of sudden 100 levels past me in a short time.

    From the Dictionary of Obscure Sorrows