@@ -5105,22 +5105,26 @@ function Get-NetGroup {
5105
5105
A [Management.Automation.PSCredential] object of alternate credentials
5106
5106
for connection to the target domain.
5107
5107
5108
+ . PARAMETER AllTypes
5109
+
5110
+ By default we will retrieve only Security, not Distribution Groups.
5111
+
5108
5112
. EXAMPLE
5109
5113
5110
5114
PS C:\> Get-NetGroup
5111
-
5112
- Returns the current groups in the domain.
5115
+
5116
+ Returns the current security groups in the domain.
5113
5117
5114
5118
. EXAMPLE
5115
5119
5116
5120
PS C:\> Get-NetGroup -GroupName *admin*
5117
-
5121
+
5118
5122
Returns all groups with "admin" in their group name.
5119
5123
5120
5124
. EXAMPLE
5121
5125
5122
5126
PS C:\> Get-NetGroup -Domain testing -FullData
5123
-
5127
+
5124
5128
Returns full group data objects in the 'testing' domain
5125
5129
#>
5126
5130
@@ -5141,10 +5145,10 @@ function Get-NetGroup {
5141
5145
5142
5146
[String ]
5143
5147
$Domain ,
5144
-
5148
+
5145
5149
[String ]
5146
5150
$DomainController ,
5147
-
5151
+
5148
5152
[String ]
5149
5153
$ADSpath ,
5150
5154
@@ -5157,7 +5161,10 @@ function Get-NetGroup {
5157
5161
[Switch ]
5158
5162
$RawSids ,
5159
5163
5160
- [ValidateRange (1 , 10000 )]
5164
+ [Switch ]
5165
+ $AllTypes ,
5166
+
5167
+ [ValidateRange (1 , 10000 )]
5161
5168
[Int ]
5162
5169
$PageSize = 200 ,
5163
5170
@@ -5167,6 +5174,10 @@ function Get-NetGroup {
5167
5174
5168
5175
begin {
5169
5176
$GroupSearcher = Get-DomainSearcher - Domain $Domain - DomainController $DomainController - Credential $Credential - ADSpath $ADSpath - PageSize $PageSize
5177
+ if (! $AllTypes )
5178
+ {
5179
+ $Filter += " (groupType:1.2.840.113556.1.4.803:=2147483648)"
5180
+ }
5170
5181
}
5171
5182
5172
5183
process {
@@ -5221,7 +5232,7 @@ function Get-NetGroup {
5221
5232
else {
5222
5233
$GroupSearcher.filter = " (&(objectCategory=group)(samaccountname=$GroupName )$Filter )"
5223
5234
}
5224
-
5235
+
5225
5236
$Results = $GroupSearcher.FindAll ()
5226
5237
$Results | Where-Object {$_ } | ForEach-Object {
5227
5238
# if we're returning full data objects
@@ -5376,15 +5387,15 @@ function Get-NetGroupMember {
5376
5387
if ($Recurse -and $UseMatchingRule ) {
5377
5388
# resolve the group to a distinguishedname
5378
5389
if ($GroupName ) {
5379
- $Group = Get-NetGroup - GroupName $GroupName - Domain $TargetDomain - DomainController $TargetDomainController - Credential $Credential - FullData - PageSize $PageSize
5390
+ $Group = Get-NetGroup - AllTypes - GroupName $GroupName - Domain $TargetDomain - DomainController $TargetDomainController - Credential $Credential - FullData - PageSize $PageSize
5380
5391
}
5381
5392
elseif ($SID ) {
5382
- $Group = Get-NetGroup - SID $SID - Domain $TargetDomain - DomainController $TargetDomainController - Credential $Credential - FullData - PageSize $PageSize
5393
+ $Group = Get-NetGroup - AllTypes - SID $SID - Domain $TargetDomain - DomainController $TargetDomainController - Credential $Credential - FullData - PageSize $PageSize
5383
5394
}
5384
5395
else {
5385
5396
# default to domain admins
5386
5397
$SID = (Get-DomainSID - Domain $TargetDomain - DomainController $TargetDomainController ) + " -512"
5387
- $Group = Get-NetGroup - SID $SID - Domain $TargetDomain - DomainController $TargetDomainController - Credential $Credential - FullData - PageSize $PageSize
5398
+ $Group = Get-NetGroup - AllTypes - SID $SID - Domain $TargetDomain - DomainController $TargetDomainController - Credential $Credential - FullData - PageSize $PageSize
5388
5399
}
5389
5400
$GroupDN = $Group.distinguishedname
5390
5401
$GroupFoundName = $Group.samaccountname
@@ -13098,7 +13109,7 @@ function Find-ManagedSecurityGroups {
13098
13109
#>
13099
13110
13100
13111
# Go through the list of security groups on the domain and identify those who have a manager
13101
- Get-NetGroup - FullData - Filter ' (&( managedBy=*)(groupType:1.2.840.113556.1.4.803:=2147483648) )' | Select-Object - Unique distinguishedName, managedBy, cn | ForEach-Object {
13112
+ Get-NetGroup - FullData - Filter ' (managedBy=*)' | Select-Object - Unique distinguishedName, managedBy, cn | ForEach-Object {
13102
13113
13103
13114
# Retrieve the object that the managedBy DN refers to
13104
13115
$group_manager = Get-ADObject - ADSPath $_.managedBy | Select-Object cn, distinguishedname, name, samaccounttype, samaccountname
0 commit comments