osagarana
asked on
How to set an automatic X500 SMTP address based on the usermailbox
Hi Experts,
I apologise with my basic request in powershell.
I need to automate some tasks at work and I am trying to put things togheter to have a kind of script in the end.
I need to get all "usermailbox" from a specific organization unit and set automagically a X500 SMTP address.
So far this is why I could reach >>>
Get-User –OrganizationalUnit "OU=Provisional,OU=ORGUNIT ,DC=domain ,DC=com" | Where-Object{$_.RecipientT ype –eq “UserMailbox”} | Set-Mailbox $SAMAccountname -EmailAddresses @{Add=’X500:/o=DOMAIN/ou=E xchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recip ients/cn=PrimarySmtpAddress'}
Notes:
$SAMAccountname is the accountname from the user
PrimarySmtpAddress is the primary smtp address from the UserMailbox.
The error>>
Cannot bind argument to parameter 'Identity' because it is null.
+ CategoryInfo : InvalidData: (:) [Set-Mailbox], ParameterBindingValidation Exception
+ FullyQualifiedErrorId : ParameterArgumentValidatio nErrorNull NotAllowed ,Set-Mailb ox
I guess my problem now is the $SAMAccountname.
Can someone put in the right direction?
I apologise with my basic request in powershell.
I need to automate some tasks at work and I am trying to put things togheter to have a kind of script in the end.
I need to get all "usermailbox" from a specific organization unit and set automagically a X500 SMTP address.
So far this is why I could reach >>>
Get-User –OrganizationalUnit "OU=Provisional,OU=ORGUNIT
Notes:
$SAMAccountname is the accountname from the user
PrimarySmtpAddress is the primary smtp address from the UserMailbox.
The error>>
Cannot bind argument to parameter 'Identity' because it is null.
+ CategoryInfo : InvalidData: (:) [Set-Mailbox], ParameterBindingValidation
+ FullyQualifiedErrorId : ParameterArgumentValidatio
I guess my problem now is the $SAMAccountname.
Can someone put in the right direction?
ASKER
Hi Subsun,
I guess I am almost there.
I had two mailboxes there and SMTP was added just for one object.
Here is the error:
[PS] C:\scripts>Get-mailbox -OrganizationalUnit "OU=Users,OU=MOE,DC=domain ,DC=com" | Where-Object{$_.RecipientT ype -eq "UserMailbox"} | % {Set-Mailbox $_.SAMAccountname -EmailAddresses @{Add="X500:/o=domain/ou=E xchange Administrative Group FYDIBOHF23SPDLT)/cn=Recipi ents/cn=$( $_.Primary SmtpAddres s.tostring ())"}}
Pipeline not executed because a pipeline is already executing. Pipelines cannot be executed concurrently.
+ CategoryInfo : OperationStopped: (Microsoft.Power...tHelper Runspace:E xecutionCm dletHelper Runspace) [],
PSInvalidOperationExceptio n
+ FullyQualifiedErrorId : RemotePipelineExecutionFai led
Pipeline not executed because a pipeline is already executing. Pipelines cannot be executed concurrently.
+ CategoryInfo : OperationStopped: (Microsoft.Power...tHelper Runspace:E xecutionCm dletHelper Runspace) [],
PSInvalidOperationExceptio n
+ FullyQualifiedErrorId : RemotePipelineExecutionFai led
[PS] C:\scripts>
I guess I am almost there.
I had two mailboxes there and SMTP was added just for one object.
Here is the error:
[PS] C:\scripts>Get-mailbox -OrganizationalUnit "OU=Users,OU=MOE,DC=domain
Pipeline not executed because a pipeline is already executing. Pipelines cannot be executed concurrently.
+ CategoryInfo : OperationStopped: (Microsoft.Power...tHelper
PSInvalidOperationExceptio
+ FullyQualifiedErrorId : RemotePipelineExecutionFai
Pipeline not executed because a pipeline is already executing. Pipelines cannot be executed concurrently.
+ CategoryInfo : OperationStopped: (Microsoft.Power...tHelper
PSInvalidOperationExceptio
+ FullyQualifiedErrorId : RemotePipelineExecutionFai
[PS] C:\scripts>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window
OrOpen in new window