Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the hueman domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/future4tech/public_html/wp-includes/functions.php on line 6114
IFMEMBER – Windows CMD Command - Future4Tech

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

You may also like...

2 Responses

  1. zoritoler imol says:

    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.

  2. vorbelutr ioperbir says:

    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.

Leave a Reply

Your email address will not be published. Required fields are marked *


Notice: ob_end_flush(): Failed to send buffer of zlib output compression (0) in /home/future4tech/public_html/wp-includes/functions.php on line 5464