【发布时间】:2015-08-31 16:03:08
【问题描述】:
我需要在 Office 365 中通过 Powershell 创建新邮箱。 我正在使用这个脚本:
$User = "administrator@blablabla.onmicrosoft.com"
$PWord = ConvertTo-SecureString -AsPlainText -Force -String "P@ssword1"
$Credential = New-Object –TypeName System.Management.Automation.PSCredential –ArgumentList $User, $PWord
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $Credential -Authentication Basic -AllowRedirection
Import-PSSession $Session
Import-CSV new.csv | foreach {
New-Mailbox -UserPrincipalName $_.UserPrincipalName -displayname $_.DisplayName -password (ConvertTo-SecureString $_.password -AsPlainText -Force) -usagelocation "us"
}
Get-PSSession | Remove-PSSession
邮箱的详细信息保存在 new.csv 文件中。 请参阅以下示例:
UserPrincipalName,DisplayName,password
clark.kent@blablabla.onmicrosoft.com,Clark Kent,P@ssword1
bruce.wayne@blablabla.onmicrosoft.com,Bruce Wayne,P@ssword1
peter.parker@blablabla.onmicrosoft.com,Peter Parker,P@ssword1
当我运行这个脚本时,我返回错误:
A parameter cannot be found that matches parameter name 'UserPrincipalName'.
+ CategoryInfo : InvalidArgument: (:) [New-Mailbox],
ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,New-Mailbox
+ PSComputerName : outlook.office365.com
请问,怎么了? 你能帮帮我吗?
【问题讨论】:
标签: powershell office365