Saturday, April 9, 2011

Search Active Directory and Get Computer Object Information

Purpose – This script searches Active Directory and report information about computer objects. 

You can modify the ObjSearch.SearchRoot filter to limit the scope to a particular OU.  Also, modify the if($TClastLogon -eq "12/31/1600 18:00:00") {[string]$TClastLogon = "Never"}  section with correct value to replace the 12/31/1600 date with Never value. 


Output – This script has two outputs.  It creates an output file called ComptuerInfo.csv which contains all computer information. 


It also generate the output on the screen as shown in the following screenshot:


I also updated this script onto the Microsoft Script Center -


It’s really an interesting fact which I just got to know via this blog. Making this blog and keeping it updated is the best possible thing which customer always ask for. So I would like to thank for this interesting knowledge given by the moderator!

I am getting a blank creates the columns with the names but does not actually pull the information.

Something wrong with your input file or the script. Post the input file and script here.

how can I incorporate the request of Lastlogin user for each machine?

Lastlogin user – You can check the profile update date. Take a look at my following script:

Hi, how can im odify the code to also export the GUID/UUID string to the file?

How I can get information about memory?

sivarajan ,

Thanks for the script i wan to understand what does
if($TClastLogon -eq "12/31/2011 18:00:00") {[string]$TClastLogon = "Never"}
if($TClastLogoff -eq "12/13/1600 18:00:00") {[string]$TClastLogoff = "Never"}

means in simple terms

replaces the variable with "never" if equals (matches) the date

I am getting error while running this script against 2012AD. The error is...

Exception calling "FindAll" with "0" argument(s): "An operations error occurred
At C:\Intelex_Corporate_IT\Scripts\SearchAD_ComputerInfo.ps1:16 char:29
+ $AllObj = $objSearch.FindAll <<<< ()
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException

Computer Name:
Last Log On: 12/31/1600 19:00:00
Last Loff Off: 12/31/1600 19:00:00
Distinguished Name:
Operating System:
PS C:\windows\system32>

Post a Comment

Popular Posts


Twitter Delicious Facebook Digg Stumbleupon Favorites More