@@ -19433,11 +19433,12 @@ Required Dependencies: Get-Domain, Get-DomainSearcher, Get-DomainSID, PSReflect
19433
19433
.DESCRIPTION
19434
19434
19435
19435
This function will enumerate domain trust relationships for the current (or a remote)
19436
- domain using a number of methods. By default, the .NET method GetAllTrustRelationships()
19437
- is used on the System.DirectoryServices.ActiveDirectory.Domain object. If the -LDAP flag
19438
- is specified, or any of the LDAP-appropriate parameters, an LDAP search using the filter
19439
- '(objectClass=trustedDomain)' is used instead. If the -API flag is specified, the
19440
- Win32 API DsEnumerateDomainTrusts() call is used to enumerate instead.
19436
+ domain using a number of methods. By default, and LDAP search using the filter
19437
+ '(objectClass=trustedDomain)' is used- if any LDAP-appropriate parameters are specified
19438
+ LDAP is used as well. If the -NET flag is specified, the .NET method
19439
+ GetAllTrustRelationships() is used on the System.DirectoryServices.ActiveDirectory.Domain
19440
+ object. If the -API flag is specified, the Win32 API DsEnumerateDomainTrusts() call is
19441
+ used to enumerate instead.
19441
19442
19442
19443
.PARAMETER Domain
19443
19444
@@ -19448,9 +19449,9 @@ Specifies the domain to query for trusts, defaults to the current domain.
19448
19449
Switch. Use an API call (DsEnumerateDomainTrusts) to enumerate the trusts instead of the built-in
19449
19450
.NET methods.
19450
19451
19451
- .PARAMETER LDAP
19452
+ .PARAMETER NET
19452
19453
19453
- Switch. Use LDAP queries to enumerate the trusts instead of direct domain connections .
19454
+ Switch. Use .NET queries to enumerate trusts instead of the default LDAP method .
19454
19455
19455
19456
.PARAMETER LDAPFilter
19456
19457
@@ -19498,19 +19499,19 @@ for connection to the target domain.
19498
19499
19499
19500
Get-DomainTrust
19500
19501
19501
- Return domain trusts for the current domain using built in .NET methods.
19502
+ Return domain trusts for the current domain using built in .LDAP methods.
19502
19503
19503
19504
.EXAMPLE
19504
19505
19505
- Get-DomainTrust -Domain "prod.testlab.local"
19506
+ Get-DomainTrust -NET - Domain "prod.testlab.local"
19506
19507
19507
19508
Return domain trusts for the "prod.testlab.local" domain using .NET methods
19508
19509
19509
19510
.EXAMPLE
19510
19511
19511
19512
$SecPassword = ConvertTo-SecureString 'Password123!' -AsPlainText -Force
19512
19513
$Cred = New-Object System.Management.Automation.PSCredential('TESTLAB\dfm.a', $SecPassword)
19513
- Get-DomainTrust -LDAP - Domain "prod.testlab.local" -Server "PRIMARY.testlab.local" -Credential $Cred
19514
+ Get-DomainTrust -Domain "prod.testlab.local" -Server "PRIMARY.testlab.local" -Credential $Cred
19514
19515
19515
19516
Return domain trusts for the "prod.testlab.local" domain enumerated through LDAP
19516
19517
queries, binding to the PRIMARY.testlab.local server for queries, and using the specified
@@ -19524,13 +19525,13 @@ Return domain trusts for the "prod.testlab.local" domain enumerated through API
19524
19525
19525
19526
.OUTPUTS
19526
19527
19527
- PowerView.DomainTrust.NET
19528
+ PowerView.DomainTrust.LDAP
19528
19529
19529
- A TrustRelationshipInformationCollection returned when using .NET methods (default).
19530
+ Custom PSObject with translated domain LDAP trust result fields (default).
19530
19531
19531
- PowerView.DomainTrust.LDAP
19532
+ PowerView.DomainTrust.NET
19532
19533
19533
- Custom PSObject with translated domain LDAP trust result fields .
19534
+ A TrustRelationshipInformationCollection returned when using .NET methods .
19534
19535
19535
19536
PowerView.DomainTrust.API
19536
19537
@@ -19541,7 +19542,7 @@ Custom PSObject with translated domain API trust result fields.
19541
19542
[OutputType('PowerView.DomainTrust.NET')]
19542
19543
[OutputType('PowerView.DomainTrust.LDAP')]
19543
19544
[OutputType('PowerView.DomainTrust.API')]
19544
- [CmdletBinding(DefaultParameterSetName = 'NET ')]
19545
+ [CmdletBinding(DefaultParameterSetName = 'LDAP ')]
19545
19546
Param(
19546
19547
[Parameter(Position = 0, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)]
19547
19548
[Alias('Name')]
@@ -19553,9 +19554,9 @@ Custom PSObject with translated domain API trust result fields.
19553
19554
[Switch]
19554
19555
$API,
19555
19556
19556
- [Parameter(ParameterSetName = 'LDAP ')]
19557
+ [Parameter(ParameterSetName = 'NET ')]
19557
19558
[Switch]
19558
- $LDAP ,
19559
+ $NET ,
19559
19560
19560
19561
[Parameter(ParameterSetName = 'LDAP')]
19561
19562
[ValidateNotNullOrEmpty()]
@@ -19612,17 +19613,17 @@ Custom PSObject with translated domain API trust result fields.
19612
19613
19613
19614
BEGIN {
19614
19615
$TrustAttributes = @{
19615
- [uint32]'0x00000001' = 'non_transitive '
19616
- [uint32]'0x00000002' = 'uplevel_only '
19617
- [uint32]'0x00000004' = 'quarantined_domain '
19618
- [uint32]'0x00000008' = 'forest_transitive '
19619
- [uint32]'0x00000010' = 'cross_organization '
19620
- [uint32]'0x00000020' = 'within_forest '
19621
- [uint32]'0x00000040' = 'treat_as_external '
19622
- [uint32]'0x00000080' = 'trust_uses_rc4_encryption '
19623
- [uint32]'0x00000100' = 'trust_uses_aes_keys '
19624
- [uint32]'0x00000200' = 'cross_organization_no_tgt_delegation '
19625
- [uint32]'0x00000400' = 'pim_trust '
19616
+ [uint32]'0x00000001' = 'NON_TRANSITIVE '
19617
+ [uint32]'0x00000002' = 'UPLEVEL_ONLY '
19618
+ [uint32]'0x00000004' = 'FILTER_SIDS '
19619
+ [uint32]'0x00000008' = 'FOREST_TRANSITIVE '
19620
+ [uint32]'0x00000010' = 'CROSS_ORGANIZATION '
19621
+ [uint32]'0x00000020' = 'WITHIN_FOREST '
19622
+ [uint32]'0x00000040' = 'TREAT_AS_EXTERNAL '
19623
+ [uint32]'0x00000080' = 'TRUST_USES_RC4_ENCRYPTION '
19624
+ [uint32]'0x00000100' = 'TRUST_USES_AES_KEYS '
19625
+ [uint32]'0x00000200' = 'CROSS_ORGANIZATION_NO_TGT_DELEGATION '
19626
+ [uint32]'0x00000400' = 'PIM_TRUST '
19626
19627
}
19627
19628
19628
19629
$LdapSearcherArguments = @{}
@@ -19689,16 +19690,25 @@ Custom PSObject with translated domain API trust result fields.
19689
19690
3 { 'Bidirectional' }
19690
19691
}
19691
19692
19693
+ $TrustType = Switch ($Props.trusttype) {
19694
+ 1 { 'WINDOWS_NON_ACTIVE_DIRECTORY' }
19695
+ 2 { 'WINDOWS_ACTIVE_DIRECTORY' }
19696
+ 3 { 'MIT' }
19697
+ }
19698
+
19692
19699
$ObjectGuid = New-Object Guid @(,$Props.objectguid[0])
19693
19700
$TargetSID = (New-Object System.Security.Principal.SecurityIdentifier($Props.securityidentifier[0],0)).Value
19694
19701
19695
19702
$DomainTrust | Add-Member Noteproperty 'SourceName' $SourceDomain
19696
19703
$DomainTrust | Add-Member Noteproperty 'SourceSID' $SourceSID
19697
19704
$DomainTrust | Add-Member Noteproperty 'TargetName' $Props.name[0]
19698
19705
$DomainTrust | Add-Member Noteproperty 'TargetSID' $TargetSID
19699
- $DomainTrust | Add-Member Noteproperty 'ObjectGuid' "{$ObjectGuid}"
19700
- $DomainTrust | Add-Member Noteproperty 'TrustType' $($TrustAttrib -join ',')
19706
+ # $DomainTrust | Add-Member Noteproperty 'TargetGuid' "{$ObjectGuid}"
19707
+ $DomainTrust | Add-Member Noteproperty 'TrustType' $TrustType
19708
+ $DomainTrust | Add-Member Noteproperty 'TrustAttributes' $($TrustAttrib -join ',')
19701
19709
$DomainTrust | Add-Member Noteproperty 'TrustDirection' "$Direction"
19710
+ $DomainTrust | Add-Member Noteproperty 'WhenCreated' $Props.whencreated[0]
19711
+ $DomainTrust | Add-Member Noteproperty 'WhenChanged' $Props.whenchanged[0]
19702
19712
$DomainTrust.PSObject.TypeNames.Insert(0, 'PowerView.DomainTrust.LDAP')
19703
19713
$DomainTrust
19704
19714
}
@@ -20308,20 +20318,21 @@ Required Dependencies: Get-Domain, Get-DomainTrust, Get-ForestTrust
20308
20318
20309
20319
This function will enumerate domain trust relationships for the current domain using
20310
20320
a number of methods, and then enumerates all trusts for each found domain, recursively
20311
- mapping all reachable trust relationships. By default, the .NET method GetAllTrustRelationships()
20312
- is used on the System.DirectoryServices.ActiveDirectory.Domain object. If the -LDAP flag
20313
- is specified, or any of the LDAP-appropriate parameters, an LDAP search using the filter
20314
- '(objectClass=trustedDomain)' is used instead. If the -API flag is specified, the
20315
- Win32 API DsEnumerateDomainTrusts() call is used to enumerate instead.
20321
+ mapping all reachable trust relationships. By default, and LDAP search using the filter
20322
+ '(objectClass=trustedDomain)' is used- if any LDAP-appropriate parameters are specified
20323
+ LDAP is used as well. If the -NET flag is specified, the .NET method
20324
+ GetAllTrustRelationships() is used on the System.DirectoryServices.ActiveDirectory.Domain
20325
+ object. If the -API flag is specified, the Win32 API DsEnumerateDomainTrusts() call is
20326
+ used to enumerate instead. If any
20316
20327
20317
20328
.PARAMETER API
20318
20329
20319
- Switch. Use an API call (DsEnumerateDomainTrusts) to enumerate the trusts instead of the built-in
20320
- .NET methods .
20330
+ Switch. Use an API call (DsEnumerateDomainTrusts) to enumerate the trusts instead of the
20331
+ built-in LDAP method .
20321
20332
20322
- .PARAMETER LDAP
20333
+ .PARAMETER NET
20323
20334
20324
- Switch. Use LDAP queries to enumerate the trusts instead of direct domain connections .
20335
+ Switch. Use .NET queries to enumerate trusts instead of the default LDAP method .
20325
20336
20326
20337
.PARAMETER LDAPFilter
20327
20338
@@ -20375,29 +20386,28 @@ Map all reachable domain trusts using Win32 API calls and output everything to a
20375
20386
20376
20387
.EXAMPLE
20377
20388
20378
- Get-DomainTrustMapping -LDAP -Server 'PRIMARY.testlab.local' | Export-CSV -NoTypeInformation trusts.csv
20389
+ Get-DomainTrustMapping -NET | Export-CSV -NoTypeInformation trusts.csv
20379
20390
20380
- Map all reachable domain trusts using LDAP, binding to the PRIMARY.testlab.local server for queries,
20381
- and output everything to a .csv file.
20391
+ Map all reachable domain trusts using .NET methods and output everything to a .csv file.
20382
20392
20383
20393
.EXAMPLE
20384
20394
20385
20395
$SecPassword = ConvertTo-SecureString 'Password123!' -AsPlainText -Force
20386
20396
$Cred = New-Object System.Management.Automation.PSCredential('TESTLAB\dfm.a', $SecPassword)
20387
- Get-DomainTrustMapping -LDAP - Server 'PRIMARY.testlab.local' | Export-CSV -NoTypeInformation trusts.csv
20397
+ Get-DomainTrustMapping -Server 'PRIMARY.testlab.local' | Export-CSV -NoTypeInformation trusts.csv
20388
20398
20389
20399
Map all reachable domain trusts using LDAP, binding to the PRIMARY.testlab.local server for queries
20390
20400
using the specified alternate credentials, and output everything to a .csv file.
20391
20401
20392
20402
.OUTPUTS
20393
20403
20394
- PowerView.DomainTrust.NET
20404
+ PowerView.DomainTrust.LDAP
20395
20405
20396
- A TrustRelationshipInformationCollection returned when using .NET methods (default).
20406
+ Custom PSObject with translated domain LDAP trust result fields (default).
20397
20407
20398
- PowerView.DomainTrust.LDAP
20408
+ PowerView.DomainTrust.NET
20399
20409
20400
- Custom PSObject with translated domain LDAP trust result fields .
20410
+ A TrustRelationshipInformationCollection returned when using .NET methods .
20401
20411
20402
20412
PowerView.DomainTrust.API
20403
20413
@@ -20408,15 +20418,15 @@ Custom PSObject with translated domain API trust result fields.
20408
20418
[OutputType('PowerView.DomainTrust.NET')]
20409
20419
[OutputType('PowerView.DomainTrust.LDAP')]
20410
20420
[OutputType('PowerView.DomainTrust.API')]
20411
- [CmdletBinding(DefaultParameterSetName = 'NET ')]
20421
+ [CmdletBinding(DefaultParameterSetName = 'LDAP ')]
20412
20422
Param(
20413
20423
[Parameter(ParameterSetName = 'API')]
20414
20424
[Switch]
20415
20425
$API,
20416
20426
20417
- [Parameter(ParameterSetName = 'LDAP ')]
20427
+ [Parameter(ParameterSetName = 'NET ')]
20418
20428
[Switch]
20419
- $LDAP ,
20429
+ $NET ,
20420
20430
20421
20431
[Parameter(ParameterSetName = 'LDAP')]
20422
20432
[ValidateNotNullOrEmpty()]
@@ -20475,7 +20485,7 @@ Custom PSObject with translated domain API trust result fields.
20475
20485
20476
20486
$DomainTrustArguments = @{}
20477
20487
if ($PSBoundParameters['API']) { $DomainTrustArguments['API'] = $API }
20478
- if ($PSBoundParameters['LDAP ']) { $DomainTrustArguments['LDAP '] = $LDAP }
20488
+ if ($PSBoundParameters['NET ']) { $DomainTrustArguments['NET '] = $NET }
20479
20489
if ($PSBoundParameters['LDAPFilter']) { $DomainTrustArguments['LDAPFilter'] = $LDAPFilter }
20480
20490
if ($PSBoundParameters['Properties']) { $DomainTrustArguments['Properties'] = $Properties }
20481
20491
if ($PSBoundParameters['SearchBase']) { $DomainTrustArguments['SearchBase'] = $SearchBase }
@@ -20517,7 +20527,7 @@ Custom PSObject with translated domain API trust result fields.
20517
20527
}
20518
20528
20519
20529
# get any forest trusts, if they exist
20520
- if ($PsCmdlet.ParameterSetName -eq 'LDAP ') {
20530
+ if ($PsCmdlet.ParameterSetName -eq 'NET ') {
20521
20531
$ForestTrustArguments = @{}
20522
20532
if ($PSBoundParameters['Forest']) { $ForestTrustArguments['Forest'] = $Forest }
20523
20533
if ($PSBoundParameters['Credential']) { $ForestTrustArguments['Credential'] = $Credential }
@@ -20547,8 +20557,7 @@ Custom PSObject with translated domain API trust result fields.
20547
20557
}
20548
20558
20549
20559
20550
- function Get-GPODelegation
20551
- {
20560
+ function Get-GPODelegation {
20552
20561
<#
20553
20562
.SYNOPSIS
20554
20563
@@ -20589,7 +20598,7 @@ Returns all GPO delegations on a given GPO.
20589
20598
$PageSize = 200
20590
20599
)
20591
20600
20592
- $Exclusions = @(" SYSTEM"," Domain Admins"," Enterprise Admins" )
20601
+ $Exclusions = @(' SYSTEM',' Domain Admins',' Enterprise Admins' )
20593
20602
20594
20603
$Forest = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest()
20595
20604
$DomainList = @($Forest.Domains)
0 commit comments