powershell

PSPowerHour v1.0 Wrap-Up

Andy Levy
The first edition of the PSPowerHour is in the books and it looks like it was a big success. This one was dbatools-heavy but I chalk that up to the dbatools community having lots of free time because we’ve automated so many of our tasks :) Overall Impressions I signed in about half an hour ahead of the webcast and was the first one there. Shortly thereafter, I was joined by Michael Lombardi (twitter, then Jess Pomfret (blog|twitter) and Chrissy LeMaire (blog|twitter).

Speaking: PowerHour, August 21st 2018

Andy Levy
It’s official! I will be speaking at the inaugural PowerHour online lightning demo event on Tuesday, August 21st at 2200 UTC. I’ll be demoing Better, Safer SQL Queries from PowerShell. If you’re working with SQL Server from PowerShell, either as a DBA, analyst, or anyone else running queries, you’ve probably used Invoke-SqlCmd. But depending on how you’re building your queries, this can be error-prone or a huge security exposure! With the help of the dbatools module, I’ll show you how to write and run these queries better and safer - and make them easier to work into your scripts to boot.

PowerHour - Online PowerShell Lightning Talks!

Andy Levy
Earlier this week, the PowerHour was announced. What is it? It’s kind of like a virtual user group. One hour, 6(ish) lightning demos (10 minutes or less), centered on PowerShell. All community-sourced and driven - anyone can submit a proposal for a demo and if accepted, you’ll be slotted into an available spot. They’ve already set up a YouTube Channel so you can either watch live or catch up later on, and the whole deal is being organized and managed through GitHub.

Quick Table Info Export with PowerShell

Andy Levy
This week I had a user come to me asking about how fields were defined on a few tables he was using in writing some reports. Long story short, he’s been tasked with writing some new reports and updating existing ones, but he doesn’t have visibility to the database itself so he’s left with the “ok, let’s try this” approach and then reading error messages to debug when things go sideways.

Processing SQL Saturday Raffle Tickets with PowerShell

Andy Levy
Every year, I spend the Sunday after SQL Saturday Rochester scanning & processing raffle tickets for our wonderful sponsors. Here’s how the system works: Attendees get tickets (one ticket per sponsor) with their name, the sponsors name, and a QR code on them The QR codes represents a URI, unique to the combination of event, attendee and sponsor. Attendees drop their tickets in a box to enter the sponsor’s raffle prize drawing When the URI from the QR code is accessed, it registers in the SQL Saturday system Organizers run a report for each sponsor that includes the contact info of all attendees who dropped off a raffle ticket, then email the report to the sponsor It works pretty well, but the hangup is that most QR scanners will open your web browser (or prompt you to open it) to the URL on each scan.

My First Migration with dbatools

Andy Levy
I’ve been a proponent of dbatools for close to a year now and even contributed to the project, but surprisingly haven’t been a heavy user of it. Mostly due to a lack of opportunity. I’m aware of many of the functions by virtue of working on the built-in documentation and following the project and presentations about it. So when the need arose to move a development/test instance of SQL Server from a VM onto a physical server, I knew exactly what I wanted to do.

T-SQL Tuesday #94 - Automating Configuration Comparison

Andy Levy
This month’s T-SQL Tuesday is hosted by Rob Sewell and he’s posed the following question: What are you going to automate today with PowerShell? I’m cheating a little bit in that this is something I did a couple weeks ago, but it was immensely helpful. I’d been working on building out a new instance to migrate our test databases onto, but the developers had an urgent need to do some testing in isolation so they “borrowed” that new instance.

Spell-checking dbatools with Visual Studio Code

Andy Levy
Earlier this week I was working on adding a new feature to Update-DbaTools and while looking at another cmdlet to check syntax/conventions, I noticed an ugly typo in some of the help for it. 100% perfect prose isn’t necessary in the comment-based help for PowerShell cmdlets, but seeing misspellings and such kind of bugs me. Fortunately this is something I can help fix since the module is on Github. First I needed to find a spell-checker that works with Visual Studio Code to help me spot misspellings.

An Unexpected Side-Effect of Invoke-WebRequest

Andy Levy
Recently I was working on a bit of PowerShell to download the awesome First Responder Kit from Brent Ozar Unlimited. The canonical URL for the FRK is http://firstresponderkit.org/ but that’s a redirect to the GitHub repository where all the magic happens. I thought to myself: Self! Rather than take a chance on that GitHub URL changing, use the “main” URL and Invoke-WebRequest will take care of the redirect for you.

Adding Application Name to Invoke-SqlCmd2

Andy Levy
In a previous post, I expressed some frustration over Invoke-SqlCmd not setting an Application Name for its ODBC connection, leaving us with the generic .NET SqlClient Library when looking at active sessions in sp_who2 and sp_whoisactive (and any other monitoring tool). Unfortunately, I can’t really do anything about Invoke-SqlCmd aside from posting a suggestion on Connect or the Client Tools Trello board, but Invoke-SqlCmd2 has the same issue and that’s on GitHub.