Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Cant return string for msExchMailboxGUID

$
0
0

Hi All,

I am trying to get users msExchMailboxGUID as a string using the function below, however the msExchMailboxGUID is being returned as System.Byte[]. Any idea how to get this to display as a string?

Function Get-ADProps {
                                $root = [ADSI]"LDAP://*******"
                                $people = Import-Csv .\users.csv
                                $searcher = new-object System.DirectoryServices.DirectorySearcher($root)      
                $ADObjects = @()
                                ForEach($person in $people){
                                                                $ADuser = $person.InternetAddress
                                                                $searcher.filter = "(&(objectClass=user)(mail=$ADUser))"
                                                                $users = $searcher.FindAll()
                                Foreach($user in $users)
                                {
                                                                [Array]$propertiesList = $user.Properties.PropertyNames
                                                                $obj = New-Object PSObject
                                                                Foreach($property in $propertiesList)
                                                                {
                                                                                $obj | add-member -membertype noteproperty -name $property -value ([string]$user.Properties.Item($property))
                                                                }

                                                                $ADObjects += $obj
                                                }
                }
                Return $ADObjects
}

Get-ADProps | Select msExchMailboxGUID, SAMaccountName

Regards,

Michael. 


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>