Windows PowerShell Scripting Primer

PowerShell Tutorial 6: PowerShell Scripting - Introduction to Script Writing


It’s time to take what we have learned and apply it to writing scripts. The plan is six new and exciting PowerShell tutorials to explain the fundamentals of the PowerShell scripting language. Here is what will be covered:

  • Variables, Constants, Arrays, and Hash Tables.
  • Using Conditional Logic.
  • Processing data with Loops.
  • Modular Scripting Using Functions.
  • Scripting using WMI Objects (Computers, Printers, Etc…).
  • Scripting using ADSI Objects (Active Directory Management).

Variables, Constants, Arrays, and Hash Tables

What’s in Tutorial 7:

  • String manipulation and concatenation.
  • Storing and Retrieving information using variables and Constants.
  • Operators and Expressions.
  • Creating, Modifying, and Combining Arrays and Hash Tables.

Conditional Logic

Tutorial 8. explains:

  • Testing conditions and running commands based on results.
  • Introduce and work with “if” and “Switch” statements.
  • Using Operators to test conditions.

Loops

Tutorial 9. gets loopy:

  • Applying “while,” “do while” and “do until” loop processing.
  • Applying “for” and “foreach” loop processing.

Modular and Dot Source Scripting using Functions

Clean up your act in Tutorial 10:

  • Organizing your code
  • Enlisting “Data Types”
  • Calling Functions from other scripts

PowerShell Scripting using WMI Objects

Tutorial 11. Oh my! WMI:

  • Concept of WMI namespaces.
  • The WMI Provider.
  • Navigating and using the WMI namespace.
  • WMI Classes.
  • Using the “Get-WmiObject” cmdlet.
  • Querying WMI.

PowerShell Scripting using ADSI Object (Active Directory Objects)

Tutorial 12. Administration without the GUI:

  • Concepts of Active Directory Objects.
  • The ADSI Provider.
  • The Active Directory namespace.
  • Creating and modifying Active Directory Objects (Users, Computers, OUs, Groups, etc…)
Email This Page To A Friend Email This Page To A Friend

Comments

By Mike Anderson on November 5th, 2007 at 5:56 am

Outstanding way of writing and explaining concepts.

Nice article. But is there a way to INCLUDE the source library files rather than pasting in the whole file each time? This would make it much easier if you wanted to make a change to a function that is called in many scripts.

Absolutely; read this article Simon, this is what you are looking for:
http://www.powershellpro.com/function-calling/144/

Jesse,

Man,if you ever write a book about PowerShell or anything IT related, I would definitely buy it. Your writing style is easy to read and follow. I can’t wait to get into the latter half of your tutorials.

Many, many thanks for putting up this site.

Rock on!

By Arlo Belshee on May 17th, 2008 at 10:57 am

Looking at your templates, it appears you don’t use source control. As you go to a modular scripting style, source control is a must. It makes deployment & file sharing easier, and it gives you full history and atomic recovery from errors.

Since this page is going to influence a lot of future IT admins, I think it’d be a good idea to mention some scm (Subversion comes to mind). And then you could remove the revision history section without losing any information. The computer tracks it all for you, and the reader doesn’t have to skip past it when he doesn’t want to see it.

By chris wood on May 28th, 2008 at 7:52 am

really good, cannot get enough. just like pie.

:-)

10/10

Is tutorial 6 still available? I only see a description of it, and the next 6 tutorials.

Thanks!

By Chandana on June 4th, 2009 at 1:15 am

Hi Jesse,

Thanks a lot to you for the content… It’s superb tutorial. I’m new to PowerShell and my basic was clear in just few hour, also the content is very interesting.. I didn’t feel bore even for a minute…

Thanks Again,
Chandana

Jesse,

Thanks for taking the time to put this stuff together. I use these tuts religiously for reference.

 

Leave a Comment