设为首页 收藏本站
查看: 823|回复: 0

[经验分享] exchange 2010新建用户自动触发功能

[复制链接]

尚未签到

发表于 2018-7-3 08:01:31 | 显示全部楼层 |阅读模式
  进入Exchange 2010 时代,终于可以实现自动化了。前两天看到一老外写的关于Cmdlet Extension Agents的使用,觉得蛮有意思的,自己测试了下,果然不错。下面是一些分享。
  首先,我们需要创建一个Receive connector 来接受从特定IP地址段来的 free>
    New-ReceiveConnector -Name "Internal>
复制代码  第二步,创建一个脚本来发送欢迎邮件到特定邮箱。我们为这个脚本取名为send-mail.ps1, 命令行参数为:

  • send-mail.ps1 –mailboxname <邮箱名>
复制代码  代码如下, 请修改变量定义中的邮件地址,请注意邮件中会自动插入出用户的用户名,邮件地址等信息,另外,可自行修改声明。第三步之前,可先行运行此脚本,保证脚本能正常工作。
  =================================

  • param
  • (
  •     [string]$mailboxname
  • )

  • #此处填上发信人地址
  • $strMsgFrom = &quot;MCMHost HelpDesk <user01@MCMhost.com>&quot;

  • #邮件标题
  • $strMsgTitle = &quot;Welcome to MCMhost!&quot;

  • #SMTP>
  • $SMTPClient = New-Object Net.Mail.SmtpClient(&quot;ex2010cas01.mcmhost.com&quot;)

  • $mailbox = get-mailbox -id $mailboxname
  • $strMsgTo = $mailbox.PrimarySMTPAddress

  • $strMsgBody = &quot;您好, &quot;+$mailbox.DisplayName+&quot;, 欢迎使用MCMhost邮件系统!

  • --------------------------------------
  • 用户名和密码
  • --------------------------------------
  • 您的登录账户名是 is '&quot;+$mailbox.SamAccountName+&quot;'. Use your username and password to login to the network. Your password should NEVER be shared with anyone except the I.T. department, and only then when requested. Please do not write it down on anything that can be seen by your coworkers. You will be prompted to change it regularly.

  • --------------------------------------
  • 邮箱
  • --------------------------------------

  • 您的邮件地址是 '&quot;+$mailbox.PrimarySMTPAddress+&quot;'.

  • To access your email, calendar, contacts, and tasks from outside of the building, such as from home, you can do so from any Internet connected computer. Simply open Internet Explorer and go to the Outlook Web Access (OWA) page at https://mail.MCMhost.com/ and log in using your username and password. Please note the 's' in https.

  • If you'd like to have access to your email and contacts from your cell phone, you will need a cell phone that has Windows Mobile 5 or later, or an Apple iPhone. Blackberry phones are not supported. Instructions for configuring your device can be found in the Frequently Asked Questions (FAQ) section of the MCMhost Intranet at https://intranet.MCMhost.com/helpdesk/Lists/SupportFaq/AllItems.aspx
  • --------------------------------------
  • Contact information
  • --------------------------------------
  • Once you're situated, please go to http://directory/DirectoryUpdate and update your information. Log in using your username and password. It's important that you update your information anytime something changes, such as>

  • --------------------------------------
  • Computer, Email, and Internet policies
  • --------------------------------------
  • MCMhost, Inc. provides a computer for your work tasks. The use of personally owned computers and>

  • --------------------------------------
  • Technical assistance
  • --------------------------------------
  • Should you need technical assistance, please check the Frequently Asked Questions (FAQ) section of the MCMhost Intranet at https://intranet.MCMhost.com/helpdesk/Lists/SupportFaq/AllItems.aspx. If you cannot find an answer there, submit a Service Request on the MCMhost intranet at https://intranet.MCMhost.com/helpdesk. If you are unable to access the intranet site, only then should you email HelpDesk@MCMhost.com. It is monitored by the whole IT department, and will ensure your issue is resolved in a timely manner.

  • Thank you, and, again, welcome to MCMhost!
  • The Information Technology Department&quot;

  • $SMTPClient.Send($strMsgFrom,$strMsgTo,$strMsgTitle,$strMsgBody)
复制代码  =================================
  第三步, 去到C:\Program Files\Microsoft\Exchange Server\V14\Bin\CmdletExtensionAgents 目录下(如果不是缺省安装路径,可自行修改)。创建一个XML文件ScriptingAgentConfig.xml
  XML文件内容如下,其作用是当完成new-mailbox这个命令后,自动调用c:\temp\send-mail.ps1脚本发送欢迎邮件,并且禁止邮箱的IMAP和POP3访问。这里的功用可无限引申出去(注意,在某些时候script agent的优先级需要比provisionagent的优先级高,比如对database做操作的命令,此处就不赘述了)。
  =========================

  • <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?>
  • <Configuration version=&quot;1.0&quot;>
  •                 <Feature Name=&quot;MailboxProvisioning&quot; Cmdlets=&quot;new-mailbox&quot;>
  •                                 <ApiCall Name=&quot;OnComplete&quot;>
  •                                                 if($succeeded)    {
  •                                                                 $newmailbox = $provisioningHandler.UserSpecifiedParameters[&quot;Name&quot;]
  •                                                                 c:\temp\send-mail.ps1 -mailboxname $newmailbox
  •                                                                 Set-CASMailbox $newmailbox -IMAPEnabled $false -POPEnabled $false
  •                                                 }
  •                                 </ApiCall>
  •                 </Feature>
  • </Configuration>
复制代码  =========================
  第四步,关闭所有服务器上目前打开的EMS和EMC。然后拷贝该XML去您环境中的每一个Exchange 服务器。别怪我没告诉你噢,等下跟我说你打不开EMC了。
  第五部,使用下面命令创建一个新用户(也可用界面创建)。请自行修改 OU路径和用户名等参数。 进入Exchange 2010 时代,终于可以实现自动化了。前两天看到一老外写的关于Cmdlet Extension Agents的使用,觉得蛮有意思的,自己测试了下,果然不错。下面是一些分享。
  首先,我们需要创建一个Receive connector 来接受从特定IP地址段来的 free>
    New-ReceiveConnector -Name &quot;Internal>
复制代码  第二步,创建一个脚本来发送欢迎邮件到特定邮箱。我们为这个脚本取名为send-mail.ps1, 命令行参数为:

  • send-mail.ps1 –mailboxname <邮箱名>
复制代码  代码如下, 请修改变量定义中的邮件地址,请注意邮件中会自动插入出用户的用户名,邮件地址等信息,另外,可自行修改声明。第三步之前,可先行运行此脚本,保证脚本能正常工作。
  =================================

  • param
  • (
  •     [string]$mailboxname
  • )

  • #此处填上发信人地址
  • $strMsgFrom = &quot;MCMHost HelpDesk <user01@MCMhost.com>&quot;

  • #邮件标题
  • $strMsgTitle = &quot;Welcome to MCMhost!&quot;

  • #SMTP>
  • $SMTPClient = New-Object Net.Mail.SmtpClient(&quot;ex2010cas01.mcmhost.com&quot;)

  • $mailbox = get-mailbox -id $mailboxname
  • $strMsgTo = $mailbox.PrimarySMTPAddress

  • $strMsgBody = &quot;您好, &quot;+$mailbox.DisplayName+&quot;, 欢迎使用MCMhost邮件系统!

  • --------------------------------------
  • 用户名和密码
  • --------------------------------------
  • 您的登录账户名是 is '&quot;+$mailbox.SamAccountName+&quot;'. Use your username and password to login to the network. Your password should NEVER be shared with anyone except the I.T. department, and only then when requested. Please do not write it down on anything that can be seen by your coworkers. You will be prompted to change it regularly.

  • --------------------------------------
  • 邮箱
  • --------------------------------------

  • 您的邮件地址是 '&quot;+$mailbox.PrimarySMTPAddress+&quot;'.

  • To access your email, calendar, contacts, and tasks from outside of the building, such as from home, you can do so from any Internet connected computer. Simply open Internet Explorer and go to the Outlook Web Access (OWA) page at https://mail.MCMhost.com/ and log in using your username and password. Please note the 's' in https.

  • If you'd like to have access to your email and contacts from your cell phone, you will need a cell phone that has Windows Mobile 5 or later, or an Apple iPhone. Blackberry phones are not supported. Instructions for configuring your device can be found in the Frequently Asked Questions (FAQ) section of the MCMhost Intranet at https://intranet.MCMhost.com/helpdesk/Lists/SupportFaq/AllItems.aspx
  • --------------------------------------
  • Contact information
  • --------------------------------------
  • Once you're situated, please go to http://directory/DirectoryUpdate and update your information. Log in using your username and password. It's important that you update your information anytime something changes, such as>

  • --------------------------------------
  • Computer, Email, and Internet policies
  • --------------------------------------
  • MCMhost, Inc. provides a computer for your work tasks. The use of personally owned computers and>

  • --------------------------------------
  • Technical assistance
  • --------------------------------------
  • Should you need technical assistance, please check the Frequently Asked Questions (FAQ) section of the MCMhost Intranet at https://intranet.MCMhost.com/helpdesk/Lists/SupportFaq/AllItems.aspx. If you cannot find an answer there, submit a Service Request on the MCMhost intranet at https://intranet.MCMhost.com/helpdesk. If you are unable to access the intranet site, only then should you email HelpDesk@MCMhost.com. It is monitored by the whole IT department, and will ensure your issue is resolved in a timely manner.

  • Thank you, and, again, welcome to MCMhost!
  • The Information Technology Department&quot;

  • $SMTPClient.Send($strMsgFrom,$strMsgTo,$strMsgTitle,$strMsgBody)
复制代码  =================================
  第三步, 去到C:\Program Files\Microsoft\Exchange Server\V14\Bin\CmdletExtensionAgents 目录下(如果不是缺省安装路径,可自行修改)。创建一个XML文件ScriptingAgentConfig.xml
  XML文件内容如下,其作用是当完成new-mailbox这个命令后,自动调用c:\temp\send-mail.ps1脚本发送欢迎邮件,并且禁止邮箱的IMAP和POP3访问。这里的功用可无限引申出去(注意,在某些时候script agent的优先级需要比provisionagent的优先级高,比如对database做操作的命令,此处就不赘述了)。
  =========================

  • <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?>
  • <Configuration version=&quot;1.0&quot;>
  •                 <Feature Name=&quot;MailboxProvisioning&quot; Cmdlets=&quot;new-mailbox&quot;>
  •                                 <ApiCall Name=&quot;OnComplete&quot;>
  •                                                 if($succeeded)    {
  •                                                                 $newmailbox = $provisioningHandler.UserSpecifiedParameters[&quot;Name&quot;]
  •                                                                 c:\temp\send-mail.ps1 -mailboxname $newmailbox
  •                                                                 Set-CASMailbox $newmailbox -IMAPEnabled $false -POPEnabled $false
  •                                                 }
  •                                 </ApiCall>
  •                 </Feature>
  • </Configuration>
复制代码  =========================
  第四步,关闭所有服务器上目前打开的EMS和EMC。然后拷贝该XML去您环境中的每一个Exchange 服务器。别怪我没告诉你噢,等下跟我说你打不开EMC了。
  第五部,使用下面命令创建一个新用户(也可用界面创建)。请自行修改 OU路径和用户名等参数。

  • New-Mailbox -Name 'Exchange 2010 user08' -Alias 'exchange2010user08' -OrganizationalUnit 'MCMHost.com/MCM/Users' -UserPrincipalName 'user08@MCMHost.com' -SamAccountName 'user08' -FirstName 'Exchange 2010' -Initials '' -LastName 'user08' -Password 'System.Security.SecureString' -ResetPasswordOnNextLogon $false
复制代码

  • New-Mailbox -Name 'Exchange 2010 user08' -Alias 'exchange2010user08' -OrganizationalUnit 'MCMHost.com/MCM/Users' -UserPrincipalName 'user08@MCMHost.com' -SamAccountName 'user08' -FirstName 'Exchange 2010' -Initials '' -LastName 'user08' -Password 'System.Security.SecureString' -ResetPasswordOnNextLogon $false
复制代码

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-533133-1-1.html 上篇帖子: 在EXCHANGE2010导出邮件到PST文件 下篇帖子: exchange十种常见退信原因
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表