Solved

Powershell script to print computers and os version within domain

Posted on 2013-01-09
3
1,043 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

Industry Leaders: 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

Always backup Domain, SYSVOL etc.using processes according to Microsoft Best Practices. This is meant as a disaster recovery process for small environments that did not implement backup processes and did not run a secondary domain controller that ne…
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

733 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