locked
Get-ADgroupMember doesn't show the details RRS feed

  • Question

  • Hello, We have multiple domains, I am trying to retrieve the list of domain admins user from each domain with below command.

    I am not getting any output, I am missing something in the below script.

    $Domain = Get-Content "C:\Temp\Domain.txt"
    $DALIST = Get-Content "C:\Temp\DAList.txt"

    ForEach-Object ($domains "in" $Domain)
    ForEach-Object ($DALISTS 'in' $DALIST)
    {
    Get-ADGroupmember-server $Domain -Identity $DALIST
    }


    Thanks HA

    Monday, October 8, 2018 4:52 PM

Answers

  • I recommend that you actually try to learn PowerShell before trying to use it. You are copying all of the wrong things because you do not know PowerShell.

    $domains = Get-Content C:\Temp\Domain.txt
    $daList = Get-Content C:\Temp\DAList.txt
    
    foreach($domain in $domains){
        foreach($da in $daList){
            Get-ADGroupmember  -Identity $da -server $domain
        }
    }
    1. Learn PowerShell  
    2. PowerShell Documentation
    3. PowerShell Style Guidelines


    \_(ツ)_/

    • Marked as answer by Anup Ghonge Monday, October 8, 2018 5:14 PM
    Monday, October 8, 2018 5:02 PM

All replies

  • I recommend that you actually try to learn PowerShell before trying to use it. You are copying all of the wrong things because you do not know PowerShell.

    $domains = Get-Content C:\Temp\Domain.txt
    $daList = Get-Content C:\Temp\DAList.txt
    
    foreach($domain in $domains){
        foreach($da in $daList){
            Get-ADGroupmember  -Identity $da -server $domain
        }
    }
    1. Learn PowerShell  
    2. PowerShell Documentation
    3. PowerShell Style Guidelines


    \_(ツ)_/

    • Marked as answer by Anup Ghonge Monday, October 8, 2018 5:14 PM
    Monday, October 8, 2018 5:02 PM
  • Yes, I am learning <g class="gr_ gr_24 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="24" id="24">powershell</g>. I am trying to learn the variable and loop command

    Thank you for your help


    Thanks HA

    Monday, October 8, 2018 5:11 PM
  • Do the tutorial linked above and it will all become clear.  So far your guesses show that you do not have enough technical experience to guess even closely to the requirements.  You must take a tutorial to learn the basics.  They cannot be guessed or learned from reading forums or blogs.

    Once you have the basics then the blogs will be useful.


    \_(ツ)_/

    Monday, October 8, 2018 5:14 PM