DEV Community

Victor James
Victor James

Posted on • Originally published at windowscmd.com on

IFMEMBER Windows Command With Examples

IFMEMBER

IFMEMBER

The IFMEMBER windows command-line tool shows the current user, a member of a group.

CMD Line

CMD Line is a text-based interface that transfers the command from the user to the OS.

CLI-Command Line Interpreter

The command-line interpreter (CLI) for windows is CMD.EXE. Also, you can use PowerShell which can automize many system administration tasks and these tasks are not approachable in command prompt. With the help of the CLI, you can communicate with your system by typing the text in commands. As a result, your system answers to the text that you have typed previously, and then the user can proceed with the next command line that shows up.

To open the Run command Window

Run command window helps you to run programs, open the files and folders. And there are several ways to open up the run command dialog box. This run command box is useful for you to head straight to the destined program easily.

By using the Keyboard shortcut Key:

WINDOWS+R

The shortcut key method to the run command box is the most commonly used one. Also, this method is in all versions of Windows. You need to press the Windows+ R key concurrently to open the Run command dialog box.

Run command box
Run command box

What does the IFMEMBER command do?

The IFMEMBER windows command-line tool is to locate if at all the current user is a member of one or more groups.

Syntax


IFMEMBER [options] Group [Group2 Group3...]

Enter fullscreen mode Exit fullscreen mode

Available Options

  • /verbose or /v – Print all matches.
  • /list or /l – Print all groups where the user is a member.

%ERRORLEVEL% return code will display how many of the listed groups the currently logged in where the user is a member.

Examples


IFMEMBER /v /l "MyDomain\Administrators"
IF ERRORLEVEL 1 echo This user is an Administrator

Enter fullscreen mode Exit fullscreen mode

Note here the syntax is the opposite of most other commands. That shoe error level as 1=success.

  • To utilize IFMEMBER 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

Enter fullscreen mode Exit fullscreen mode

Verdict

Through this simple guide, hope that you get to know about the IFMEMBER windows command-line tool. To know more about windows command with syntax and examples, visit our website.

Related Articles

  • IFMEMBER The IFMEMBER command is to locate if at all the current user is a member of one or more groups.
  • IPCONFIG The IPCONFIG command is to Configure IP. This command allows getting the IP address information of a computer.
  • INUSE The INUSE windows command-line tool is to replace files that are currently in use by the Operating System.
  • LABEL The LABEL windows command-line tool is for modifying the label of the computer drive.
  • DISM The DISM windows command-line tool is a Deployment Image Servicing and Management tool. To know more about this command with syntax and examples, read further.

The post IFMEMBER appeared first on Windows Commands- SS64 Commands.

Discussion (0)