PowerShellEmpire / PowerTools

PowerTools is a collection of PowerShell projects with a focus on offensive operations.
Other
2.03k stars 817 forks source link

Get-OUs #48

Closed Meatballs1 closed 8 years ago

Meatballs1 commented 8 years ago

Something along the lines of:

function Get-OUs {
    $info = ([adsisearcher]"objectclass=organizationalunit")
    $info.PropertiesToLoad.AddRange("CanonicalName")
    $info.findall().properties.canonicalname
}
HarmJ0y commented 8 years ago

So something different than https://github.com/PowerShellEmpire/PowerTools/blob/9f3f2ba6f6daf37749833b416d498be94fc3789e/PowerView/powerview.ps1#L2815 ?

Meatballs1 commented 8 years ago

Ah no :) Just couldn't find it

HarmJ0y commented 8 years ago

There's also now an option in Get-NetUser and Get-NetComputer which allows you to specify the ADSpath/OU/etc. for querying users/computers from particular OUs https://github.com/PowerShellEmpire/PowerTools/blob/5b8f4acf1ec51da40e3ffda5599668dbc13b01a2/PowerView/powerview.ps1#L2559 . Still needs some more testing, but seems to work nicely when combined with Get-NetGuidOU (https://github.com/PowerShellEmpire/PowerTools/blob/5b8f4acf1ec51da40e3ffda5599668dbc13b01a2/PowerView/powerview.ps1#L2855) to pull OUs that GPP is applied to, and then extracting the machines from that particular OU easily :)

Meatballs1 commented 8 years ago

It would also be handy for Get-NetGroup as often see things like OU=Admins which contain the more interesting groups :)

Although I expect if you refactor more methods with the Get-DomainSearcher helper this parameter can be supported by default?