Skip to content

Instantly share code, notes, and snippets.

@brettmillerb
Created August 9, 2018 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brettmillerb/d468c84e24c19cf06178fdcce03a5228 to your computer and use it in GitHub Desktop.
Save brettmillerb/d468c84e24c19cf06178fdcce03a5228 to your computer and use it in GitHub Desktop.
function Get-ADSystemInfo{
<#
.LINK
https://technet.microsoft.com/en-us/library/ee198776.aspx
#>
$properties = @(
'UserName',
'ComputerName',
'SiteName',
'DomainShortName',
'DomainDNSName',
'ForestDNSName',
'PDCRoleOwner',
'SchemaRoleOwner',
'IsNativeMode'
)
$ads = New-Object -ComObject ADSystemInfo
$type = $ads.GetType()
$hash = @{}
foreach($p in $properties){
$hash.Add($p,$type.InvokeMember($p,'GetProperty', $Null, $ads, $Null))
}
[pscustomobject]$hash
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment