Skip to main content

Posts

Script to move SQL Server System Database Files

One issue that can occur when using VM snapshots to back up a server with large database volumes is that the server gets paused when the snapshots are consolidated. We like to refer to this a "stunning" because it sounds worse, and it can cause really bad things if you are using clusters and/or availability groups. If a cluster node gets stunned for more than a few seconds, the other node will think that it needs to fail over. Additionally, when the stun is over, the node that was stunned comes back to life right where it left off, and if it was the owner when it was stunned, all this has to be sorted out, and honestly, after working with Microsoft Cluster for twenty years, you just don't want to put it in this situation unless there's no way to avoid it. So, your backup strategy changes, and you set your large volumes as independent disks so that they are ignored by the VM snapshots. This lets you backup the OS and any other small volumes without a stun. Your...

SQL Diagnostics Manager - Script to Disable Maintenance Mode on All Servers

We use Idera's SQL Diagnostics Manager and there is a defect where monitored servers are sometimes not taken out of maintenance mode as specified by the schedule. As a workaround, I wrote the following script that runs each morning to log which servers are in maintenance mode, and disables maintenance mode on all servers. The use of the -MMRecurring switch on Set-SQLdmMonitoredInstance disables maintenance mode and keeps the maintenance mode schedule enabled. add-pssnapin sqldmsnapin $LogFile = "D:\Jobs\DisableMaintenanceModeAll\MMEnabledLog.txt" # Log any servers that are currently in maintenance mode $MMEnabled = invoke-sqlcmd -serverinstance -Query "USE SQLdmRepository; SELECT InstanceName FROM MonitoredSQLServers WHERE MaintenanceModeEnabled = 1" if( $MMEnabled.ItemArray.Count -gt 0 ) { add-content -Value " " -path $LogFile add-content -Value "================================================" -path $LogFile add-content -Value ...

Dumb Things You Need to Know to PowerShell

OK--so I'm not much of a blogger, but as I've started working with PowerShell to write a lot of scripts, I'd like to document some of the pains that it caused. The script parser reads from top to bottom, and if it hasn't read a function before it's called, it won't find the function. Yeah, I know. Just like all of the quirks that I'll list here, I'm sure they had a good reason for making it work like that, but it was painful learning it. So you'll just need to put all of your functions at the top, and the part of the script that runs first is at the end of the file. Passing multiple parameters to a function requires no parentheses, and no commas. Yeah, so when you call a function that has more than one parameter, don't use parentheses, and delimit the parameters with spaces. foo param1 param2 parm3 Update PowerShell before you start coding. PowerShell is not updated by Windows Update, so you'll want to get the late...

Time For a Raise

So despite my innermost secret thoughts on blood donation that were posted earlier ( The Window Seat ), I decided to give a pint of my red honey for the greater good of society. In particular, the part of society that exists in my wallet. It turned out that the next time the Indiana Blood Center visited our office that they were giving away concert tickets to everyone that bled. I had no interest in the concert--I can't even recall what band it was for--but thanks to the magic of email, a black market for the tickets developed rather robustly. So I ended up making a cool $15 dollars, plus some raunchy comedy albums, which they were also handing out. Ah, but were that the end of the story. When I give blood I always get a bit light-headed and hot at the very end of the donation. As these feelings of unwellness once again began to wash over my vein-tapped body, I just laid my head back and tried to relax. The next thing I knew I was awakened by a voice calling my name rather urg...

Maine Event - Days Eleven and Twelve

See the photographic evidence. Wednesday sloshed into view with a nice downpour at the time we were loading up to head to Acadia National Park. We managed to get loaded up without getting too wet and hydroplaned our way northeast. The scenery between Wiscasset and Acadia is quite nice if you take US 1 instead of the interstate, so we enjoyed some nice views and gave the towns a once-over as we drove through. The tourism industry really starts to dig its heels in around Rockport and is in full blossom in Bar Harbor. Bar Harbor sits on the edge of Acadia and has an endless number of bed and breakfasts, hotels, restaurants, gift shops, galleries, and tour operators. It was about a 3 hour drive, so we ate lunch before we got to Bar Harbor. Our plan was to drive around Acadia, enjoy the views, and generally check things out before checking in at the hotel. We failed at this due to my faulty navigation--I didn't see that the eastern part of Park Loop Road is one way. So after driving t...

Maine Event - Days Eight, Nine, and Ten

Sunday morning brought more sunshine, so we puttered around the house a bit and then made a beeline for Popham Beach. The day went without much excitement other than Leigh finding a sand dollar about the size of a fifty cent piece. Emily once again had a fantastic time and even worked on her swimsuit modelling skills. We also flew my parafoil kite, which requires a good bit of wind to fly, but is extremely stable once it's up. Since we knew the secret of the beach, there was no mystery to the phenomena of the growing beach, but it was still super-duper. We knew this time to take our shoes to the island so we could explore a bit, so we tramped around it for quite a while. That was pretty much it for Day Eight. Day Nine didn't see much action of note until we headed to Portland to pick up Mamaw and Papaw Hinkle. After we loaded them up we stopped at L.L. Bean for a bit. They don't allow you to leave the state until you've made a purchase there. We drove down to the restau...

Maine Event - Day Seven

Put on your Internet seatbelt folks--it was another big day in Mid-Coast Maine! Now that we've been here for a full week, Leigh is warming up to the local wildlife. This is a Maine Coon cat--complete with three legs! We got our day started with a rousing parade in Wiscasset. It was a rather small parade, but it got the job done. I think the only things Emily really wanted to see anyway were the firetrucks, and firetrucks had they. Hunter's Breakfast & Lunch was well represented with one of the most elaborate floats. As you can see, the turkey got out for a bit of fresh air. By the end of the parade, the sun had once again made us aware of its presence, so we decided to swerve down to Popham State Beach. We visited this beach last November, and as you can guess it was much different at this time of year. It also held a surprise for us that we couldn't have imagined. As we were eating our lunch on the beach, I noted that the waves were coming from two directions. The brig...

Maine Event - Day Six

Today was the biggest and brightest yet of our wonderful stay here. We started off with a quick trip to Dunkin Donuts, which is a requirement to make any trip to New England complete. We were bringing our glazed portions back to the house, and my anticipation of consuming the sugary delight was so pervading my thoughts that I missed a turn. I decided to drive on just a bit as I knew that the road would end soon near Maine Yankee, the decommissioned nuclear power plant. And without much fanfare, that's just what it did, so we did a one-eighty. As we sported along we spotted a whitetail deer in the general area of right in the middle of the freaking road. The brakes were hit--nothing too extreme as there was no iminent danger. The deer completed its road-crossing endeavor, and as we continued on slowly I noted that the deer was apparently just as interested in us as we were in it. It was standing a few yards out in the woods and gazing back as if we had a carload of donuts or somethi...

Maine Event - Day Five

For those of you that might have had a concern based on my recent reports of the feline community entrusted to our care, we are happy to report that five out of the six furry beasts have been seen alive and well within the past 24 hours. One was on the roof of the porch, but apparently quite happy there as my effort to "rescue" him was rebuffed. The one that we haven't seen is a bit of a recluse, so we really don't expect to see him. Today started to a pitter patter of raindrops, but the weather never really got busy with making life miserable and it turned out to be a rather nice spin of the planet. We had planned to take it easy this morning at home with some pancakes (with authentic Maine maple syrup) and bacon lovingly prepared by T. Wallace Hinkle. We also worked on our Wii bowling and various strategies for coping with toddler temper tantrums. We sallied forth around 11:00 AM, headed for the botanical garden near Boothbay. Leigh had packed a picnic lunch so we e...

Maine Event - Day Four

Turns out that the animal running through the yard making freaky sounds was a fox. As we slumbered in our humble Maine cottage, we heard the sound again--my first thought was that there was a vicious chihuahua outside. So I got up and turned the front porch light on, and beheld a reddish fox trotting across the front lawn. If you've never seen a red fox relatively up close, they are quite beautiful. Their markings are striking, and they always look so clean. Their tails are quite bushy, and it's difficult to imagine how they manage to stay so well groomed as they're tromping through the forest. As our day started we noted with glee the lack of rain for a second day in a row! Our plan was to drive down to Boothbay Harbor to visit the Maine State Aquarium, so that's just what we did. We got there about 11:00 AM and enjoyed seeing a blue lobster, a very large lobster, and other aquatic creatures that dwell in the vicinity. They had a wonderful interactive tank where we cou...