I need to Add Active Directory Groups to Local Administrator Group with If state

Welcome Forums General PowerShell Q&A I need to Add Active Directory Groups to Local Administrator Group with If state

This topic contains 1 reply, has 2 voices, and was last updated by

 
Keymaster
1 year, 10 months ago.

  • Author
    Posts
  • #62601

    Participant
    Points: 0
    Rank: Member

    I need to Add Active Directory Groups to Local Administrator Group on Server but I need a IF statement
    Like If the Computer is in that Group then add this AD Group name to Local Administrator Group of the local computer
    I need help I am still trying to create one if someone help me I'll really appreciate that.

    $g=Get-ADGroupMember -Identity "CN=myADgroup,OU=myOU,DC=corp,DC=com" -server corp.com foreach($mbr in $g) {if($name.MemberOf -like "*mycomp*" -eq $true)} |

  • #62745

    Keymaster
    Points: 1,704
    Helping HandTeam Member
    Rank: Community Hero

    You can't do that all in one statement. You're going to have to query its group memberships, test for the one you want, and then take whatever action – three steps. Logic statements aren't supported in filter criteria.

The topic ‘I need to Add Active Directory Groups to Local Administrator Group with If state’ is closed to new replies.