PowershellBIG

 

I was thinking, If you wanted to REALLY do a good deployment of Windows 7 (or Vista for that Matter) you’d want to have a full Zero Touch installation scenario.   A Zero Touch Installation (to put it in a a VERY general description) allows you to “Flip the Switch and just install handsfree”.

This is where if you spent the time with Microsoft Deployment Toolkit 2010, Systems Center Configuration Manager 2007 and tie in a Windows Deployment Server you can deploy 10’s 100’s or 10’s of 1000’s of workstations effortlessly.

And with Windows 7 and Windows Vista tied into this scenario, you don’t need to maintain and keep re-updating the images.  Just add or change the needed pieces!

But to get something like this started (at least from what I understand) you’ll need a list of MAC addresses and machine names.  

There’s a lot more than that, and if you had a small network of 10 computers, it’s not so difficult.

Or is it?  Do you want to climb under every desk and dig for numbers? or Sit there logging it, typing in IPConfig, writing down the info, hoping you have it right…

Yes if you’re a large corporation, you probably have inventory software, but unfortunately that’s not always correct.  Network cards get changed.

But in Powershell, well this is very easy to do

You’ll find I have a huge theme in Powershell, using it to get the information I need.    Because it just does it so beautifully and so simply

 

And so INEXPENSIVELY! 🙂

 

So one of the things you will hear over and over and over is how Powershell and WMI are best friends.  And they are.

WMI – the “Windows Management Instrumentation”, contains a LOT of information on your PC, your operating system, right down to the CMOS and how Many sticks of Ram you have.

In our case we’re going to ask Windows what network cards we have using

 
Get-Wmiobject WIN32-NETWORKADAPTER

Now this command simply lists EVERY Network Adapter, both REAL and Virtual, Including CiscoVPN, Tunneling, loopback.  To be honest a bit TMI (too much Information)

Really all I want is a list of the PHYSICAL adapters.  And this is done very easily too.  If you run a GET-MEMBER against this output you’ll find a pretty obvious Property called “PhysicalAdapter” with a Boolean True/False.  Want to guess what it does?

If you run tack on that property to our last command

Get-Wmiobject WIN32-NETWORKADAPTER | Foreach { $-.Name, $-.PhysicalAdapter }

You’ll end up with a basic list showing all the adapters and whether they are PHYSICAL (True) or NOT (False)

So this is great but Ideally I’d like to take this into a useful form.  So with a little help of the Format-List command and specifying properties.

Get-WmiObject win32-networkadapter | where { $-.PhysicalAdapter.CompareTo($FALSE) } | format-table -property name, macaddress

Now to make it TRULY useful, I’d like to have it mesh the name of the computer into this on the output which would make things easier for me as the Administrator to know which machines have these MacAddresses.  Well that part is easy.  I already know this particular computer name.   But we’re going to prepare this script to be universally useful.  I’m going to assign the name to a variable.

$COMPUTERNAME=’localhost’

Get-WmiObject win32-networkadapter -computer $computername | where { $-.PhysicalAdapter.CompareTo($FALSE) } | format-table -property @{Label="ComputerName"; Expression={$computername}}, name, macaddress 

Ok yes, that’s a cheat but you’ll see why this is useful next time.   What has been done is to use the GET-WMIOBJECT to pull up that list we had before.  We’re piping the output to the “FORMAT-TABLE” listing only the Name of the card and it’s Macaddress with a computer name.  I’ve also added in a Custom column into the list showing the present Computer Name.  Why is this going to help for one machine.

 

That’s for Next time I’ll show you how to tie THAT into Active Directory to get a list of your computers and have Powershell do all the work for you. 

 

Sean
The Energized Tech