@@ -5012,7 +5012,7 @@ function Get-DomainSID {
5012
5012
$DCSID.Substring (0 , $DCSID.LastIndexOf (' -' ))
5013
5013
}
5014
5014
else {
5015
- Write-Warning " Error extracting domain SID for $Domain "
5015
+ Write-Verbose " Error extracting domain SID for $Domain "
5016
5016
}
5017
5017
}
5018
5018
@@ -7043,20 +7043,26 @@ function Find-GPOLocation {
7043
7043
' PageSize' = $PageSize
7044
7044
}
7045
7045
7046
- # enumerate all GPO group mappings for the target domain
7046
+ # enumerate all GPO group mappings for the target domain that involve our target SID set
7047
7047
$GPOgroups = Get-NetGPOGroup @GPOGroupArgs | ForEach-Object {
7048
7048
7049
7049
$GPOgroup = $_
7050
7050
7051
- # if the locally set group is what we're looking for or the locally set group is a
7052
- # member of what we're looking for, check the GroupMembers for our target SID
7053
- if ( ( $GPOgroup.GroupSID -match $TargetLocalSID ) -or ( $GPOgroup .GroupMemberOf -contains $TargetLocalSID ) ) {
7051
+ # if the locally set group is what we're looking for, check the GroupMembers ('members')
7052
+ # for our target SID
7053
+ if ($GPOgroup.GroupSID -match $TargetLocalSID ) {
7054
7054
$GPOgroup.GroupMembers | Where-Object {$_ } | ForEach-Object {
7055
7055
if ( ($TargetSIDs [0 ] -eq ' *' ) -or ($TargetSIDs -Contains $_ ) ) {
7056
7056
$GPOgroup
7057
7057
}
7058
7058
}
7059
7059
}
7060
+ # if the group is a 'memberof' the group we're looking for, check GroupSID against the targt SIDs
7061
+ if ( ($GPOgroup.GroupMemberOf -contains $TargetLocalSID ) ) {
7062
+ if ( ($TargetSIDs [0 ] -eq ' *' ) -or ($TargetSIDs -Contains $GPOgroup.GroupSID ) ) {
7063
+ $GPOgroup
7064
+ }
7065
+ }
7060
7066
} | Sort-Object - Property GPOName - Unique
7061
7067
7062
7068
$GPOgroups | ForEach-Object {
@@ -7065,12 +7071,18 @@ function Find-GPOLocation {
7065
7071
$GPOguid = $_.GPOName
7066
7072
$GPOPath = $_.GPOPath
7067
7073
$GPOType = $_.GPOType
7068
- $GPOMembers = $_.GroupMembers
7074
+ if ($_.GroupMembers ) {
7075
+ $GPOMembers = $_.GroupMembers
7076
+ }
7077
+ else {
7078
+ $GPOMembers = $_.GroupSID
7079
+ }
7080
+
7069
7081
$Filters = $_.Filters
7070
7082
7071
7083
if (-not $TargetObject ) {
7072
7084
# if the * wildcard was used, set the ObjectDistName as the GPO member SID set
7073
- # so all relationship mappings are output
7085
+ # so all relationship mappings are output
7074
7086
$TargetObjectSIDs = $GPOMembers
7075
7087
}
7076
7088
else {
@@ -7306,8 +7318,7 @@ function Find-GPOComputerAdmin {
7306
7318
7307
7319
$TargetOUs | Where-Object {$_ } | ForEach-Object {
7308
7320
7309
- # for each OU the computer is a part of, get the full OU object
7310
- $GPOgroups += Get-NetOU - Domain $Domain - DomainController $DomainController - ADSpath $_ - FullData - PageSize $PageSize | ForEach-Object {
7321
+ $GPOLinks = Get-NetOU - Domain $Domain - DomainController $DomainController - ADSpath $_ - FullData - PageSize $PageSize | ForEach-Object {
7311
7322
# and then get any GPO links
7312
7323
if ($_.gplink ) {
7313
7324
$_.gplink.split (" ][" ) | ForEach-Object {
@@ -7316,25 +7327,39 @@ function Find-GPOComputerAdmin {
7316
7327
}
7317
7328
}
7318
7329
}
7319
- } | ForEach-Object {
7320
- $GPOGroupArgs = @ {
7321
- ' Domain' = $Domain
7322
- ' DomainController' = $DomainController
7323
- ' UsePSDrive' = $UsePSDrive
7324
- ' ResolveMemberSIDs' = $True
7325
- ' PageSize' = $PageSize
7330
+ }
7331
+
7332
+ $GPOGroupArgs = @ {
7333
+ ' Domain' = $Domain
7334
+ ' DomainController' = $DomainController
7335
+ ' UsePSDrive' = $UsePSDrive
7336
+ ' ResolveMemberSIDs' = $True
7337
+ ' PageSize' = $PageSize
7338
+ }
7339
+
7340
+ # extract GPO groups that are set through any gPlink for this OU
7341
+ $GPOGroups += Get-NetGPOGroup @GPOGroupArgs | ForEach-Object {
7342
+ ForEach ($GPOLink in $GPOLinks ) {
7343
+ $Name = $_.GPOName
7344
+ if ($GPOLink -like " *$Name *" ) {
7345
+ $_
7346
+ }
7326
7347
}
7327
- # for each GPO link, get any locally set user/group SIDs
7328
- Get-NetGPOGroup @GPOGroupArgs
7329
7348
}
7330
7349
}
7331
7350
7332
7351
# for each found GPO group, resolve the SIDs of the members
7333
7352
$GPOgroups | Sort-Object - Property GPOName - Unique | ForEach-Object {
7334
7353
$GPOGroup = $_
7335
7354
7336
- $GPOGroup.GroupMembers | ForEach-Object {
7355
+ if ($GPOGroup.GroupMembers ) {
7356
+ $GPOMembers = $GPOGroup.GroupMembers
7357
+ }
7358
+ else {
7359
+ $GPOMembers = $GPOGroup.GroupSID
7360
+ }
7337
7361
7362
+ $GPOMembers | ForEach-Object {
7338
7363
# resolve this SID to a domain object
7339
7364
$Object = Get-ADObject - Domain $Domain - DomainController $DomainController - PageSize $PageSize - SID $_
7340
7365
@@ -7349,8 +7374,8 @@ function Find-GPOComputerAdmin {
7349
7374
$GPOComputerAdmin | Add-Member Noteproperty ' GPODisplayName' $GPOGroup.GPODisplayName
7350
7375
$GPOComputerAdmin | Add-Member Noteproperty ' GPOGuid' $GPOGroup.GPOName
7351
7376
$GPOComputerAdmin | Add-Member Noteproperty ' GPOPath' $GPOGroup.GPOPath
7352
- $GPOComputerAdmin | Add-Member Noteproperty ' GPOType' $GPOType .GPOType
7353
- $GPOComputerAdmin
7377
+ $GPOComputerAdmin | Add-Member Noteproperty ' GPOType' $GPOGroup .GPOType
7378
+ $GPOComputerAdmin
7354
7379
7355
7380
# if we're recursing and the current result object is a group
7356
7381
if ($Recurse -and $GPOComputerAdmin.isGroup ) {
@@ -7685,7 +7710,7 @@ function Get-NetLocalGroup {
7685
7710
# 0 = success
7686
7711
if (($Result -eq 0 ) -and ($Offset -gt 0 )) {
7687
7712
7688
- # Work out how mutch to increment the pointer by finding out the size of the structure
7713
+ # Work out how much to increment the pointer by finding out the size of the structure
7689
7714
$Increment = $LOCALGROUP_MEMBERS_INFO_2 ::GetSize()
7690
7715
7691
7716
# parse all the result structures
@@ -7979,7 +8004,7 @@ filter Get-NetShare {
7979
8004
# 0 = success
7980
8005
if (($Result -eq 0 ) -and ($Offset -gt 0 )) {
7981
8006
7982
- # Work out how mutch to increment the pointer by finding out the size of the structure
8007
+ # Work out how much to increment the pointer by finding out the size of the structure
7983
8008
$Increment = $SHARE_INFO_1 ::GetSize()
7984
8009
7985
8010
# parse all the result structures
@@ -8073,7 +8098,7 @@ filter Get-NetLoggedon {
8073
8098
# 0 = success
8074
8099
if (($Result -eq 0 ) -and ($Offset -gt 0 )) {
8075
8100
8076
- # Work out how mutch to increment the pointer by finding out the size of the structure
8101
+ # Work out how much to increment the pointer by finding out the size of the structure
8077
8102
$Increment = $WKSTA_USER_INFO_1 ::GetSize()
8078
8103
8079
8104
# parse all the result structures
@@ -8175,7 +8200,7 @@ filter Get-NetSession {
8175
8200
# 0 = success
8176
8201
if (($Result -eq 0 ) -and ($Offset -gt 0 )) {
8177
8202
8178
- # Work out how mutch to increment the pointer by finding out the size of the structure
8203
+ # Work out how much to increment the pointer by finding out the size of the structure
8179
8204
$Increment = $SESSION_INFO_10 ::GetSize()
8180
8205
8181
8206
# parse all the result structures
@@ -8340,7 +8365,7 @@ filter Get-NetRDPSession {
8340
8365
8341
8366
if (($Result -ne 0 ) -and ($Offset -gt 0 )) {
8342
8367
8343
- # Work out how mutch to increment the pointer by finding out the size of the structure
8368
+ # Work out how much to increment the pointer by finding out the size of the structure
8344
8369
$Increment = $WTS_SESSION_INFO_1 ::GetSize()
8345
8370
8346
8371
# parse all the result structures
@@ -12573,6 +12598,7 @@ function Get-NetDomainTrust {
12573
12598
$DomainTrust | Add-Member Noteproperty ' ObjectGuid' " {$ObjectGuid }"
12574
12599
$DomainTrust | Add-Member Noteproperty ' TrustType' $ ($TrustAttrib -join ' ,' )
12575
12600
$DomainTrust | Add-Member Noteproperty ' TrustDirection' " $Direction "
12601
+ $DomainTrust.PSObject.TypeNames.Add (' PowerView.DomainTrustLDAP' )
12576
12602
$DomainTrust
12577
12603
}
12578
12604
$Results.dispose ()
@@ -12601,7 +12627,7 @@ function Get-NetDomainTrust {
12601
12627
# 0 = success
12602
12628
if (($Result -eq 0 ) -and ($Offset -gt 0 )) {
12603
12629
12604
- # Work out how mutch to increment the pointer by finding out the size of the structure
12630
+ # Work out how much to increment the pointer by finding out the size of the structure
12605
12631
$Increment = $DS_DOMAIN_TRUSTS ::GetSize()
12606
12632
12607
12633
# parse all the result structures
@@ -12650,7 +12676,10 @@ function Get-NetDomainTrust {
12650
12676
# if we're using direct domain connections through .NET
12651
12677
$FoundDomain = Get-NetDomain - Domain $Domain - Credential $Credential
12652
12678
if ($FoundDomain ) {
12653
- $FoundDomain.GetAllTrustRelationships ()
12679
+ $FoundDomain.GetAllTrustRelationships () | ForEach-Object {
12680
+ $_.PSObject.TypeNames.Add (' PowerView.DomainTrust' )
12681
+ $_
12682
+ }
12654
12683
}
12655
12684
}
12656
12685
}
@@ -12699,7 +12728,10 @@ function Get-NetForestTrust {
12699
12728
$FoundForest = Get-NetForest - Forest $Forest - Credential $Credential
12700
12729
12701
12730
if ($FoundForest ) {
12702
- $FoundForest.GetAllTrustRelationships ()
12731
+ $FoundForest.GetAllTrustRelationships () | ForEach-Object {
12732
+ $_.PSObject.TypeNames.Add (' PowerView.ForestTrust' )
12733
+ $_
12734
+ }
12703
12735
}
12704
12736
}
12705
12737
}
@@ -13144,9 +13176,10 @@ function Invoke-MapDomainTrust {
13144
13176
$TargetDomain = $Trust.TargetName
13145
13177
$TrustType = $Trust.TrustType
13146
13178
$TrustDirection = $Trust.TrustDirection
13179
+ $ObjectType = $Trust.PSObject.TypeNames | Where-Object {$_ -match ' PowerView' } | Select-Object - First 1
13147
13180
13148
13181
# make sure we process the target
13149
- $Null = $Domains.push ($TargetDomain )
13182
+ $Null = $Domains.Push ($TargetDomain )
13150
13183
13151
13184
# build the nicely-parsable custom output object
13152
13185
$DomainTrust = New-Object PSObject
@@ -13156,6 +13189,7 @@ function Invoke-MapDomainTrust {
13156
13189
$DomainTrust | Add-Member Noteproperty ' TargetSID' $Trust.TargetSID
13157
13190
$DomainTrust | Add-Member Noteproperty ' TrustType' " $TrustType "
13158
13191
$DomainTrust | Add-Member Noteproperty ' TrustDirection' " $TrustDirection "
13192
+ $DomainTrust.PSObject.TypeNames.Add ($ObjectType )
13159
13193
$DomainTrust
13160
13194
}
13161
13195
}
0 commit comments