Wir haben kürzlich eine Domain zu unseren akzeptierten Domänen- und E-Mail-Adressrichtlinien hinzugefügt. Während viele unserer Benutzer dieser Richtlinie folgen, haben wir eine dritte Domäne, die einige Benutzer als ihre primäre Adresse haben, die keiner Adressrichtlinie folgt. Ich muss diese Benutzer nehmen und eine SMTP-Adresse im Format [email protected]
hinzufügen.Bulk SmtpAddress zu Benutzern hinzufügen Exchange 2010
Zum Beispiel hat [email protected] (primär) [email protected] als Alias und muss [email protected] als SMTP-Adresse hinzugefügt haben.
Ich habe den folgenden Code, aber am Empfang Fehler:
$Users = Get-Mailbox -ResultSize Unlimited | Where-Object {($_.PrimarySMTPAddress -like "*domain3.com*)}
foreach ($a in $Users) {
$b = Get-User $a.Primary.SMTPAddress
$a.EmailAddresses.Add("$($b.Firstname + "." + $b.Lastname)@domain2.com")
}
$Users |%{Set-Mailbox $_.PrimarySMTPAddress -EmailAddresses $_.EmailAddresses
Fehler sind wie folgt:
Cannot process argument transformation on parameter 'Identity'. Cannot convert the "[email protected]" value of type "Microsoft.Exchange.Data.SmtpAddress" to type "Microsoft.Exchange.Configuration.Tasks.UserIdParameter". + CategoryInfo : InvalidData: (:) [Get-User], ParameterBindin...mationException + FullyQualifiedErrorId : ParameterArgumentTransformationError,Get-User
Exception calling "Add" with "1" argument(s): "The address '[email protected]' is invalid: "[email protected]" isn't a valid SMTP address. The domain name can't contain spaces and it has to have a prefix and a suffix, such as example.com." At C:\_scripts\SmtpAdd.ps1:4 char:23 + $a.emailaddresses.Add <<<< ("$($b.Firstname + "." + $b.LastName)@domain2.com") + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException
Cannot process argument transformation on parameter 'Identity'. Cannot convert the "[email protected]" value of type "Microsoft.Exchange.Data.SmtpAddress" to type "Microsoft.Exchange.Configuration.Tasks.MailboxIdParameter". + CategoryInfo : InvalidData: (:) [Set-Mailbox], ParameterBindin...mationException + FullyQualifiedErrorId : ParameterArgumentTransformationError,Set-Mailbox
Dank
Dies funktionierte, wenn ein einzelner Benutzer mit '$ Users Angabe = Get-Mailbox "Benutzername". Ich erhalte immer noch den Fehler "Exception calling" Add ", der oben mit dem gleichen Code in OP aufgeführt ist. – hdub
Können Sie den Inhalt von $ b untersuchen, bevor Sie die' EmailAddresses.Add'? –
Das Problem schien von a Problem mit unserer Exchange-Umgebung, das wurde behoben und das Skript lief. Vielen Dank nochmal @Tav. – hdub