首页 > 解决方案 > 在 Exchange Server 2010 上创建/导入新联系人时出错 [PowerShell]

问题描述

我有我使用的这个脚本,它过去工作得很好,用于创建联系人,我在 Exchange 服务器的 Powershell 控制台中运行这个脚本。

# This script creates contacts from csv file
#Set-ExecutionPolicy Unrestricted
Import-Module ActiveDirectory
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010;
 
.'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'
clsconnect-ExchangeServer -server1

Import-Csv "C:\contacts.csv" | foreach { 

%{New-MailContact -Name $_.Name -DisplayName $_.Name -ExternalEmailAddress $_.ExternalEmailAddress -FirstName $_.FirstName -LastName $_.LastName -OrganizationalUnit $_.OU }

}

现在,当我运行脚本时,我遇到以下错误:

New-MailContact : The term 'New-MailContact' is not recognized as the name of a cmdlet, function, script file, or 
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try 
again.
At line:4 char:3
+ %{New-MailContact -Name $_.Name -DisplayName $_.Name -ExternalEmailAd ...
+   ~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (New-MailContact:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

我仔细检查了 csv,它看起来没问题。

会出什么问题?

谢谢。

标签: powershellexchange-server

解决方案


推荐阅读