Problem with filling out textbox

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 8 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Problem with filling out textbox

Post by jvierra »

$txtbox_exmail.Text = (Get-Mailbox -Anr $txtbox_search.Text ).PrimaryEmailAddress
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Problem with filling out textbox

Post by jvierra »

OR do this:
  1. if($address=(Get-Mailbox -Anr $txtbox_search.Text).PrimaryEmailAddress){
  2.     $txtbox_exmail.Text = $address
  3. }else{
  4.     $txtbox_exmail.Text = 'NOT FOUND'
  5. }
User avatar
alwo23@hotmail.com
Posts: 28
Last visit: Tue Jun 06, 2023 2:43 am

Re: Problem with filling out textbox

Post 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?
User avatar
dan.potter
Posts: 709
Last visit: Wed Nov 14, 2018 11:39 am

Re: Problem with filling out textbox

Post 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:'
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Problem with filling out textbox

Post 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.
User avatar
dan.potter
Posts: 709
Last visit: Wed Nov 14, 2018 11:39 am

Re: Problem with filling out textbox

Post 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.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Problem with filling out textbox

Post 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.
This topic is 8 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked