Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Running through an array and do something - Where is my mistake?

$
0
0

Hey,

I'm still working at my script and ran into another issue.

Now I have an Array which is called $Groups. In this Array are are informations from an AD Group like Name, Member, Info, ... .

I like to run through this Array, search for "DFS-I". If I found DFS-I I like to replace it with "DFS-R" and save in a new variable ($Name). At least there is $rMembers, here I like to get the AD Group Members of the Group which is named $Name.

Background: There are two identic Group names, just the I and R is different, I like to get the Members of this R Group. 

#Get AD-Group Member Read Group
ForEach($object in $Groups){  
     #$Groups.Name[$i]
     if($Groups.Name[$i].Contains("DFS-I")){
      $Name=$Groups.Name[$i]
      $Name=$Name.Replace("DFS-I-", "DFS-R-")
      $rMembers=Get-ADGroupMember -Identity $Name
     }    
    }

The result is a write-host of the three Group names and the $Name is still empty. Thats not what I was trying for ;-)

Thanks!!!


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>