Adfind: Querying Active Directory made easy

List all AD user accounts matching a string: C:>adfind -b DC=Test,DC=com -f “(&(objectcategory=user)(name=*govardhan*))” displayname AdFind V01.42.00cpp Joe Richards ([email protected]) April 2010 Using server: test.domain.com:389 Directory: Windows Server 2008 dn:CN=Govardhan g.,OU=TestUsers,DC=test,DC=com >displayName: Govardhan g. 1 Objects returned C:> — — List all computer (server) accounts whose operating system matching certain string: C:>adfind -b DC=Test,DC=com -f “(&(objectcategory=computer)(OperatingSystem=server*2008*r2))” operatingsystem AdFind V01.42.00cpp Joe Richards ([email protected]) April 2010 Using server: test.domain.com:389 Directory: Windows Server 2008 dn:CN=W2K81049,CN=Computers,DC=test,DC=com >operatingSystem: Windows Server 2008 R2 Enterprise 1 Objects returned C:> List all members of a AD group: C:>adfind -b DC=Test,DC=com -f “(&(objectcategory=group)(name=*_tech))” member | cut -d”,” -f1  | cut […]

Read more

Using SED: Match RegEx pattern in multiple lines and combined the lines into sinlge line

gunnalag@GMD /cygdrive/c/Gunnalag/MyFiles $ grep -i -A1 -B1 “topbar.*” movie0715.html   <div id=”topbar”> <h2>Ragada&nbsp;&nbsp;<small><i></i></small>&nbsp;(December 24, 2010)&nbsp;&nbsp;&nbsp;<a href=#comment><small>Write A Comment</small></a></h2> — src=”../pagead2.googlesyndication.com/pagead/show_ads.js”> </script>                       </div> <!– End Of topbar –> <div id=”outer5″>   gunnalag@GMD /cygdrive/c/Gunnalag/MyFiles $ cat movie0715.html | sed -E -n ‘/”topbar”/{N; s/n//; p;}’ <div id=”topbar”>                           <h2>Ragada&nbsp;&nbsp;<small><i></i></small>&nbsp;(December 24, 2010)&nbsp;&nbsp;&nbsp;<a href=#comment><small>Write A Comment</small></a></h2>   gunnalag@GMD /cygdrive/c/Gunnalag/MyFiles $

Read more

Perl and Shell Scritping Windows

Code to list all Windows environment variables in current user shell C:>perl -e “foreach (sort keys %ENV) {print “$_ = $ENV{$_}n”; } “; > Tempperl-env.txt C:> Single Command to combine all files in directory into single file. C:Temptest>dir /w *.json | grep -i json tasklist-level-1.json   tasklist-level-2.json   tasklist-level-3.json tasklist-level-4.jsonC:Temptest>copy *.json combined-file.json tasklist-level-1.json tasklist-level-2.json tasklist-level-3.json tasklist-level-4.json 1 file(s) copied. C:Temptest>dir /w *.json | grep -i json combined-file.json      tasklist-level-1.json   tasklist-level-2.json tasklist-level-3.json   tasklist-level-4.json C:Temptest>wc -l C:Temptest>wc -l combined-file.json 2230 combined-file.json C:Temptest> Single command line to find and replace string in all files of a folder.  Use Cygwin on Windows. gunnalag@GMD /cygdrive/c/temp $ grep -r […]

Read more