I Wanna Be Like You

orangutan Growing up, one of my favorite Disney movies was their adaption of The Jungle Book, and perhaps my favorite scene was King Louie’s production number “I Wanna Be Like You.” I think what really makes this song work is that we all have a desire to be like someone else, perhaps a role model or someone who is living a life you’d like to have. I’ve been living my life as an IT Pro for quite a while now and I must have crossed a threshold because I often am asked, “What can I do to become like you?” So I thought I’d share some thoughts on the subject.

First, let me state out right that what I do isn’t an easy way to make a living. I work for myself, from home and certainly put in more work hours than I would at a “normal” IT job. While working several projects at the same time, I am also developing future work plus dealing with all of the paperwork like invoicing, bookkeeping and taxes. Perhaps most importantly, I am able to do what I do because my family supports me and my wife has a good job with benefits. If you are the sole provider for your family, you might want to reconsider a life like mine unless you have substantial savings or lottery winnings.

Still with me? Ultimately I think if you want to pursue a career like mine it all comes down to reputation. I can only do what I do because I have spent years establishing a trusted name, reputation or brand. Whatever you want to call it. I did this by blogging, getting speaking engagements at conferences, finding opportunities to write online, contributing to forums. Anything that would demonstrate I was competent and trustworthy. Actually, it is more than that. You need to demonstrate to your community, that you are at the forefront based on quantity and quality of your contributions. That is the secret I think to becoming a Microsoft MVP, which I’m also frequently asked. Being an MVP definitely helps with your credibility and reputation, but it is a bit of a chicken/egg proposition. All I can tell you is that you have to put in the time demonstrating to your community and Microsoft that you are a valuable asset and a leader.

Today, social media is a much bigger presence than it was when I first started. You should be contributing valuable content on Twitter, Facebook, YouTube, Google Plus and more. This takes active work on your part and it will take time.

You also need to find avenues for more substantial efforts through writing, training, or presenting. There are many user groups looking for speakers. You can even start locally. Find places where you can contribute written material. It probably won’t pay much but it gets your name out there. Submit session proposals to conferences. Not comfortable speaking in front of people? Then create video clips and build a following. At the very least, blog and blog frequently. One important point about content: quality counts. It may seem obvious, but don’t post or create something that is a re-hash of a help document or something without explanation. The whole point about reputation is that you need to demonstrate that you know what you are talking about. So don’t post a blog entry with a 1 line PowerShell command. Explain it. How did you arrive at? What are the alternatives? Why is this a good solution? In some ways, this is like good customer service – you have to exceed expectations.

All of this takes time, probably even a few years. And even then, don’t expect to take 1 month vacation in the Caribbean every year and have a 6 figure salary. I’m not saying you can’t set that as a goal, but know that will take a great deal of time and work to reach that level. Personally, the journey has been just as rewarding as where I am now. I’ve met some terrific people along the way like Don Jones and Mark Minasi as well as IT Pros who have attended my conference sessions and training classes. I like what I do now and appreciate the flexibility of being able to work almost anywhere. But I had to pay my dues and you will too, but hopefully you now have a better idea of how much that will cost.

If you are starting down this path, I’d love to hear your story, your plan or any words of advice you have for others.

Friday Fun Reverse PowerShell

reverseThese Friday Fun posts are not supposed to be practical, yet hopefully still entertaining and educational. Today’s article is no exception but I ‘ll be you’ll try it at least once. And you’ll maybe even learn something about PowerShell that perhaps you didn’t know before. It all starts with a string. We use strings all the time for things like passwords and names. Let me start by explaining some basic concepts and then we’ll get to the fun stuff.

The string object has a number of methods, but I’m not going to use any of them today. Instead, I want to start by showing that the string is an array, or collection, of characters. This means you can access any element by its index number.

You can start at the end of the array with -1. You can also get several elements with the Range ( .. ) operator.

So, what about counting in reverse? We know we can start at -1. -2 would give us the 2nd to last element, -3 the third to last and so on. Therefore all we need to do is count backwards to the beginning.

I used the string length to know how far back to count. But wait, it gets better. Let’s bring in the -Join operator. This operator is designed to join elements of an array into a single string.

If you don’t want to specify a delimiter, you can use -Join like this:

See where I’m going with this? Let’s join the reversed array of string characters.

So if I can take any string and reverse it, why not reverse PowerShell? I created a function called Out-Reverse.

The idea is that you can run any PowerShell expression, pipe it to Out-Reverse, and you’ll get just that: reverse output.
out-reverse

The function takes any pipeline input and stores it in a temporary array. Once everything has been processed, the data is converted to a string with Out-String. Because I need to process each line separately, I split what would otherwise be a very long single string, into multiple strings on the end of line marker (`n).

$Text is now an array of strings and I can reverse each one.

It is kind of fun looking at reversed output. For you language geeks, this also makes a great palindrome tester.

Or maybe you need some simple obfuscation.

Actually, if you find a production-worthy use of this function I hope you’ll share it with me and the community. But as always I hope you picked up a PowerShell tidbit along the way that you can use in your “real” PowerShell work.

Enjoy your weekend. I’m sure you earned it.

Pimp your Prompt

bling2If you are like me and live in PowerShell, then you spend a great deal of your day looking at your PowerShell prompt. That little indicator in the console and ISE that usually shows where you are. That little part of your PowerShell world is defined by a built-in function called Prompt. You can easily see the function like this:

This prompt is from PowerShell v4 but I’m pretty sure it is the same function that was used in v3. PowerShell v2 has a different function.

Did you notice that the newer function has a help link? Try it:

help prompt -online

You’ll get the online version of the about_prompts help topic. The great thing about the prompt function is that you can change it. I’ve posted a variety of prompts over the years. But here are 4 more for you to try out. These prompts should work in v3 and later. Most of the functions are simple additions to the standard prompt and should work for both the console and ISE. To try out the prompt you can paste the function into your PowerShell session. To make it “permanent”, insert it into your PowerShell profile script.

Include PowerShell Version

This prompt inserts the PowerShell major version into your prompt.
version-prompt

Include Admin

This prompt will test if you are running as Admin and if so, it inserts [ADMIN] in red text.
adminprompt

Include Computername

Do you like how a remoting session shows you the computer you are connected to? Why not have that all the time? All I’ve done is insert the local computername from the Computername environmental variable.

computername-prompt

Auto Export Command History

This last version serves up a twist on transcription. When you run a transcript you get the command and results. But maybe all you want is a record of all the commands you ran. Sure, you could export command history at the end of your session, but you have to remember to do so and if you exceed your maximum history count, you’ll miss commands. In this prompt, everytime you hit enter, it gets the last command you ran and appends it to a log file. The log file is created in your PowerShell directory and uses the naming format of the PowerShell host, without spaces, a time stamp (YearMonthDay) and the process ID of the current PowerShell session. This allows you to keep multiple PowerShell sessions with separate logs. The log file will only record the command if it is different than the last one you ran. This also allows you to hit Enter without doing anything and not fill up your log.

If you temporarily paste in one of these Prompt functions, but don’t like it, you can simply restart PowerShell to get your original prompt. Or you can use this function to restore it.

This is handy to put into your PowerShell profile if you are experimenting with prompts. The Restore-Prompt simply defines a new Prompt function in the global scope. I’m using the default PowerShell prompt but you change it to whatever you wanted.

If you are doing something cool with your prompt, I hope you’ll share.

Advice, solutions, tips and more for the lonely Windows administrator with too much to do and not enough time.

%d bloggers like this: