IFMEMBER – Windows CMD Command
Find out if the current user is a member of one or more groups.
Syntax
IFMEMBER [options] Group [ Group2 Group3...]
Options:
/verbose or /v : print all matches.
/list or /l : print all groups user is a member of
The %ERRORLEVEL% return code shows how many of the listed groups the currently logged-in user is a member of.
To also test for nested permissions use VBScript or PowerShell Get-adGroupMember.
Examples
IFMEMBER /v /l "MyDomain\Administrators"
IF ERRORLEVEL 1 echo This user is an Administrator
Notice that the syntax here is the opposite to most other commands in that an %errorlevel% of 1 = Success
A good way to utilise IFMEMBER is through conditional execution...
IFMEMBER Administrators || ECHO Error is 1 so [%Username%] is an Admin
IFMEMBER Administrators && ECHO Error is 0 so [%Username%] is NOT an Admin
I have been surfing on-line more than 3 hours nowadays, yet I never discovered any fascinating article like yours. It’s lovely worth enough for me. In my view, if all site owners and bloggers made excellent content material as you probably did, the web might be much more helpful than ever before.
I’ve recently started a site, the info you offer on this website has helped me tremendously. Thanks for all of your time & work. “It is a great thing to know our vices.” by Cicero.