Another post for me that is simple and hopefully serves as an example for people trying to get blogging as #SQLNewBloggers.
Working with results and manipulating them is always something I struggle with a bit in PowerShell. I’ve slowly been learning how to limit results to what I want and then save those out.
Recently, I was reading Learn dbatools in a Month of Lunches, and I learned something new. I can save results to the clipboard easily. Here’s an example:
Let’s say I want to get backups status. I’d run something like this, using the Get-DbaDbBackupHistory cmdlet:
I see results, but I might want to put this into a report or email that I send to others. I can certainly highlight this in the cmdline and copy it, but there’s an easier way.
I can pipe this to clip, and then I don’t see the results.
Then I can CTRL+V and paste this into notepad (or anywhere).
Super handy way to take information from the PoSh cmdline and ensure I get everything. Miss-highlighting when not paying attention has caused me problems before, especially when the results scroll off the screen. Highlighting a lot of information is hard, so using clip is a good trick.
This was a quick trick I learned while doing something else, so I decided to write a quick post. This took me about 5 minutes to put together.
You could do the same thing, showing how you’d use this in your job.