2012-05-24 4 views
0

Я пытаюсь ввести встречу в календарь в обмен на 2010 с помощью powershell. Но я получаю сообщение об ошибке в последней строке для сохранения. у smtp нет почтового ящика, связанного с ним. Я использую пользователя admin для этого, поэтому я не понимаю, почему он не работает. Ниже приведен кодpowershell smtp не имеет почтового ящика, связанного с ним

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

# Testing 
#$calinputfile="d:\calendar_inject.csv" 
# Connect to [email protected] 
# capture the admin LiveID username in a variable 
$Username = "[email protected]" 
# 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("[email protected]","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 

ответ

1

Проверьте почтовый ящик действительно существует, и правильно ли псевдоним.

+1

Понял работает в настоящее время '$ iUserID = новый объект-Microsoft.Exchange.WebServices.Data.ImpersonatedUserId ([Microsoft.Exchange.WebServices.Data.ConnectingIdType] :: SmtpAddress, $ электронная почта) $ service.ImpersonatedUserId = $ iUserID ' – shorif2000

Смежные вопросы