Hi all
Using shell I can move mailboxes to 0365 by running the following cmdlets, I just need to manually add prem and cloud creds when prompted:
$LiveCred = Get-Credential (ENTERS CLOUD ADMIN CREDS)
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.co
m/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection
Import-PSSession $Session
$OnPremAdmin=Get-Credential (enters prem admin)
Import-Csv c:\users\lparker\Desktop\Script\userlist.csv | foreach {New-MoveRequest
-Identity $_.identity -Remote -RemoteHostName XXXXXXX -RemoteCredential $OnPremAdmin -TargetDeliveryDomain XXXX.onmicrosoft.com}
Mailboxes migrate over without issues, however I need to script this to run as a scheduled task so I have the following script:
###########################################################
# Set Variable values
###########################################################
$onPremcred = "xxxxx"
$onPrempass = ConvertTo-SecureString -AsPlainText -String "xxxxx" -Force
$o365Cred = "xxxx@xxx.onmicrosoft.com"
$o365pass = ConvertTo-SecureString -AsPlainText -String "xxxxxxx" -Force
###########################################################
# Import necessary powershell modules
###########################################################importmodule
Import-Module ActiveDirectory
Import-Module MSOnline
###########################################################
# Create connections to Office 365 for each credential, both
# local and remote (O365)
###########################################################
$msol = New-Object System.Management.Automation.PSCredential -ArgumentList ($onPremcred, $onPrempass)
$msol2 = New-Object System.Management.Automation.PSCredential -ArgumentList ($o365Cred, $o365pass)
$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $msol2 -Authentication Basic -AllowRedirection
Import-PSSession $session
Connect-MsolService -credential $msol2
###########################################################
# Move mailbox(es)
###########################################################
Import-Csv c:\Users\lparker\Desktop\Script\userlist.csv | foreach {New-MoveRequest -Identity $_.Identity -Remote -RemoteHostName xxxxxxxxx.xxxx.bc.ca -TargetDeliveryDomain xxxx.onmicrosoft.com -RemoteCredential $msol}
###########################################################
# Close sessions
###########################################################
get-pssession | remove-pssession
However the connection to the cloud is not made, and thus I get an error stating the user already has a primary mailbox. Essesentially I am not connected to my tenant. Can you guys see any issues with my move script? Is there a way to streamline this to work? I know the above cmdlets work as I can run manually and move mailboxes:(
Thanks in advance