Collect Computer Information From Active Directory– PowerShell Script

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 = $
$tOS = $ItemProp.operatingsystem
$tSP = $ItemProp.operatingsystemservicepack
$tDes = $ItemProp.description
$tLoc = $ItemProp.distinguishedname
$tBuild = $ItemProp.operatingsystemversion




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.  


Powered by WPeMatico

Kurt Conway

That's IT!