Greetings,
Request:
Trying to run a PowerShell script in Exchange in order to generate CSV report to of users.
I have the following script and it's working fine, except the last attribute "msExchMailboxGUID" returned the output as "System.Byte[]"
Import-Module ActiveDirectory
$FormatEnumerationLimit =-1
$Users=get-aduser -SearchBase "DC=ans,DC=red" -filter * -Properties DisplayName, mail, DistinguishedName, objectGUID, msExchMailboxGUID
# Setup the Table
$table = New-Object System.Data.DataTable
$table.Columns.Add("DisplayName","string") | Out-Null
$table.Columns.Add("Mail","string") | Out-Null
$table.Columns.Add("DistinguishedName", "string") | Out-Null
$table.Columns.Add("objectGUID","string") | Out-Null
$table.Columns.Add("msExchMailboxGUID","string") | Out-Null
$userNumber = 1
ForEach($user in $users)
{
# Define a new row object
$r = $table.NewRow()
#Add field to the row
$r.DisplayName = $user.DisplayName
# Add field to the row
$r.Mail = $user.Mail
# Add field to the row
$r.DistinguishedName = $user.DistinguishedName
# Add field to the row
$r.objectGUID = $user.objectguid
# Add field to the row
$r.msExchMailboxGUID = $user.msExchMailboxGUID
# Add the row to the table
$table.Rows.Add($r)
Write-Host "Processing user: " $userNumber
$userNumber = $userNumber + 1
}
#$table | Format-table
$table | Export-Csv -Path C:\AD-users-dump-exchange.csv -NoTypeInformation
Example of the output
Help:
Can someone help please from the PowerShell community to tweak the script in order to convert correctly the HEXA msExchMailboxGUID into actual attribute value?
Thank you all!