Powershell exchange 2013批量创建邮箱错误

Powershell exchange 2013批量创建邮箱错误,powershell,csv,windows-server-2008,exchange-server,Powershell,Csv,Windows Server 2008,Exchange Server,我试图从csv文件导入用户列表,但出现以下错误: 脚本: PS C:\Software>import csv C:\Software\lastDumpPolished.csv |%{New ADUser-Name$.Name-SamAccountName$.SamAccountName-DisplayName$.Name-LastName$.NastName$.Sn-GivenName$.GivenName-AccountPassword(转换为SecureString密码1234-AsPlai

我试图从csv文件导入用户列表,但出现以下错误:

脚本:


PS C:\Software>import csv C:\Software\lastDumpPolished.csv |%{New ADUser-Name$.Name-SamAccountName$.SamAccountName-DisplayName$.Name-LastName$.NastName$.Sn-GivenName$.GivenName-AccountPassword(转换为SecureString密码1234-AsPlainText-Force)-启用:$true-Title$.Title-Description$.Description-Company Myland-OfficePhone$.Telephone-HomeDrive Z:-HomeDirectory$HomeDrive-ChangePasswordAtLogon:$true}|启用邮箱-Identity$.SamAccountName-别名$.SamAccountName

错误:

Enable-Mailbox : Cannot bind argument to parameter 'Identity' because it is null.
At line:1 char:443
+ ... lbox -Identity $_.SamAccountName -Alias $_.SamAccountName
+                    ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Enable-Mailbox], ParameterBind
   ingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,M
   icrosoft.Exchange.Management.RecipientTasks.EnableMailbox
由于某些原因,Powershell不记得$\.SamAccountName。 有没有一种简单的“内联方法”将其设置为可以在管道之后使用的变量


如何消除该错误,以便批量创建和启用邮箱?

PS C:\Software>import csv C:\Software\lastDumpPolished.csv |%{New ADUser-Name$.Name-SamAccountName$.SamAccountName-DisplayName$.Name-姓氏$.Sn-GivenName$.GivenName-AccountPassword(ConvertTo SecureString Password1234-AsPlainText-Force)-启用:$true-Title$.Title-Description$.Description-Company Midland-OfficePhone$.Telephone-HomeDrive Z:-HomeDirectory$HomeDrive-ChangePasswordAtLogon:$true}|%{启用邮箱-标识$.SamAccountName-别名$.SamAccountName}