Page 2 of 2

Re: Problem with filling out textbox

Posted: Thu Jan 07, 2016 9:09 am
by jvierra
$txtbox_exmail.Text = (Get-Mailbox -Anr $txtbox_search.Text ).PrimaryEmailAddress

Re: Problem with filling out textbox

Posted: Thu Jan 07, 2016 9:11 am
by jvierra
OR do this:

Code: Select all

if($address=(Get-Mailbox -Anr $txtbox_search.Text).PrimaryEmailAddress){
$txtbox_exmail.Text = $address
}else{
$txtbox_exmail.Text = 'NOT FOUND'
}

Re: Problem with filling out textbox

Posted: Thu Jan 07, 2016 9:14 am
by alwo23@hotmail.com
Ok i understood.
Now i need the proxy addresses without smtp:

$smtp = get-aduser -Filter { DisplayName -eq "Nick Schiller" } -prop proxyaddresses | select -exp proxyaddresses
$smtp.TrimStart("smtp:")

Correct?

Re: Problem with filling out textbox

Posted: Thu Jan 07, 2016 1:13 pm
by dan.potter
I believe sort will put the uppercase on the top all the time, at least it does in my case.

((get-aduser mysam -properties proxyaddresses).proxyaddresses | ? {$_ -like "smtp:*"} |sort ) -replace 'smtp:'

Re: Problem with filling out textbox

Posted: Thu Jan 07, 2016 1:52 pm
by jvierra
As I pointed out above:

(Get-AdUser userid -Prop mail).Mail


This is the same as the SMTP:nnm,sdnf,nd without the SMTP: AD manages the address that way.

Also:
(Get-Maibox userid).PrimaryAddress
And is the same value and is placed there for convenience.

Exchange maintains all of these addresses.

Re: Problem with filling out textbox

Posted: Fri Jan 08, 2016 5:16 am
by dan.potter
The mail attribute isn't mandatory, I wouldn't trust that one unless your standards are very strict. I thought he wanted all of them in a list.

Re: Problem with filling out textbox

Posted: Fri Jan 08, 2016 6:27 am
by jvierra
dan.potter wrote:The mail attribute isn't mandatory, I wouldn't trust that one unless your standards are very strict. I thought he wanted all of them in a list.
TH]he attribute is always filled in when an Exchange mailbox is defined. Exchange sets it and will reset it if the addressing rules are set up correctly.

The users PrimaryAddress is also managed only by Exchange. THe WindowsPrimaryAddress is managed by Exchange and copied to User.Mail.
If you are in doubt then use

(Get-Mailbox userid).PrimaryAddress

The AD SMTPProxyAddresses are not valid if the mailbox has been removed although they may still be set. We either check the exchange attributes for a connection then use the address or directly access the mailbox.

When using only ADSI to AD we must check the connection since we cannot see the Exchange CmdLets.