what is the best scenario for the command to use it
cmdlet Get-ADGroup at command pipeline position 1Supply values for the following parameters:(Type !? for Help.)Filter:
Why did you post this twice???
"what is the best scenario for the command to use it "
... needs more context.
Best is determined by you and your use case. Anything we could state would just be an opinion.
If all you are after is some users, then you simply need to specify who they should be, either by named list or group/OU list.
Don't stress out over doing this from scratch, unless it's a self-learning / homework thing.
Use the built in Windows tools to write this base code for you then teak as needed, such as the Windows Server 2012 ADAC console leveraging the PowerShell History Viewer.
Active Directory Administrative Center: Getting Started 'technet.microsoft.com/.../dd560651(v=ws.10).aspx'
Active Directory Administrative Center 'docs.microsoft.com/.../active-directory-administrative-center'
Step-By-Step: Utilizing PowerShell History Viewer in Windows Server 2012 R2 'blogs.technet.microsoft.com/.../step-by-step-utilizing-powershell-history-viewer-in-windows-server-2012-r2'
You just click thru the GUI, it writes the code in the background, you view the history, copy and paste into the ISE or VSCode and tweak as needed.
Powered by IDERA