Home > Powershell > Powershell in Action….

Powershell in Action….

I’m by no means a scripting expert and the experience I do have is limited to that of simple VBScript.  I do however recognize its importance and believe that not only learning a scripting language will provide for greater efficiency, but it’s now a requirement in the world of Windows IT administration. It was with that conviction that I signed up for a 3 day Powershell class titled “Automating Windows Server 2008 Administration with Windows Powershell” at Global Knowledge. It was an official Microsoft course 6434A and was taught by Brian Langan. I have to admit that, at times, it was a bit dry but when it comes to learning the basics of scripting it’s what I expected. I now use the book, along with online content, to further develop my understanding of Powershell.

Having recently migrated over from MCSE to MCITP, I’ve been required to both learn and teach Powershell fundamentals.  The Microsoft Press books provide several examples regarding creating users, group and computers as well as a few other administrative tasks.    I decided, however, that the best way to learn to “Powershell” was to come up with a list of basic tasks that could be scripted with the end result of saving a minimum of 1/2 hour in manual configurations.  I now needed to decide on the following:

  1. List of required tasks
  2. Calculate their total configuration time
  3. Decide on which tasks were best suited for my first script

Since I’m required to build new servers for every upcoming class, as well as bring new ones online to implement test scenarios, it seemed this would be the best place to start making a list of tasks needed to accomplish my goal. Although the manual configurations would seem redundant to anyone who has set up a test lab environment for the 100th time, the desire to automate such processes seems daunting in comparison.

My theory is that if it’s worth doing then it shouldn’t be easy, otherwise everyone would do it. Anyway, what doesn’t kill you makes you stronger, so let’s exercise our Powershell brain one line of code at a time.

I put together the following list of tasks I felt would best be automated and will update their manual configuration times in future updates to this blog.

Task

Time

Configure a static IP and DNS address

 

Install Active Directory

 

Reboot server

 

Create an MCITP OU

 

Create a new admin account

 

Create a new MCITP Global Group

 

Add new admin account to MCITP GL

 

Add MCITP Global group to Domain Admins GL

 

Verify DNS address configuration and reset if needed (ongoing issue with VirtualPC)

 

Install DHCP

 

Configure DHCP scopes

 

Enable Remote Desktop

 

Enable Remote Administration

 

Create the following folder: C:\Software

 

Share the C:\Software folder as “Software”

 

Map a network drive to the Software share for all Domain Users

 

Create the following folder C:\Documents

 

Share the C:\Documents folder as “Docs”

 

Map a network drive to the Docs share for all Domain Users

 

 

I just doing some online research looking for a viable way to accomplish the very first task “Configure static IP & DNS address”, and although the code is out there the examples I came across were prepared as functions. Since my knowledge of Powershell is limited at best, and the same holds true for my scripting abilities in general, I do understand some of the basic scripting principles, such as variables, arrays, and of course functions.

Ok..so what is a function? A function is a chunk of code that performs an easily reusable set of instructions. Functions have the following benefits:

  • you can repeat the block of code easily and reliably by calling the Function’s name 
  • you can introduce parameters which modify the code

Now knowing what a function does is a far cry from being able to actually write one so I decided to use the example code found on Andy Schneider’s Blog, as well as on the Powershell Code Repository web site. The code on the Powershell Code Repository is actually Andy’s original function but it includes some additional information.

 

References

Computerperformance

Powershell Code Repository

Advertisements
Categories: Powershell
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: