Export isn't showing PC Name

Hey Everyone,

New to Powershell scripting and could use a little help. I modified this script to pull the local admins from all PC’s in an OU and generate a CSV. The script runs fine, the output isn’t exactly what i’m looking for and not sure how to fix. Below is the script and the CSV output (I highlighted both lines in bold red that I need help with). Where it has “System.DirectoryServices.SearchResult” I would like to have the PC DNS name. Thank you in advance for all of your help!

 

 

Import-Module ActiveDirectory
$Searcher = New-Object DirectoryServices.DirectorySearcher([ADSI]"")
$Searcher.SearchRoot = ‘LDAP://OU=Staging,OU=Computers,OU=COMPANY,DC=corp,DC=local’
$Searcher.Filter = “(objectClass=computer)”
$Computers = ($Searcher.Findall())

$Results = @()
md C:\All_Local_Admins

Foreach ($Computer in $Computers){
$Path=$Computer.Path
$Name=([ADSI]"$Path").Name
write-host $Name
$members =[ADSI]“WinNT://$Name/Administrators”
$members = @($members.psbase.Invoke(“Members”))
$members | foreach {
$LocalAdmins = $.GetType().InvokeMember(“Name”, ‘GetProperty’, $null, $, $null) # Create a new object for the purpose of exporting as a CSV
$pubObject = new-object PSObject
$pubObject | add-member -membertype NoteProperty -name “Server” -Value $Name
$pubObject | add-member -membertype NoteProperty -name “Computer” -Value $Computer
$pubObject | add-member -membertype NoteProperty -name “Administrators” -Value $LocalAdmins

# Append this iteration of our for loop to our results array.
$Results += $pubObject
}
}

$Results | Export-Csv -Path “C:\All_Local_Admins\ServerLocalAdmins.csv” -NoTypeInformation
$Results = $Null

 

 

Server Computer Administrators
System.DirectoryServices.PropertyValueCollection System.DirectoryServices.SearchResult Administrator