?
Solved

Powershell script to print computers and os version within domain

Posted on 2013-01-09
3
Medium Priority
?
1,076 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 2000 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

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

A hard and fast method for reducing Active Directory Administrators members.
After seeing many questions for JRNL_WRAP_ERROR for replication failure, I thought it would be useful to write this article.
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

764 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