####################################################################
# Assuming that a different name is passed to this value in some type of loop, the function will return the user's DN.
function Get-userDN($user){
return ((Get-QADUser $user -IncludedProperties DN).DN)
}
####################################################################
# Again, assuming that a user's DN is passed to this function in #some type of look, the function will obtain the user's email #server name.
function Get-userServerName($userDN){
return ((Get-QADUser -Identity $userDN -IncludedProperties msExchHomeServerName).msExchHomeServerName)
}
#################################################################
# This function will extract the server's name from the email #server name DN
function Get-homeServer([string]$DN){
return ($DN.replace('/','') -split ",*..=")[4]
}
##################################################################
#This is how I usually export info to a CSV file. However, I #usually use the Get-QAD...cmdlet. Never tried more complex scripts #with functions and such.
$users = Get-Content -Path 'C:\users.txt'
@(ForEach($user in $users){
Get-QADUser -Identity $user -IncludedProperties name,msExchHomeServerName | select name,msExchHomeServerName
}) | Export-Csv C:\output.csv -NoType
|