Hi
I am looking trying to create/migrate/remote move our users mailboxes to 365.
Until now, I have been creating the new AD accounts from Adaxes on our on Prem exchange and then manuell move the mailboxes to 365.
I would like to automate this process, remember that we are in hybrid-mode.
I have looked around and found this but I still getts errors.
365 Hybrid New User Creation.
Everything work except "Run PowerShell script 'RemoteMailbox' for the User".
The error:
"The type initializer for 'System.Management.Automation.Runspaces.WSManConnectionInfo' threw an exception.
Cannot validate argument on parameter 'Session'. The argument is null. Supply a non-null argument and try the command again.
The term 'Enable-RemoteMailbox' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Cannot validate argument on parameter 'Id'. The argument is null. Supply a non-null argument and try the command again."
The script from Adaxes support
$exchangeServer = "Our local exchange" # TODO: modify me
$exchangeAdminName = "administrator" # TODO: modify me
$exchangeAdminPassword = "xxxxxx" # TODO: modify me
$o365Domain = "something.mail.onmicrosoft.com" # TODO: modify me
$credential = New-Object -type System.Management.Automation.PSCredential `
-argumentlist $exchangeAdminName,(ConvertTo-SecureString -AsPlainText $exchangeAdminPassword -Force)
$session = New-PSSession -Configurationname Microsoft.Exchange –ConnectionUri http://$exchangeServer/powershell -Credential $credential
Import-PSSession $session -DisableNameChecking -AllowClobber
Enable-RemoteMailbox "%distinguishedName%" -RemoteRoutingAddress "%samaccountname%@$o365Domain"
Remove-PSSession $session
The run order:
If the operation succeeded AND
the User is located under the 'Temp User (sfi.se)' container then
Move the User to 'STO (sfi.se\SFI\SFI_Users)'
Add the User to the 'SFI Samtliga anställda (sfi.se\_Groups\Distribution Groups)' group
Run PowerShell script 'Home directory settings' for the User
Create Exchange mailbox for the User (Alias: '%username%', Mailbox Store: containing the least number of mailboxes)
Activate an Office 365 account for the User: set Location to 'SE', enable Exchange Online (Plan 1)
Run PowerShell script 'RemoteMailbox' for the User
Send e-mail notification (Ny medarbetare.)
Regards
Olle Myrberg