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
Recent posts

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 &qu

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