EvotecIT / ADEssentials

PowerShell Active Directory helper functions to manage healthy Active Directory
MIT License
429 stars 51 forks source link

Get-WinADForestDetails not working with WAN-Optimizer #32

Open DonDom86 opened 2 years ago

DonDom86 commented 2 years ago

If there are WAN-Optimizer in an active directory environment this function is not working. This is because Get-ADDomainController -Filter * Small change and it will also work in these environments.

$DomainControllers = Get-ADDomainController -Filter $Filter -Server $QueryServer -ErrorAction Stop

$DomainControllers = (Get-ADDomain -Identity $Domain).ReplicaDirectoryServers | ForEach { Get-ADDomainController -Identity $_ -Server $QueryServer }

This change should be done in multiple modules our maybe a chance for refactoring? image

PrzemyslawKlys commented 2 years ago

This is coming from a single module: https://github.com/EvotecIT/PSSharedGoods/blob/master/Public/ActiveDirectory/Get-WinADForestDetails.ps1

During deployment the function is merged for those modules so that you don't need pssharedgoods for all modules. So if you modify it there, next release for all modules it will fix itself.

You would need to tell me more what happens with WAN Optimizer because I am not sure what happens? Also in future I would like to remove dependency on Get-ADDomain and use non-rsat way

DonDom86 commented 2 years ago

Hopefully this can help :-)

` PS C:\Windows\system32> $Filter = "*" $QueryServer = $env:COMPUTERNAME $Domain = $env:USERDOMAIN $Test1 = Get-ADDomainController -Filter $Filter -Server $QueryServer -ErrorAction Stop

$Test2 = (Get-ADDomain -Identity $Domain).ReplicaDirectoryServers | ForEach { Get-ADDomainController -Identity $_ -Server $QueryServer } $Test2.count Get-ADDomainController : Directory object not found At line:4 char:10

30

PS C:\Windows\system32>
`

PrzemyslawKlys commented 2 years ago

Can you tell e what sort of this WAN optimizer is ? is it some product or what?

DonDom86 commented 2 years ago

For example

https://www.riverbed.com/de/products/steelhead

DonDom86 commented 2 years ago

It's a bad implementation of the riverbed, because this appliance is a "fake rodc.

https://social.technet.microsoft.com/Forums/windowsserver/en-US/5260ae0c-79c7-459a-ae01-168098e5d220/getaddomaincontroller-directory-object-not-found?forum=winserverpowershell