Support Forums

Problem with filling out textbox

Ask your Windows PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.
User avatar
jvierra
Posts: 9738
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Problem with filling out textbox

Postby jvierra » Thu Jan 07, 2016 9:09 am

$txtbox_exmail.Text = (Get-Mailbox -Anr $txtbox_search.Text ).PrimaryEmailAddress
User avatar
jvierra
Posts: 9738
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Problem with filling out textbox

Postby jvierra » Thu Jan 07, 2016 9:11 am

OR do this:

if($address=(Get-Mailbox -Anr $txtbox_search.Text).PrimaryEmailAddress){
$txtbox_exmail.Text = $address
}else{
$txtbox_exmail.Text = 'NOT FOUND'
}
User avatar
alwo23@hotmail.com
Posts: 27
Joined: Sat Sep 28, 2013 1:56 am

Re: Problem with filling out textbox

Postby alwo23@hotmail.com » Thu Jan 07, 2016 9:14 am

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?
User avatar
dan.potter
Posts: 632
Joined: Wed Oct 08, 2014 6:02 am

Re: Problem with filling out textbox

Postby dan.potter » Thu Jan 07, 2016 1:13 pm

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:'
User avatar
jvierra
Posts: 9738
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Problem with filling out textbox

Postby jvierra » Thu Jan 07, 2016 1:52 pm

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.
User avatar
dan.potter
Posts: 632
Joined: Wed Oct 08, 2014 6:02 am

Re: Problem with filling out textbox

Postby dan.potter » Fri Jan 08, 2016 5:16 am

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.
User avatar
jvierra
Posts: 9738
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Problem with filling out textbox

Postby jvierra » Fri Jan 08, 2016 6:27 am

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.

Return to “Windows PowerShell”

Who is online

Users browsing this forum: No registered users and 2 guests