Guys, I am having some issues with this script. I have removed all the working attributes from it , just leaving me with two. both are DN AD attributes for Secretary and seeAlso
If each attribute has a single entry they seem to display the first name and last name but if they contain multiple entries then i get a System.Object{} in the CSV export.
Any ideas , i am pulling my hair out LOL…
Import-Module ActiveRolesManagementShell
Connect-QADService -Service “AR-Server-Name-Here” -Proxy
$OUName = “OU_Name_Here”
$CSVName = “C:\Export.csv”$Report = @()
foreach ($user in (Get-QADUser -SearchRoot $OUName -SizeLimit 0 -IncludedProperties Secretary , seealso )) {
try { $Secretary = Get-QADUser $user.Secretary -ErrorAction Stop $sName = "$($Secretary.FirstName) $($Secretary.LastName)" $sPhone = $Secretary.homephone } catch { $sName = '' }
try {
$SeeAlso = Get-QADUser $user.SeeAlso -ErrorAction Stop
$sSeeAlso = “$($SeeAlso.FirstName) $($SeeAlso.LastName)”} catch { $sSeeAlso = '' } $Report += New-Object PSObject -Property @{ 'SamAccountName' = $user.SamAccountName 'Secretary' = $sName 'seeAlso' = $sSeeAlso }
}
$Report | Select-Object SamAccountName , Secretary , SeeAlso | Export-Csv -path $CSVName -NoTypeInformation -Force -Encoding UTF8