Link to home
Start Free TrialLog in
Avatar of luyan
luyan

asked on

remove mail user in mail contact in exchange management shell

Hi,
first I 'd like to find a script to remove mail user in mail contact in exchange management shell.

And I have script to enable a user mailbox.
Enable-MailUser -Identity 'AD.LOCAL/MIS/test' -Alias 'test' -ExternalEmailAddress 'SMTP:test@mail.com'
I'd like to put them together and run in exchange management shell.
My questions is when I run test.ps1 it showed me a error message, "The term 'enable_mail_yantest.psl' is not recognized as a cmdlet, function, operable program, or script file. Verify the term and try again."

Please help,
Thanks,
ASKER CERTIFIED SOLUTION
Avatar of Rick Fee
Rick Fee
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of luyan
luyan

ASKER

Yes, I'd like to have the test user account have a mailbox on exchange.

Thx
Avatar of luyan

ASKER

when I run
Remove-MailContact aliasofcontact
it said
Object could not be found on domain controller.
So I tried command,
REmove-mailuser test

it is successful with some option 'y' 'a', n'',...

but when I run,
Enable-MailUser test -Alias test -ExternalEmailAddress SMTP:test@mydomain.com
it said,
object /ad/mis/test' could not be found on domaincontroller
I thought remove-mailuser removed user account as well, right?

Can I run them in batch file and silently?

Remove-Mailuser aliasofcontact
Enable-MailUser test -Alias test -ExternalEmailAddress SMTP:test@mydomain.com

Thanks,