DiscoPosse – Using the chicken to measure IT
Technology, Cycling, Music and Madness


Technology

July 27, 2010

PowerShell – Get serial numbers for computers in Active Directory

More articles by »
Written by: Eric
Tags: , , , ,

PowerShellThere are a lot of posts about pulling data from a file to do actions against computers/users. While this is valuable, I prefer to do dynamic capturing of computer and user objects directly from my Active Directory.

This is a simple script which will capture a list of computers from Active Directory and subsequently pull the serial number using the Get-WMIObject CmdLet using the Win32_BIOS class.

The neat addition over many other scripts I have used is the addition of the -ErrorAction SilentlyContinue option which prevents offline computers from sending error information in the output. Add some error handling and you now have a list of computers which are offline or inaccessible.

As with many of the scripts I will show you, you need to install ActiveRoles CmdLets from Quest Software (follow the link in the Gist)

Here’s the code: http://gist.github.com/492475

List of serial numbers from Active Directory computers

List of serial numbers from Active Directory computers



About the Author

Eric





 
 

 
featured_powershell

Updating (same as parent folder) records with DNSCMD and PowerShell

In an earlier post on the site (Microsoft DNS record updates using PowerShell and DNSCMD) I noted how PowerShell cannot natively update records in MS DNS, however we could leverage the DNSCMD command and pass parameters using a...
by Eric
1

 
 
featured_powershell

CSV, yeah you know me! – PowerShell and the Import-Csv CmdLet – Part 3

This was a long overdue post, so thanks for sticking with me while I finally got back on track with our CSV, yeah you know me series (Here are Part 1 and Part 2). As I’d mentioned in the closing of Part 2, we want to be a...
by Eric
0

 
 
featured_powershell

Finding RDP sessions on servers using PowerShell

Have you ever needed to use RDP to get to a server console for some local admin work and then been bounced out because there are already active sessions? Or have you had your Active Directory account locked out because of an op...
by Eric
8

 

 
featured_powershell

It’s all about Progress: Using the PowerShell Write-Progress CmdLet

If you are like me and you like to know how your task is going in a PowerShell process, this is a great little tip for you. I’ve got a number of long running scripts that perform actions against a collection or query. The...
by Eric
2

 
 
alias-logo

A.K.A. – Using PowerShell Aliases

An interesting capability baked into the PowerShell environment is alias commands. Much like we can find in IOS (The Cisco one that is) and with other CLI environments, there are short commands available to save you some typing...
by Eric
0

 

 
powershell-for-developers-cover

DiscoPosse Review: Windows PowerShell for Developers by Doug Finke – O’Reilly Media

For those fans of PowerShell, and for those just getting on-board, PowerShell MVP Doug Finke has built the bridge for your journey with his latest book Windows PowerShell for Developers from O’Reilly Media. As a long time...
by Eric
0

 



Join Zipcar and get $50 in free driving Join Zipcar and get $50 in free driving Join Zipcar and get $50 in free driving

0 Comments


Be the first to comment!


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>