@@ -5077,22 +5077,26 @@ function Get-NetGroup {
50775077 A [Management.Automation.PSCredential] object of alternate credentials
50785078 for connection to the target domain.
50795079
5080+ . PARAMETER AllTypes
5081+
5082+ By default we will retrieve only Security, not Distribution Groups.
5083+
50805084 . EXAMPLE
50815085
50825086 PS C:\> Get-NetGroup
5083-
5084- Returns the current groups in the domain.
5087+
5088+ Returns the current security groups in the domain.
50855089
50865090 . EXAMPLE
50875091
50885092 PS C:\> Get-NetGroup -GroupName *admin*
5089-
5093+
50905094 Returns all groups with "admin" in their group name.
50915095
50925096 . EXAMPLE
50935097
50945098 PS C:\> Get-NetGroup -Domain testing -FullData
5095-
5099+
50965100 Returns full group data objects in the 'testing' domain
50975101#>
50985102
@@ -5113,10 +5117,10 @@ function Get-NetGroup {
51135117
51145118 [String ]
51155119 $Domain ,
5116-
5120+
51175121 [String ]
51185122 $DomainController ,
5119-
5123+
51205124 [String ]
51215125 $ADSpath ,
51225126
@@ -5129,7 +5133,10 @@ function Get-NetGroup {
51295133 [Switch ]
51305134 $RawSids ,
51315135
5132- [ValidateRange (1 , 10000 )]
5136+ [Switch ]
5137+ $AllTypes ,
5138+
5139+ [ValidateRange (1 , 10000 )]
51335140 [Int ]
51345141 $PageSize = 200 ,
51355142
@@ -5139,6 +5146,10 @@ function Get-NetGroup {
51395146
51405147 begin {
51415148 $GroupSearcher = Get-DomainSearcher - Domain $Domain - DomainController $DomainController - Credential $Credential - ADSpath $ADSpath - PageSize $PageSize
5149+ if (! $AllTypes )
5150+ {
5151+ $Filter += " (groupType:1.2.840.113556.1.4.803:=2147483648)"
5152+ }
51425153 }
51435154
51445155 process {
@@ -5193,7 +5204,7 @@ function Get-NetGroup {
51935204 else {
51945205 $GroupSearcher.filter = " (&(objectCategory=group)(samaccountname=$GroupName )$Filter )"
51955206 }
5196-
5207+
51975208 $Results = $GroupSearcher.FindAll ()
51985209 $Results | Where-Object {$_ } | ForEach-Object {
51995210 # if we're returning full data objects
0 commit comments