Needed to export the Computer Name and all the local Admins for a particular OU
Used the following Powershell script to export the details
Used the following Powershell script to export the details
$computers = Get-ADComputer -SearchBase
"OU=Servers,OU=Computers,OU=ABC,DC=XYZ,DC=Domain,DC=com" -Filter *
| %{$_.name}
foreach($computer in $computers)
{
$computer
$s1 = $null
$ADSIComputer = [ADSI]("WinNT://$computer,computer")
$adminGroup =
$ADSIComputer.psbase.children.find('Administrators', 'Group')
$adminMembers =
$adminGroup.psbase.invoke("members") |
%{$_.GetType().InvokeMember("Name",'GetProperty',$null,$_,$null)} |
%{$s1 += $_ + ","}
$computer + "," + $s1.Trim(",") >>
.\LocalAdmins.csv
}
Hope this helps
Comments
Post a Comment