I need to list all the AD groups used in all the site collection.
Can any one please help.

```
$SPWebApp = Get-SPWebApplication https://*******.com/

foreach ($SPSite in $SPWebApp.Sites)
{
    write-host -foregroundcolor green "Working on Site Collection: "$SPsite.RootWeb.Title 
    ##write-host -foregroundcolor green "Working on Site Collection: "$SPsite.RootWeb.URL
    $SiteURL = $SPsite.RootWeb.URL
    $ADgroup=Get-SPUser -Web $SiteURL  | Where { $_.IsDomainGroup }
    foreach($group in $ADgroup)
    {
        write-host $group.DisplayName
        $Output += ($group.DisplayName)
        $users = new-object psobject
        $users | add-member noteproperty -name "Site Collection" -value $SPsite.RootWeb.Title
        $users | add-member noteproperty -name "Groups" -value $group.DisplayName
        $combinedusers += $users
    } 
    $combinedusers | export-csv "F:\group.csv" -notypeinformation
}

```