Advertisement
Old-Lost

Get all domains info

Jan 26th, 2017
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (([System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest()).GetAllTrustRelationships() | ? TrustType -eq 'Forest' | % TrustedDomainInformation | % { [pscustomobject]@{DomainName=$_.DNSName;NetBIOSName=$_.NetBIOSName;DomainSID=$_.DomainSid}}) + (Get-ADDomain | % { [pscustomobject]@{DomainName=$_.DNSRoot;NetBIOSName=$_.NetBIOSName;DomainSID=$_.DomainSid}}) | Sort-Object -Property DomainName -Unique
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement