powershell smtp没有与之关联的邮箱 [英] powershell smtp has no mailbox associated with it

查看:2011
本文介绍了powershell smtp没有与之关联的邮箱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用powershell在2010年交易日历中输入约会。但我得到一个错误在最后一行保存。 smtp没有与之关联的邮箱。我使用管理员用户这样做,所以我不明白为什么它不工作。以下是代码

I am trying to input an appointment into calendar in exchange 2010 using powershell. But i get an error on the last line to save. the smtp has no mailbox associated with it. I am using admin user to do this so i don't understand why it is not working. below is the code

Param ([string]$calInputFile = $(throw "Please provide calendar input file..."))

# Testing
#$calinputfile="d:\calendar_inject.csv"
# Connect to Live@edu
# capture the admin LiveID username in a variable
$Username = "administrator@domainasa.com"
# capture the admin LiveID password in a variable.  Note, that it is stored as a secure string
$Password = ConvertTo-SecureString ‘password’ -AsPlainText -Force
# populate the $Livecred PowerShell credential with $Username and $Password
$Livecred = New-Object System.Management.Automation.PSCredential $Username, $Password
#$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://thor.uk.domainasa.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection
#Import-PSSession $Session
# Load EWS Managed API library
Import-Module -Name "C:\Program Files\Symantec\Backup Exec\Microsoft.Exchange.WebServices.dll"
# Load all Mailboxes
#$exchangeUsers = Get-Mailbox -ResultSize Unlimited | Select UserPrincipalName
#test with just one user
$exchangeusers = get-mailbox "sharif uddin" |select UserPrincipalName
# Load all calendar Entries
$calEntries = Import-Csv $calInputFile
# Identify the folder to save our appointments into
$folderid = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Calendar)
# Create Exchange Service object
$service = new-object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.Exchangeversion]::exchange2010)
$service.Url = new-object System.Uri("https://thor.uk.domainasa.com/EWS/Exchange.asmx")
# Service account must have ApplicationImpersonation ManagementRoleAssignment in Exchange
$service.Credentials = new-object Microsoft.Exchange.WebServices.Data.WebCredentials("administrator@domainasa.com","woki1141")

foreach($mailbox in $exchangeUsers)
{
 # Identify user to which appointment will be added
  $MailboxName = $mailbox.UserPrincipalName
  # Instruct service to use impersonation
  $iUserID = new-object Microsoft.Exchange.WebServices.Data.ImpersonatedUserId([Microsoft.Exchange.WebServices.Data.ConnectingIdType]::SmtpAddress,$MailboxName)
  #Write-Output $iUserID
  $service.ImpersonatedUserId = $iUserID
  Write-Output $service

  # Create new appointment object for each appointment to save
  foreach($entry in $calEntries)
  {
   $appt = New-Object Microsoft.Exchange.WebServices.Data.Appointment($service)
   $appt.Subject = $entry.Subject

   # Convert date
   $x = Get-Date -Date $entry."Start Date"
   $y = Get-Date -Date $entry."End Date"
   $appt.Start = [System.DateTime]( $x )
   $appt.End = [System.DateTime]($y)    #For AllDayEvent, end date must be after start date
   $appt.IsAllDayEvent = $True
   $appt.LegacyFreeBusyStatus = "Free"
   $appt.IsReminderSet = $False   #If you want a reminder then remove this line
   #$appt.Save($folderid)
   $appt.Save()
  }
}

错误:

Exception calling "Save" with "0" argument(s): "The SMTP address has no mailbox associated with it."
At C:\exchange.ps1:55 char:14
+    $appt.Save <<<< ()
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException


推荐答案

检查邮箱是否存在以及别名是否正确。

Check if the mailbox does exist and whether the alias is correct.

这篇关于powershell smtp没有与之关联的邮箱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆