我需要通过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
拜托,怎么了?
你能帮助我吗?
最佳答案
UPN参数仅在本地Exchange上可用。根据您的AD是本地部署还是在云中,我建议您首先使用此参数创建AD帐户,然后启用邮箱。
或者只是不使用此参数。
关于powershell - 在Office 365中通过Powershell使用CSV创建新邮箱,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32315386/