Skip to content

Instantly share code, notes, and snippets.

@Doug-Moody
Created February 17, 2020 19:58
Show Gist options
  • Save Doug-Moody/a9c2781331b657ef344edaeb2568fa29 to your computer and use it in GitHub Desktop.
Save Doug-Moody/a9c2781331b657ef344edaeb2568fa29 to your computer and use it in GitHub Desktop.
Batch file that creates powershell file to handle username lookup requests. Displays MemberOf AD Groups quickly
@echo off
Title FindGroups
REM #######################################
echo [CmdletBinding()]>%CD%\findgroups.ps1
echo Param(>>%CD%\findgroups.ps1
echo [Parameter(Mandatory=$True,Position=1)]>>%CD%\findgroups.ps1
echo [string]$user>>%CD%\findgroups.ps1
echo. >>%CD%\findgroups.ps1
echo )>>%CD%\findgroups.ps1
echo. >>%CD%\findgroups.ps1
echo Get-ADPrincipalGroupMembership -identity $user | select name>>%CD%\findgroups.ps1
echo write-host "Press any key to continue...">>%CD%\findgroups.ps1
echo [void][System.Console]::ReadKey($true)>>%CD%\findgroups.ps1
REM ###################################
:START
setlocal
cls
echo.
echo Enter the username to see the group membership.
set user=
set /p user=Enter Username:
powershell -File ".\findgroups.ps1" %user%
pause
goto :START
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment