Author Archive

Scripting/Sysadmin Meme

Associations, Career, Geek Stuff, General Interest, Scripting June 10th, 2008

I’ve found a Software Development Meme (A meme  consists of any unit of cultural information, such as a practice or idea, that gets transmitted verbally or by repeated action from one mind to another) on a few blogs I’ve started reading (Larry Clarkin’s and Damon Payne’s), and I thought I would adapt it to the Sysadmin.

How old were you when you started using computers?

I was eight when I first started using computers.  My mom was a teacher for the local public school system and they were just getting computers.  She could bring one home over the summer and I started learning Basic on an Apple II.

What was your first machine?

The first machine we had in our family (other than the ones my mom could bring home) was an Apple II GS.  My first machine was a 486 IBM clone that cost me $2,000 (in 1993) (my summer work money - I was in high school).

What was the first real script you wrote?

The first “real” script I wrote was a Python script to enter addresses into a database system via ADO.

What scripting languages have you used?

I’ve used VBScript (marginally), PowerShell, and Python.

What was your first professional sysadmin gig?

My first professional sysadmin job is the one I currently have, with a local law enforcement agency.  I started officially as the IT Specialist here in April of 2006.

If you knew then what you know now, would have started in IT?

Definitely.  If I knew then what I know now, I would have finished college in the IT realm and started down this path sooner.  However, that might have changed how I’ve ended up, and I really like the position I have now and the opportunities in front of me.

If there is one thing you learned along the way that you would tell new sysadmins, what would it be?

Get involved.  I’ve learned more and met more great people getting involved in community.  By commenting on blogs, podcasting, spending time on IRC in the #powershell channel and participating in PowerShellCommunity.org, I have learned so much and met generous, knowledgeable people.

What’s the most fun you’ve ever had scripting?

The 2008 Winter Scripting Games were a blast, even though I got busy with work halfway through, I had a great time.  It was awesome watching the community provide their solutions and see people working on the challenges in the IRC channel and forums.

Who am I calling out?

Rich Niemeier

Keith Albright

Hal Rottenberg

Jonathan Walz

Shay Levy

Aleksandar Nikolic

Episode 53 - OLPC Lives

Podcast June 3rd, 2008

Recorded: May 26, 2008
Your Hosts: Steve Murawski and Rich Niemeier
Show Length: 32:54

The logo contest is running until June 30th. Submit your entries to Contest [at] MindOfRoot.com. The winner gets their choice of either a full retail copy of Microsoft Office 2007 Standard or $25 cash.

Thanks for listening and we hope you enjoy.

Links mentioned in this show:

Read the full show notes here.

Listen Now:

Download Here

Episode 47 - Vista and Me

Podcast April 20th, 2008

Recorded: April 17, 2008
Your Host: Steve Murawski
Show Length: 47:06

Thanks for listening and we hope you enjoy.

Links mentioned in this show:

Read the full show notes here.

Listen Now:

Download Here

PoShMon for PolyMon is available!

Scripting April 8th, 2008

I finished the first revision of PoShMon - a PowerShell snap-in for PolyMon.

 Get it here!

Episode 34 - The Show That Wasn’t

Podcast January 20th, 2008

Recorded: January 7, 2008

Your Host: Steve Murawski

Show Length: 09:52

Links mentioned in this show:

View the full show notes here.

Website Picks:Sorry, none for this episode.

Listen Now:

Download Here

Recipes? This ain’t stone soup were makin’!

Podcast, Scripting December 14th, 2007

Recorded: November 29, 2007
Your Hosts: Steve Murawski, Rich Niemeier, and Keith Albright
Show Length: 59:11

A while back on our blog, I posted a review for the Windows PowerShell Cookbook from O’Reilly Press.  Lee Holmes, the author, responded to my review and, when I asked if he would do an interview for the show, he agreed.  We talk a bit about PowerShell, about his book, and the PowerShell community.  It is interesting to hear first hand from one of the developers on the PowerShell team who has not been featured on any other podcast (that I’m aware of).

Links mentioned in this show:

Precision Computing - Lee Holmes’ blog

Windows PowerShell Cookbook - O’Reilly Press

Get PowerShell

Get Powershell - V2 CTP

Listen Now:

Download Here

Forcing Windows Updates with PowerShell

Patches, Scripting December 10th, 2007

Lately, I have had to set up a number of computers from scratch (I know, I know, I should have updated my base image, but I didn’t…). As I was setting up the computers, I wanted to make sure their patch level was current.

Going to Windows Update (Microsoft Update) showed around 91 updates to download. I said to myself, “Self, I already downloaded all these updates to my Windows Server Update Services server. Isn’t there an easy way to make this computer update from there?”

In my environment, the location of the computer determines what Organizational Unit it is in my Active Directory, which in turn, says when it is scheduled to download updates.

A short Google search later, and I found a batch file which will cause a client computer to check with a local WSUS server (or MS Update if there is not an assigned local server) at Patchaholic - the WSUS Blog!

Since I’m a PowerShell fan, I though I should translate this simple batch file to PowerShell (and give it a more PowerShelly name).

#* FileName: Invoke-WindowsUpdate.ps1
#*================================================================
#* Script Name: [Invoke-WindowsUpdate]
#* Created: [12/10/07]
#* Author: Steven Murawski
#* Company:
#* Email: steve@acoupleofadmins.com
#* Web: http://www.acoupleofadmins.com
#* Reqrmnts:
#* Keywords:
#*===============================================================
#* Purpose: This script will force a computer to check for updates from
#* Microsoft Update or a local WSUS Server. This script is the
#* PowerShell version of the batch file found at Patchaholic - The WSUS Blog
#* http://msmvps.com/blogs/athif/pages/66375.aspx
#*===============================================================

Write-Host “This PowerShell script will Force the Update Detection from the AU client:”
Write-Host “1. Stops the Automatic Updates Service (wuauserv)”
Write-Host “2. Deletes the LastWaitTimeout registry key (if it exists)”
Write-Host “3. Deletes the DetectionStartTime registry key (if it exists)”
Write-Host “4. Deletes the NextDetectionTime registry key (if it exists)”
Write-Host “5. Restart the Automatic Updates Service (wuauserv)”
Write-Host “6. Force the detection”
Read-Host “Press enter to continue”

# Stop the local Windows Update Service
Stop-Service wuauserv

# Set the location of registry key
$AutoUpdate = “HKLM:\Software\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update”

# PowerShell allows you to navigate the registry like a drive
# The various registry hives are like drives, the keys are like files
# and their values are shown as properties.

# The switch statement below checks to see if any of the values below are set and deletes them
# if they are present.
switch (Get-ItemProperty $AutoUpdate)
{
{$_.LastWaitTimeout} {Remove-ItemProperty -Path $AutoUpdate -name LastWaitTimeout}
{$_.DetectionStartTime} {Remove-ItemProperty -Path $AutoUpdate -name DetectionStartTime}
{$_.NextDetectionTime} {Remove-ItemProperty -Path $AutoUpdate -name NextDetectionTime}
}

# Restart the local Windows Update Service
Start-Service wuauserv

# Call the command line client to check for new updates
wuauclt /detectnow

Write-Host “This AU client will now check for the Updates on the Local WSUS Server.”
Read-Host “Press enter to continue”

Translating this script was good, as it allowed me to work hands-on with the registry through PowerShell, which I had not yet had an opportunity to do.

Invoke-WindowsUpdate.ps1

ForceUpdate.bat

Book Review: Windows PowerShell Cookbook

Scripting November 20th, 2007

Windows PowerShell Cookbook by Lee Holmes is the latest in the Cookbook series by O’Reilly Publishing.  I have been a huge fan of the Cookbook series of books.  The Cookbooks are set up in the Problem/Solution/Discussion format, where the author proposes a common problem, shows a code/configuration solution to that problem, and then discusses why/how this solves the problem. 

The Cookbook series has covered many technical topics and, in my opinion, covered the topics quite well.  My current favorite is the IOS Cookbook, which set the bar quite high for the level of content for this series.

When I heard that there was going to be a Cookbook focused on PowerShell, I eagerly watched for it to appear on the bookshelf at my local bookstore (and to be available online).  My first impression was that, for an O’Reilly Cookbook, it was rather skinny (584 pages).  Being skinny does not doom a book to being a poor resource, so I picked it up and began to read. 

In scanning the table of contents, it appeared that the book covered a wide array of common, not-so-common, and quite interesting tasks.  After five minutes of reviewing the enclosed scripts and instructions, I was extremely disappointed.  While the problems covered a good amount of ground and the scripts to solve the problems were elegant (better than anything I could come up with), the discussion was lacking. 

In the IOS Cookbook, one could gain a working understanding of many of the protocols, services, and features offered in Cisco devices through the discussion portion of the solutions.  I did not see that same ability reflected in the Windows PowerShell Cookbook. 

The most disappointing to me was the coverage of how to create a PowerShell Cmdlet and how to add PowerShell scripting to  your own programs.  While Mr. Holmes provides examples of how to do each of the tasks, the discussion could be summed up as “check out the SDK documentation”.  The book would have been better if he had not broached these topics.

The Windows PowerShell Cookbook will stay on my shelf as a reference book (for the code samples), but I would look to other resources first (e.g. Windows PowerShell In Action by Bruce Payette), if you need a resource to help learn PowerShell.

If you have read this book, please let me know what you thought.

Powered by ScribeFire.

PowerShell Scripts and Functions

Scripting October 19th, 2007

I’ve included a few scripts and functions that I’ve found useful in playing around with PowerShell.  There are probably better/easier ways of doing these things, and many of my scripting ideas were gleaned from the blogs/podcasts/websites of those who are better with PowerShell than I.

That said, download the scripts, improve them, delete them…

Scripts: (can be run from the PowerShell command prompt)

Get-DomainComputers.ps1
    - This script will get a listing of all the computer accounts in the current Active Directory Domain.

Get-MachineSerial.ps1
    -This script is based off of the previous one and checks all the computers that have Active Directory accounts and are live on the network (respond to pings) for their serial number via WMI.

Functions: (create a function that can be used from the command prompt)

Get-RSS.ps1

    - This function will take as input a RSS Feed link and return a listing of the names of the posts and their links.  The default feed is for “A Couple Of Admins Podcasting”.

Run-SQLQuery
    - This function takes either a string as an argument or (with the -file) switch, you can supply the name of a saved SQL query (either a .txt file or .sql file).  This function needs to be updated with your database connection information.

**In order to make the functions available from the command line, you have to “dot source” them.**

Enjoy!

Powered by ScribeFire.

PowerShell on dnrTV!

Scripting September 14th, 2007

Scott Hanselman recently was on dnrTV! discussing PowerShell.  dnrTV! is a video podcast about .NET development; however, on this episode (#82), they discuss PowerShell. 

Scott walked through the installation of Powershell, as well as a really useful extension (MOW’s PowerTab).  The remainder of the episode covers some of the basic structure of PowerShell, as well as how to access the .NET Framework from PowerShell. 

If you are interested in learning about PowerShell, this is a great start.  It might be something to watch over the weekend! 
Enjoy!

Powered by ScribeFire.

blank