Solved

Powershell script to print computers and os version within domain

Posted on 2013-01-09
3
1,067 Views
Last Modified: 2013-01-10
I need a Powershell script to print a list of all computers and their os versions within domain.
0
Comment
Question by:roosterup
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 18

Expert Comment

by:Sarang Tinguria
ID: 38760788
I am not sure about Powershell however Chris has a great GUI tool for all theese stuffs

Cjwdev | AD Info - Active Directory Reporting www.cjwdev.co.uk/Software/ADReportingTool/Info.html

Or

AdFind by joe but CLI
www.joeware.net/freetools/tools/adfind/index.htm
0
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 38760792
Check this blog post for getting the list using Microsoft AD cmdlets..
http://blogs.technet.com/b/askds/archive/2010/02/04/inventorying-computers-with-ad-powershell.aspx

With Quest AD cmdlets use the following code..
Get-QADComputer -SizeLimit 0 | Select-Object Name,OperatingSystem,OperatingSystemServicePack,OperatingSystemVersion | Export-CSV AllWindows.csv -NoTypeInformation

Open in new window

0
 
LVL 6

Expert Comment

by:traoher
ID: 38760869
$ou = [ADSI]"LDAP://OU=<OU>,DC=<domain>,DC=<COM>"
foreach ($Server in $ou.psbase.Children)
{
      if ($Server.ObjectCategory -like '*computer*')
      {
            $Server = $Server.Name
            $query = "select * from win32_pingstatus where address = '$Server'"
            $result = Get-WmiObject -query $query -ErrorAction SilentlyContinue
            #$result | fl
            if ($result.ProtocolAddress)
            {
                  $Win32_OS = Get-WmiObject Win32_OperatingSystem -computer $Server -ErrorAction SilentlyContinue | select Caption,servicepackmajorversion
                  if($Win32_OS.caption -like '*Microsoft*'){
                  "$Server `t `t -$($Win32_OS.Caption) Service Pack $($Win32_OS.servicepackmajorversion)"
                  Get-WMIObject -class Win32_Printer -computer $Server | Select Name,DriverName,PortName
                  } else {"$Server  `t `t -is NOT a Windows Host"}
             }
       else
       {
             "$Server  `t `t -is OFFLINE"
       }
       }
}
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question