Protip March: Quickly viewing logs with Powershell

Wow it feels like it’s been forever since I have posted.  I have been crazy busy with work stuff and am just now getting caught up with everything and have enough room to poke my head above the water and breath again finally.  We had a massive overhaul of our data center in mid February (among other things) and I am finally getting all the loose ends tied up from that project, including our brand-spanking new test environment which I am super excited about and which I will post about in the not so distant future.

Here is proof of some of our efforts just in case you don’t believe me 🙂

dc1

dc4

dc5

Anyway, getting back on track, I just discovered a slick way in Powershell to mimic the functionality of tail and tail -f in the Linux world.  If you have ever used tail then you know it is a great tool for monitoring log files or quickly looking at the end of a piece of code for example.

With the trick I’m about to show you, the same can essentially be done in Windows.  However, there are a few caveats.  For one, the syntax is a little bit different (if you want to change this just set up an alias).  The Powershell equivalent relies on the Get-Content cmdlet with the -Tail and -Wait flags to accomplish this task.

So in the following example I have instructed Powershell to look at the last 30 lines of the uploadpic.ps1 file and using the -Wait flag it will be updated as the file gets appended to.

Get-Content -path .\uploadpic.ps1 -Tail 30 -Wait

If you don’t care about viewing the file live then you can remove the -Wait flag and Powershell will simply grab the last N number of lines where N is 30 in our example.  30 seems like a good enough number in our example and can obviously be changed depending on your needs.  Easy enough for what I need it for.

Get-Content -path .\uploadpic.ps1 -Tail 30

As I mentioned, I will be going into a little more detail about some of the things I learned from our data center rebuild that I feel were some great lessons and good things to know/be aware of.   Standby for new contents as I get back to writing more blog posts and getting back up to speed on the writing side of things.

Read More

Are you sitting on an expensive disaster?

Those who have been following my posts will have spotted that occasionally I discuss something less technical. If that sort of thing bores you – look away now.

Everyone I’ve ever met who’s been in IT for any length of time – whether it’s as a technician, a sysadmin or a helpdesk operator – knows that this is a fast-moving industry and sometimes businesses get left behind.

Whether that’s the server that for some reason is still running Exchange 5.5, the PC with an IBM logo on the front that’s still running Windows 2000 or the sudden, urgent need to restore a backup from some obscure tape format that we thought had died out circa 2001.

And we get to pick up the pieces.

There’s a simple reason for this: as a profession, we’re fantastically good at spending money. We can easily spend half an hour on Dell’s website and our employer walks away £thousands lighter.

However, we’re fantastically bad at explaining why we’re spending the money or what benefit it’ll bring. Few of us buy a new car when the old one still meets our needs and it’s still economical to maintain, yet we provide equipment that’s more-or-less maintenance free and expect our employers to replace it while it still meets their needs just fine.

Upshot? We get to explain that yes, you can still buy Exchange. But no, you can’t easily upgrade the fifteen year old server in the corner to the latest version.

Solution? Explain what you want in terms the business will understand: it should either make money, save money or reduce risk. If you can’t think of at least one good reason based on one of these three, you probably shouldn’t be recommending the solution in the first place.

Read More

More tips for improvement

The previous post I wrote about becoming a better sysadmin, covering general points and tips for self improvement turned out to be more popular than I thought it would be (okay not really, but for me it was at least!).  So I decided to write a little bit of a follow up post in regards to general improvement and subsequently have decided to focus more of my time and effort on including more posts related to that type of content.  I find the topic of self improvement to be interesting and would love to write more about my findings, so I will be experimenting a little bit with these less technical pieces a little bit more I think. I would also like to hear what others have to say about these posts and the topic of self improvement so let me know.

While this post is primarily focused on self improvement this can easily be adopted to anybody in the IT industry that is just looking for a way to improve themselves and get better.  So while the hard skills (certifications, books, blogs, anything that specifically relates to a specific area) are incredibly important, why not throw in these general and well known strategies to help with your improvement?  I think the positive benefits will heavily outweigh the negatives in this scenario.

General Tips for improvement

These simple tips can go a really long way.  I read threads all the time about how to get better and how to improve mental capacity, blah blah blah and the following suggestions always seem to pop up.  What I have found to be true is that there is no magical instant way to improve yourself, I am learning that the hard way.  To me, the best way to see results and really work on yourself starts by changing your habits, working hard and being consistent.  That might not be what you are looking for, but trust me, these small tips can go a long way in becoming better at what you do.

Exercise – Time and again I hear and read about the massive benefits of proper exercise.  I did not take this advice seriously until just recently and can say that it has made a huge difference in the way I think and the way I feel.  I used to always feel beat down and terrible after work until I started exercising so those times of the day where you feel a lot slower are lessened.  I wouldn’t recommend starting out by completely changing the way you live your life.  Something simple to start with.  This summer I started running again, I made a routine out of going out for a run after work, and just kept at it until I started seeing changes.  I gradually increased the period of time and distance of my runs, then I added in weight lifting and other types of exercises gradually. By no means am I a hardcore athlete now but I do believe in the importance and benefits of exercising and working your body regularly to improve your mind.

Sleep – This is probably the most important thing to remember when you are trying to work on hacking your mind and improving yourself.  8 hours of sleep seems to be the general rule of thumb, and it should not be overlooked when you are evaluating yourself and your goals for getting to where you want to be.  If you want to wake up early, you need to go to sleep early, it really is as simple as that.  It is also important to be consistent on your sleep schedule so your body can get used to when it should slow down and when it should speed up (even on weekends!).  For example, getting in a routine of winding down at a certain time, say 9 pm  every night by reading a book for an hour to train your body that it is time to sleep.  Read until say 10 pm every night if you want to wake up at 6 am to get the sleep consistency your body needs, also giving your body enough time to repair and heal itself to get up and going.

Diet – Also important.  I realize that everybody is different and I don’t want to speak as if an authority on the subject so please take this advice at face value.  The point I want to make though is that diet isvery important in improvement.  Again, I do not want to encourage anybody to go all out and completely change every eating habit they have at once.  You will crash and burn like many others, it make work for some but generally you will be safer and more likely to make an impact if you take things slowly.  Work on one thing at a time and gradually make the changes to improve your diet and health.  As an example, start by cutting out something small, like cutting out a particular type of food that isn’t exactly healthy.  For me it was soda, and once I had that under control I was able to cut out (for the most part) fast food, etc.  Not entirely, I wouldn’t advocate that but cutting back is a good first step.  Basically doing something is better than doing nothing.

Read More

Protip January: Get your external IP from the command line

Ever need to grab your IP quick but don’t want to get out of the command line or stop whatever you’re working on?  Or how about if you have SSH’d into a number of different servers and you simply want to know where you are at currently?  This little trick enables you to quickly determine your public IP address without leaving the command line.

I’ll admit, I didn’t originally come up with this one, but liked it so much that I decided to write a quick post about it because I thought it was so nice and useful. There is a great website called commandlinefu.com where users can post all their slick one liners, which is where I found this one.  If you haven’t been there before I highly recommend it, there is some really good stuff over there.

This one is simple yet quite useful, which is what I’m all about.  The command uses curl, so if you don’t have that bad boy installed yet you’ll need to go get that quick (Debian based distros).

sudo aptitude install curl

Once that is installed simply run the following:

curl ifconfig.me

And bam!  Emeril style.  Let that go out and do its thing and you will quickly have your external IP address.  I like this method a lot more than having to jump out of the shell and open up a browser then going to a website to get this information.  It might not save that much time but to me just knowing how to do this is useful and knowledge is power.  Or something.

Read More

Reflections on the year

A lot happened this year for me, some good some bad (but mostly good) and  I wanted to take a moment to reflect on the year.  I made it to my first technical conference, got my first and second tablet, I started and finished some seemingly daunting work projects, I met, worked with and learned a ton from some incredibly smart people, I grew my network of professional contacts, list goes on and on.  One particularly important milestone that I was able to hit was my first full year of blogging.  Its been a great journey so far and I am hoping 2013 will be just as great if not better.

One goal of mine was to grow the blog, and I feel like I accomplished that goal although that wasn’t exactly a very specific goal I will admit.  Another goal I had in mind when I started doing this was just to be able to help others out with technical issues as much as I could.  I am really pleased with how things have come along so far, I have managed to grow my readership and have succeeded in getting in some fresh authors that have made some great contributions, who I would like to thank very much.  I would also like to thank all of the other contributors including the readers for helping to grow the blog this past year.  I know there will be a lot of work to do in 2013 and I feel like this was a great first full year for the blog.  I have had a great deal of fun learning about blogging and cultivating this blog and have no doubts that there will be some great stuff to come in the coming year.

I didn’t expect to learn nearly as much as I did about Exchange, Powershell, Lync, backups and networking.  These are the areas that I have been working with primarily in my current role and I will say for the most part I have loved these additional responsibilities.  I have fallen in love with Exchange and Powershell and would like to explore these areas and write about them much more in 2013.

There are some exciting areas that will come into focus more next year, which I am excited about.  I will be building a full on, clustered virtual environment, a new Exchange 2013 test bed, a Server 2012 Active Directory environment and much more I’m sure.  I have also managed to keep my Linux skills sharp (well somewhat) by labbing at home and plan to continue growing my home environment and skills that do not otherwise get any “production” to share my experiences on the blog.  I will hopefully be building a home grown SAN, adding a node to my virtual environment to create a cluster and obtaining some network gear so there should be some interesting topics on those fronts as well.

So anyway, I would love to hear any and all feedback from the readers!  What should I change?  What can I improve on?  Which topics are the most informative and the most interesting?  Knowing these types of things would be a great way to help build this blog and hopefully continue to grow in 2013.  Thank you all again, happy new years!

 

Read More