Skip to content

Commit

Permalink
Retrieve Security groups by default
Browse files Browse the repository at this point in the history
  • Loading branch information
Meatballs1 committed Aug 13, 2016
1 parent 869badc commit 462c6e8
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions Recon/PowerView.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5077,22 +5077,26 @@ function Get-NetGroup {
A [Management.Automation.PSCredential] object of alternate credentials
for connection to the target domain.
.PARAMETER AllTypes
By default we will retrieve only Security, not Distribution Groups.
.EXAMPLE
PS C:\> Get-NetGroup
Returns the current groups in the domain.
Returns the current security groups in the domain.
.EXAMPLE
PS C:\> Get-NetGroup -GroupName *admin*
Returns all groups with "admin" in their group name.
.EXAMPLE
PS C:\> Get-NetGroup -Domain testing -FullData
Returns full group data objects in the 'testing' domain
#>

Expand All @@ -5113,10 +5117,10 @@ function Get-NetGroup {

[String]
$Domain,

[String]
$DomainController,

[String]
$ADSpath,

Expand All @@ -5129,7 +5133,10 @@ function Get-NetGroup {
[Switch]
$RawSids,

[ValidateRange(1,10000)]
[Switch]
$AllTypes,

[ValidateRange(1,10000)]
[Int]
$PageSize = 200,

Expand All @@ -5139,6 +5146,10 @@ function Get-NetGroup {

begin {
$GroupSearcher = Get-DomainSearcher -Domain $Domain -DomainController $DomainController -Credential $Credential -ADSpath $ADSpath -PageSize $PageSize
if (!$AllTypes)
{
$Filter += "(groupType:1.2.840.113556.1.4.803:=2147483648)"
}
}

process {
Expand Down Expand Up @@ -5193,7 +5204,7 @@ function Get-NetGroup {
else {
$GroupSearcher.filter = "(&(objectCategory=group)(samaccountname=$GroupName)$Filter)"
}

$Results = $GroupSearcher.FindAll()
$Results | Where-Object {$_} | ForEach-Object {
# if we're returning full data objects
Expand Down

0 comments on commit 462c6e8

Please sign in to comment.