I could not pass the opportunity to blog about PowerShell for today’s T-SQL Tuesday hosted by Wayne Sheffield (b | t). I will be frank, I’m not a subject matter expert or pretend to be one on the Internet when it comes to PowerShell, but I enjoy trying to do new things with it.
I have found Powershell to be a great utility to me on a day to day basis to automate activities I repeatedly perform when I’m developing software. Being able to use the .Net Framework, I usually write ps1 scripts to prepare my databases when testing features I’m developing. I’ll make this short and sweet; I have one tip to share, and one script that might come in handy.
First of all, if you don’t do so already, you should customize your environment by adding a directory path to your scripts in your Environment Variables. If you don’t know how to do this, simply read this How To Add/Edit Environment Variables in Windows 7.
For Visual Studio users:
Now that you added scripts to your Paths, open Visual Studio and test a script in you scripts directory by calling the command on your Visual Studio Package Manager Console. The Package Manager Console is a Powershell console and will execute any Powershell command. I spend most of my day developing in C#, and I write PoSH scripts to assist me in preparing data when I'm running unit test to try code out. The best part, I simply use the Package Manager Console to execute the commands.
Lastly, I wanted to share a little script I been playing around with, and I did this for a session I wrote and presented in Albuquerque's SQL Saturday #183. The jist is, we all have that "squirrel" effect when searching exceptions or some solutions to your problems. I remember the days of green text and black screen, and spending time online was simple; you find what you are looking for and then you're out. It's not the case anymore, for instance, say you're started searching for "SQL Server CTE" examples and 45 minutes later realize you have been watching YouTube videos of kittens.
To resolve this productivity issue, I created a Stack Overflow text browser in PowerShell (pictured above). The code is simple, and it's online on my github. Utilizing Invoke-WebRequest, I search a query and return a number of question asked in plain text. Like the good old days, you select the question you want to read about and out returns the answers. I do this on my Package Manager Console when I'm working on Visual Studio. I hope some of you enjoy this little script and tip as I will work to improve it and add more features.
I did my first presentation to a technical community on January of last year. I since have presented at SQL Saturdays in Colorado Springs, Denver and Salt Lake City. I’ve presented database security and data driven web development topics for code camps in Denver, and done virtual conferences from Tucson, AZ. I did a small tour of user groups in Colorado Springs and Boulder, CO as well as Las Vegas, NV. This Saturday, we wrapped up SQL Saturday #169 and I’d say was my high point in since I began public speaking.
I called in the assistance of the "#SqlHelp" Twitter Hash tag today to ask the following questions:
Today's share are both words to live by, and programming patter design. As a developer, you must abide to the SOLID design priciples. I found this under the Creative Commons Attribution 3.0 and would like to share with you the "S" in SOLID, the Single Responsibility Principle by Uncle Bob. Without further adieu:
“I know that if war is the answer, we are still not asking the right question.” – Terry Greenblatt
Here is my presentation deck to my talk at the 2012 Rocky Mountain Tech Trifecta session "Develop a Quick and Dirty Web interface to your database: for the DBA and other non-developers". You can also download the code and databse code to this project from GitHub https://github.com/extofer/MUDBug
"Isn't it funny how day by day nothing changes, but when you look back everything is different." - C.S. Lewis
"To hear about something a thousand times is not as good as experiencing it once" - Ancient Chinese Proverb
I was thinking the other day that I pay no attention to how old I am anymore. I could say that I have to think about it when I’m asked how old I am. Today adds another notch to my years. I’ll allow you to guess my age:
- If I could go back in time and meet myself on Day one of my IT career, I would advise myself not to use VB 5.0.I can almost say I was an accidental developer – let me explain. I had a degree in Mass Communications and found myself interested in computers enough to land a job as a Layout Designer for a local newspaper. I began to dabble in HTML soon after as I was able to afford my first Packard Bell P1. When I left the world of Newspaper and Media, I took a job as a computer operator in the automotive industry and learned to use a product management application on MS Access. There were inconsistencies in the engineering department I worked in with our, *cough, cough* database and the data coming to us from an AS400 application networked from Detroit and Japan. So my curiosity took me to explore options and I discovered I could use VBA within Access, or Excel mind you, and create an ODBC connection to a datasource. All this was mind boggling and I resulted to learn programming and create our own application to connect to the Access data as well as the AS400 data. My first question was, “Where do I begin?” Seeing that I worked in the engineering department, I pursued advice from the engineers as they recommended C or Java (cerca 1997, 1.1 or 1.2). It was Visual Basic that caught my attention.STOP!!I wish I could have done that. It was pretty, it was easy, it was just the thing a newbie could have done. From that moment, I became a Visual Basic developer; luckily, there was .Net in the next three years. The problem was, old habits die hard. VB is not an OO language; it’s procedural and event driven. I spent most of my development going back to VB.Net during its inception or used C# as I did VB – event driven. Object oriented design and development was beyond foreign to me.Programming languages don’t make the programmer, but learning the right language where other major languages are derived from and are the foundation to pattern design, would be a good start. I develop in C# now, and have dabbled in PHP as well as Java. But learning Object orientation design and development took a reboot in my career. I am happy where I am now, but it could have been a shorter trip given the opportunity to go back in time and meet myself on Day One of my IT career.