Solved

Powershell script to print computers and os version within domain

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

Join & Write a Comment

Find out how to use Active Directory data for email signature management in Microsoft Exchange and Office 365.
This article will help you understand what HashTables are and how to use them in PowerShell.
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
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 …

758 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now