Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Nested Groups - Trying to create a csv or HTML report

$
0
0

Hi

I found this script online to find nested groups in AD:

#NestedGroups.ps1
Import-module Active Directory
Clear 
$AllGroupNames = Get-ADGroup -Filter {(GroupCategory -eq 'security')} #-SearchBase 'DC=toyota,DC=co,DC=za' 
#Gnames - contins all Security group details 
    foreach ($GNamet in $AllGroupNames) 
    { 
    Write-Host "Parent Group Name -" $GNamet.Name, $GNamet.GroupScope 
    #GNamet contains all Group properties 
    $Gname = $GNamet.Name 
    #$Gname contians only group names 
    $AllGmembers = Get-ADGroupMember -identity $Gname 
    #$AllGmembers - memeber details from each security group 
        foreach ($GMemebr in $AllGmembers) #Loop for verifying each member type 
            { 
                If ($GMemebr.objectClass -eq "Group") #verifying each member type.  
                { 
                    $ChildGroupProp = Get-ADGroup -Identity $GMemebr 
                    Write-Host "Child Group Member(s)-" $GMemebr.name, $ChildGroupProp.GroupScope -ForegroundColor Green 
                } 
            }

    } 

 

This script is awesome in that it displays the results on the screen, however I need to get this in to a csv or html report and was wondering if someone here could assist me this.

Thanks in advance.


Viewing all articles
Browse latest Browse all 6937

Trending Articles