Monday, 26 June 2023

How to find particular Group in multiple computers memberof.

 How to find particular Group in multiple computers memberof.





$Computers= Get-Content C:\Temp\ADComputer.txt

$output = foreach($Computer in $Computers)

{

    $groups = Get-ADPrincipalGroupMembership (Get-ADComputer $Computer) | select-object name | Where-Object name -Like "*GroupName*"

 

    foreach($group in $groups)

    {

        [PSCustomObject]@{

            ComputerName  = $Computer

            Group = $group.Name

        }

    }

}

 $output   | Export-Csv c:\temp\Final.csv -NoTypeInformation  


No comments:

Post a Comment