Tag: powershell

  • Powershell in a Month Day 8 – Objects: data by another name

    This is part of my Powershell Challenge, to learn more about PowerShell (PoSh) using the Learn Windows Powershell 3 in a Month of Lunches book by Don Jones.

    What are objects? I’ve always found that to be a hard question to answer if I’m talking to someone that doesn’t understand how to program. The explanation here is simple, relating each row of results to an object, and the entire result as a collection. It’ s a little simplistic, but it works for Powershell. The whole idea, really, is to understand that these objects have types (each field or column) and those types matter because they affect what we can do with the output of each part of a PoSh process.

    Get-Member is the big introduction here, to help you find out what the properties and methods are for these objects. I have the feeling this is handy because when things don’t work right and you are debugging, Get-Member (or gm) is probably very handy. The other commands that are introduced here and are handy are the SortObject (or Sort) and Select-Object (or Select). These are easy concepts for me, because the way they work, with multiple columns and ascending or descending (-desc) are very similar to SQL Server.

    Overall, it’s a short chapter, but I feel like it’s starting to be more useful. I can pick and choose, easily, which columns I want, sort them, and find the various ways I can interact with an object. The lab was easy, feeling more like writing simple T-SQL queries than anything else.

  • Powershell in a Month – Day 7 Adding Commands

    This is part of my Powershell Challenge, to learn more about PowerShell (PoSh) using the Learn Windows Powershell 3 in a Month of Lunches book by Don Jones.

    Post holidays, day 7 looks at the shell itself and adding in snap-ins and modules. I have to say that the first time I looked at Powershell was in SQL Server 2008 when there was a “mini-shell”, but I didn’t understand what the difference was. I’m sure I’ve read other explanations, but they didn’t make as much sense. Perhaps because I’m more focused this time on learning PoSh it made sense? Not sure.

    In any case. This chapter starts to explain, and emphasize, there is really only one shell for PoSh. This is in contrast to the earlier SQL implementation, but moving forward, everything will be in one shell. The various shortcuts you find for different Microsoft tools and features are the same shell with an “Import-Module” parameter passed in. This is the same way in which the MMC works, and it’s the same way that we often configure other tools, like SSMS and VS, which have add-ins.

    That’s interesting, and good to know. This means I can not only customize my PoSh environment, but I can set up custom environments that can be shared on all computers in an organization or group. That is one of the main concerns I’ve had with PoSh. If I change my environment on my laptop to do things, I need to be sure all the places I’ll deploy the scripts to have the same environment.

    The chapter also look at snap-ins and modules, which are different. In my earlier work with PoSh, the idea of snap-ins seemed to be a pain, almost like installing Perl on every machine. Snap-ins need to be pre-installed and registered on the computer to be added in. The examples in the chapter load the SQL Server snap-ins, though the chapter mentions that snap-ins are not the way forward. Modules are.

    Modules are more like self-contained items that do not need to be installed. They just need to be in the PoSh path (environmental variable) or loaded with the full disk path. If the modules exist in the PoSh environmental variable, then they are auto loaded.

    The rest of the chapter is really devoted to some practice with modules and loading them. There are brief sections that look at how you can pre-configure your own environment automatically with a configuration file that allows you to pre-load modules or specify settings. That can be handy, especially as you add a series of modules to your setup. That also seems like something that you might want to deploy to all servers, or all members of a team, in order to ensure that any scripts you have written will run.

  • Budget for Training

    I hope everyone had a great holiday season and is refreshed, ready to tackle the new year. Many of you might have made resolutions with the calendar change, and I’d urge you to consider making one more: a resolution to learn something new in 2014 related to your career.

    I’ve been tackling the Powershell Challenge for a little over a month now, and one of the things I’ve found to be problematic is scheduling. With vacation and the holidays, I haven’t had a set schedule in my life. More importantly, I hadn’t scheduled myself specific times to work on Powershell and fell behind in my challenge.

    Andy Warren, co-founder of SQLServerCentral, has a talk about building a professional development plan in which he notes that we need to budget both time and money for our plan. It’s important that you not only commit some time, but that you schedule it. You may also need some money, and you ought not to be afraid of investing in yourself, especially if you are looking to move into a new area, or find a new job.

    I haven’t done a great job of making time for my career over the last month, but I have realized that I need to do so. I am looking to schedule specific times on specific days to work on my skills over the next few months. My plan is to take 2 lunches a week and dedicate that time to working on PoSh. I’m hoping that putting myself on a schedule will help me focus and get through my challenge.

    I would encourage you, on this, the first full week of the new year, to take an hour or two and plan out your learning for the year. My recommendation is you pick at least two six week time periods across the year. During each of those periods, schedule 2-4 sessions a week to learn. They can be half hour to hour slots where you work on a specific skill and improve your knowledge. You could start with one of our Stairway series if you’re looking for ideas. Give yourself at least a week or two, and probably a month, between sessions to recharge. Be sure you are also looking out for opportunities to put your new skills to work throughout the year.

    You are responsible for your career, and today is the first day of the rest of your career.

    Steve Jones

    The Voice of the DBA Podcast

    Listen to the MP3 Audio ( MB) podcast or subscribe to the feed at iTunes and Mevio . feed

    The Voice of the DBA podcast features music by Everyday Jones. No relation, but I stumbled on to them and really like the music. Support this great duo at www.everydayjones.com.

  • The Powershell Challenge–Notes and Observations

    It’s been a month and a half in real time since I started the Powershell Challenge. In that time, I had a business trip and 9 days of vacation and the holidays that impacted the event. After a week of working on the book, I ended up sporadically getting back to it, partially as I lost the book for 2 weeks after vacation.

    I’m still working my way through it, and as my schedule stabilizes, I’ll get back to regular posts. However, I wanted to make some notes on the issues I’ve seen and the challenges of professional development (PD) from my own experience in the last month.

    Vacation is vacation

    For me, vacation is really vacation. I have tried hard across the last 10 years to learn to enjoy vacation and not work during that time. I rarely check emails, and if I do, I typically don’t respond. I also leave the computer closed most of the time.

    This means, for me, that professional development also gets stunted. There were times in the past where I dedicated some time to professional development while on vacation, but as my kids approach adulthood, and I mature, I have typically stopped doing that.

    You can choose to spend your vacation as you wish, but with time off for family visiting, skiing, and ranch projects, I didn’t do any PD.

    A Schedule Matters

    One of the challenges I face is that I have a hectic life. As a result, when I try to fit things into that schedule, something else gets moved. Across the last month, I’ve been making more of an effort to exercise on a regular schedule, and that’s often been at lunch. Unfortunately, that’s pushed off the Powershell Challenge more days than I’d like to admit.

    I need some routine and schedule, and the holiday season (Thanksgiving-New Years) was disruptive to me. I didn’t think it would be as much of a problem as it was. I thought I could just sit down for 30 minutes and I’d find the time easily.

    I was wrong.

    I need to schedule time to do this each day, and I’m looking to get back to that next week.

    Momentum

    In line with scheduling, I think momentum matters as well. Just as with exercise, if you put it off for a few days, it’s much easier to put it off for a few more days than it is to get back on track and back to work.

    When Thanksgiving intruded, I lost momentum. When I came back and was pressed for time, I put off a few lunches. When exercise became a bigger priority, I put it off even more.

    This is why I do regularly talk about scheduling some time to learn. I think once a month won’t work, though perhaps you can make once a week work. I suspect for me that I need to schedule more regular time, such as every 2-3 days or M-W-F and stick to it. I recognize a balance is important, and I’d likely do this for 4-8 weeks and then take a break for a few weeks before tackling something else.

    I’ll see if I can implement this in the new year.

    A Place

    This might not matter for many of you, but it does for me. I started the Challenge by sitting at the kitchen table with my laptop and the book.

    My desktop for the last year has been a standing desk, that has the keyboard and mouse lifted off the desk surface with boxes. However, there is no place for a book at my desktop. During the holidays, I rarely had my laptop open, and in fact it was often in the bedroom near the bed. Having a book open in bed, or at my standing desk, didn’t work.

    I need to use my laptop regularly with the book and that was an issue for me. I’ll get that back on track next week.

    Summary

    We do need to regularly improve our skills if we work in technology. Or medicine or engineering or law or accounting or a number of fields. Some fields make that easier, but in technology it is mostly up to each of us to motivate ourselves and find time.

    I encourage you to tackle something like my Powershell Challenge, but think about budgeting and scheduling time in order to succeed. I’d also encourage you to schedule in breaks in your life when you aren’t driven to move forward in some direction and just enjoy your life.