Tuesday, March 18, 2014

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:\Scripts\Win7\Report_Backups"
$Verify = Test-path -PathType Container $BKlocation
If ($Verify -eq $false)
{$Verify = New-Item -ItemType Directory -Path $BKlocation }
move-item "E:\Scripts\Win7\win*.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

0 comments:

Post a Comment

Popular Posts

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More