Saturday, April 9, 2011

Home /Active Directory /AD /PowerShell /script / Search Active Directory and Get Computer Object Information

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. 

image

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

image

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

image

Downloadwww.sivarajan.com

I also updated this script onto the Microsoft Script Center - http://gallery.technet.microsoft.com/scriptcenter/5c618613-9a51-402c-a4b9-edccd06ba8d9

SS

Santhosh Sivarajan

Microsoft MVP · Identity & Cybersecurity Architect

Santhosh has 30+ years of hands-on enterprise experience in Identity and Access Management, Microsoft Entra ID, Active Directory, Microsoft 365 and Zero Trust architecture. He is the author of two books on Windows Server and security, and leads consulting, assessments and training at SAG Business Group.

12 comments:

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!
http://www.hpd530.com

I am getting a blank file..it 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?

http://portal.sivarajan.com/2010/07/user-profile-and-os-info-powershell.html

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

http://portal.sivarajan.com/2010/07/user-profile-and-os-info-powershell.html

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
Workstation Trust Relationship Issue Issue: You receive the following error message, when you try to login to the domain.  The security database on the server does not have ... ADMT Service Account - Permission and Configuration The ADMT service account needs to have proper permission in source and target domains.  You don’t need to use 2 separate accounts.  You can ... My First Peek into Microsoft Exchange 2010 By Santhosh Sivarajan Before I really dive into Exchange 2010, I thought I would install and play with it first. I took some screen shots and notes during the ins... ObjectSID and Active Directory What is an objectSID in Active Directory? When a new object is created in Active Directory, Domain Controller assigns a unique value used ... AD Group Report - List Group Members in Active Directory–PowerShell Script Updated Script - http://portal.sivarajan.com/2011/10/search-ad-collect-local-admin-group.html Script #1 This script... Add Users to a Group–PowerShell Script Purpose – Add users to a group from an input file – PowerShell V2 Script.  Input file – Input file (Users.csv) contains samAccountName in... User Account Migration and Merging – Part I (ADMT) Part I - User Account Migration and Merging Using ADMT Part II - User Account Migration and Merging Using QMM pre-creating user account ... User Account Migration and Merging – Part II (Quest Migration Manager) Part I - User Account Migration and Merging Using ADMT Part II - User Account Migration and Merging Using QMM Pre-creating user account in... Delete Stale or Inactive Computer Accounts from Active Directory Here is an easy way to identify and delete inactive or stale computers in an Active Directory environment.  Using the dsquery command you c... Converting PowerShell (PS1) to EXE / Standalone Application As we know, there many applications available to convert a PowerShell file to a standalone executable file.  Based on my experience, PowerSh...