Monday, January 3, 2011

Generate sidHistory Report using DSQUERY command

Last week I blogged about generating sidHistory report using a PowerShell script - http://portal.sivarajan.com/2010/12/powershell-script-search-active.html. If you prefer to use dsquery command, you can use the following syntax to generate similar report.

dsquery * -Filter "(samaccountname=santhosh)" -Attr samAccountName ObjectSID sidHistory

You can also create a batch file with the following command generate a report from an input file (Users.txt):

image

For /f %%i in (C:\Users.txt) Do (

dsquery * -Filter "(samaccountname=%%i)" -Attr samAccountName ObjectSID sidHistory >> C:\User_Info.txt

)

As you can see in the following screenshot, the output file (User_Info.txt) contains the SamAccontName, ObjectSID and its sidHistory value:

image

Dsquery - http://technet.microsoft.com/es-es/library/cc754232(WS.10).aspx

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.

2 comments:

I bought a watch for my boyfriend at this online store. The watch runs on time, the quality is very good, the style of the watch is very like, it is worth buying.
buy uk fake watches

I know that advices from https://writemyessay4me.org/blog/how-to-make-a-class-entertaining will be useful for teachers. You can use this information in order to keep children's attention.

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...