Remove Groups partial group name

Welcome Forums General PowerShell Q&A Remove Groups partial group name

Viewing 2 reply threads
  • Author
    Posts
    • #279282
      Participant
      Topics: 2
      Replies: 1
      Points: 5
      Rank: Member

      Hey all

      Anyway, I’m trying to get the below running. I guess I need to run this line against the foreach:

      Then once I have that value stored, I can run:

      I just have no idea how to do that, any ideas?

      Thanks all

       

       

       

       

      • This topic was modified 1 month, 1 week ago by liminal162.
      • This topic was modified 1 month, 1 week ago by liminal162.
      • This topic was modified 1 month, 1 week ago by liminal162.
    • #279459
      Participant
      Topics: 5
      Replies: 252
      Points: 999
      Helping Hand
      Rank: Major Contributor

      What does C:\Scripts_CSV\Licences_to_Remove_Output.csv contain?  Just need the format.  Get-Content would only get raw strings for each line of text in that csv.  You probably want Import-Csv so you can create objects for each line and then you can use the property dereference operator “.” to access the individual properties like $user.samaccountname.  Making an assumption that samaccountname is the column heading in this example.  Also the members property will take a collection (array) of objects so no need for the foreach loop.  Also, the Identity parameter will take pipeline input so you should be able to pipe right into Remove-ADGroupMember.  I can’t test in my environment however.

       

       

    • #280014
      Participant
      Topics: 2
      Replies: 1
      Points: 5
      Rank: Member

      Sorry mate, I missed this. Thanks for getting back to me 🙂

      It is a column with samaccountname. I was just trying to get some general information yesterday about Get-Content vs Import-CSV, thats very interesting thanks!

      Also not needing the foreach, it just seems to be the go to for anything involving a CSV now.

      Anyway, ill test that and let you know how it goes.

      Thanks again

Viewing 2 reply threads
  • You must be logged in to reply to this topic.