This PowerShell script can be used to collect computer information from Active Directory.   I am searching only Windows XP and Windows 7 machines.  You can update these values  by modifying $OS1 and $OS2 variables.

$OS1 =  “Windows 7*”
$OS2 = “Windows XP*”

This script is schedule to run everyday.  That is the reason I have include a backup file location and a file copy process.

 

$BKlocation = “E:ScriptsWin7Report_Backups”
$Verify = Test-path -PathType Container $BKlocation
If ($Verify -eq $false)
{$Verify = New-Item -ItemType Directory -Path $BKlocation }
move-item “E:ScriptsWin7win*.txt” $BKlocation –Force

I am currently collecting only the following information.  You can add more details based on your requirement.

$tName = $ItemProp.name
$tOS = $ItemProp.operatingsystem
$tSP = $ItemProp.operatingsystemservicepack
$tDes = $ItemProp.description
$tLoc = $ItemProp.distinguishedname
$tBuild = $ItemProp.operatingsystemversion

Script:

image 

 

In my case, I am using an input file which contains the Distinguished Name of the OU.  You don’t have to use an input file, if you are searching an entire Domain.  

image

http://www.amazon.com/dp/1849687447/?tag=packtpubli-20

Powered by WPeMatico

Categories: Microsoft

Related Posts

Microsoft

Azure – Your account is temporarily locked to prevent unauthorized use

Here is the another common error message when dealing with directory and password synchronization.  Error Message: Your account is temporarily locked to prevent unauthorized use. Try again later. Contact Customer Support if the problem persists Read more…

Microsoft

Verify Service Status Remotely Using Local Account – PowerShell Script

I have modified one of my previously published script – Stop, Start, Disable Service Remotely–PowerShell Script (http://portal.sivarajan.com/2011/05/stop-start-disable-service.html) to use Local account (instead of a domain account) to verify the status of the service.   Input Read more…

Microsoft

PowerShell – Tips, Tricks and Useful Commands

Tip #4 –   #4                       Tip #3 – Comparison Operators Published date – May12, 2013 -eq   -ne   -gt   -ge   -lt Read more…