Does New-MigrationBatch create New-MoveRequest for each user internally?
Can somebody explain to me how New-MigrationBatch works internally?
New-MigrationBatch cmdlet is use to submit a new migration request for a batch of users. It helps to Move mailboxes to different databases in on-premises Exchange organizations.
Example to take input from CSV file:
#It creates a migration batch for a local move, where the mailboxes in the specified CSV file are moved to a different mailbox database.
#This CSV file contains a single column with the email address for the mailboxes that will be moved.
#The header for this column must be named EmailAddress.
$InputCSV="C:\Users\Administrator\Desktop\Input.csv"
New-MigrationBatch -Local -Name MyFirstBatch -CSVData ([System.IO.File]::ReadAllBytes($InputCSV)) -TargetDatabases MyLocalDB
Start-MigrationBatch -Identity MyFirstBatch
Note: You can use AutoStart in order to run batches automatically.
To create a migration endpoint for the on-premises Exchange server, and then uses that endpoint to create the migration batch.
$InputCSV="C:\Users\Administrator\Desktop\FirstBatch.csv"
$Endpoint = New-MigrationEndpoint -ExchangeOutlookAnywhere -Name Endpoint -Autodiscover -EmailAddress user#domain.com -Credentials $Credentials
$StagedBatch1 = New-MigrationBatch -Name FirstBatch -SourceEndpoint $Endpoint.Identity -CSVData ([System.IO.File]::ReadAllBytes($InputCSV))
Start-MigrationBatch -Identity $FirstBatch.Identity
For Further reference, Please visit Technet--New-MigrationBatch
Hope it helps.
Related
I'm trying to write down a powershell script that will automatically finds the mailbox server and connect to it (using the URI https://mailboxserver/powershell).
Problem is I haven't found a way to automatically detect a mailbox server for a given exchange organization. I found a way how to find the CAS server because someone posted how the outlook finds this manually.
I tried to query AD but I do not know which attribute is unique to exchange mailbox server.
I also tried DNS records but found none which helps.
Does anybody know about a unique value of mailbox server which could be queried from AD or GC? Or a DNS record or something else I have not thought of?
Exchange 2010
I could post forest and domain functional level if necessary but I am on the way.
Thanks in advance
Your AD user attributes have this information, albeit you have to parse the mailbox server name from them.
HomeMTA
msExchHomeServerName
So if you have access to the AD cmdlets you might be able to get your mailbox server this way.
$adUser = get-aduser someuser -Properties msExchHomeServerName
$mailboxServerName = ($aduser.msExchHomeServerName -split "cn=")[-1]
Those attributes help you find your current mailbox is hosted. The mailbox server in my case was the last "item" in msExchHomeServerName so I split the string on "cn=" and then the last element of that array would be my mailbox server name.
Then you can use that to connect to an Exchange session!
$Credentials = Get-Credential
$exchangePath = "http://$mailboxServerName/PowerShell/?SerializationLevel=Full"
$ExSession = New-PSSession –ConfigurationName Microsoft.Exchange –ConnectionUri $exchangePath -Credential $Credentials –Authentication Kerberos
Import-PSSession $ExSession
Does the code below get you what you need? It uses EWS - see my SO post for further details on EWS.
# load the assembly
[void][Reflection.Assembly]::LoadFile("D:\Temp\Microsoft.Exchange.WebServices.2.2\lib\40\Microsoft.Exchange.WebServices.dll")
# set ref to exchange - may need to change the version
$s = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2010_SP2)
# replace with your email address
$email = "your.email#domain.com"
# grab your own credentials
$s.UseDefaultCredentials = $true
# discover the url from your email address
$s.AutodiscoverUrl($email)
$s.Url.AbsoluteUri
Based on the following article i'm uploading file server information to SharePoint online.
Everything is working except for Step 7: Processing and Monitoring your SPO Migration.
The description there is:
Checking job status You can check the status of your job by viewing
the real time updates posted in the Azure storage account queue by
using the Encryption.EncryptionKey returned in step 6.
Viewing logs If you’re using your own Azure storage account, you can
look into the manifest container in the Azure Storage for logs of
everything that happened. At this stage, it is now safe to delete
those containers if you don’t want to keep them as backup in Azure.
If there were errors or warnings, .err and .wrn files will be created
in the manifest container.
If you’re using the temporary Azure storage created by
Invoke-SPOMigrationEncryptUploadSubmit in step 6, the import log SAS
URL can be obtained by decrypting the Azure queue message with the
“Event” value “JobLogFileCreate”. With the import log SAS URL, you can
download the log file and decrypt it with the same encryption key as
returned in Step 6.
I have the encryptionKey and ReportingQueueUri, there is no explanation on how to use them, trying with Azure Storage Explorer i opened the reporting queue but its all encrypted there and there is no option to use the encryptionKey.
If anyone did this or know how to i'd really appreciate some help.
One has to use two other cmdlets, Get-SPOMigrationJobProgress and Get-SPOMigrationJobStatus
$job = Invoke-SPOMigrationEncryptUploadSubmit `
-SourceFilesPath $sourceFiles `
-SourcePackagePath $targetPackage `
-Credentials $creds `
-TargetWebUrl $targetWebUrl
$encryption = $job.Encryption
$queueLink = $job.ReportingQueueUri.AbsoluteUri
$jobID = $job.jobid
Get-SPOMigrationJobProgress -AzureQueueUri $queueLink `
-Credentials $creds `
-TargetWebUrl $targetWebUrl `
-JobIds $jobID `
-EncryptionParameters $encryption
Get-SPOMigrationJobStatus -TargetWebUrl $targetWebUrl -Credentials $creds -JobId $jobID
We have office 365 and a hybrid server. It is set to sync 1 way from hybrid to o365.
We are wanting to run
Set-mailbox "$usertodisable#domain.com" -EmailAddressPolicyEnabled $true
on the hybrid server.
The problem is the hybrid server doesn't support/have the -mailbox commands. It has the -msol commands. I can not find an msol command that changes the emailaddresspolicyenabled. I also don't see a module to load for -mailbox.
We are running this command directly off the server itself. Any help would be great. Thank you and have a great day.
Use the Set-RemoteMailbox cmdlet to modify remote mailboxes. A remote mailbox is a mail user in Active Directory that's associated with a mailbox in the cloud-based service.
So what you are searching for seamed to be:
Set-RemoteMailbox -Identity "$usertodisable#domain.com" -EmailAddressPolicyEnabled $True
SOLUTION FOUND: For anyone else that happens to come across this problem, have a look-see at this: http://www.harbar.net/archive/2010/10/30/avoiding-the-default-schema-issue-when-creating-the-user-profile.aspx
TL;DR When you create UPS through CA, it creates a dbo user and schema on the SQL server using the farm account, however when doing it through powershell it creates it with a schema and user named after the farm account, but still tries to manage SQL using the dbo schema, which of course fails terribly.
NOTE: I've only included the parts of my script I believe to be relevant. I can provide other parts as needed.
I'm at my wit's end on this one. Everything seems to work fine, except the UPS Synchronization service is stuck on "Starting", and I've left it over 12 hours.
It works fine when it's set up through the GUI, but I'm trying to automate every step possible. While automating I'm trying to include every option available from the GUI so that it's present if it ever needs to be changed.
Here's what I have so far:
$domain = "DOMAIN"
$fqdn = "fully.qualified.domain.name"
$admin_pass = "password"
New-SPManagedPath "personal" -WebApplication "http://portal.$($fqdn):9000/"
$upsPool = New-SPServiceApplicationPool -Name "SharePoint - UPS" -Account "$domain\spsvc"
$upsApp = New-SPProfileServiceApplication -Name "UPS" -ApplicationPool $upsPool -MySiteLocation "http://portal.$($fqdn):9000/" -MySiteManagedPath "personal" -ProfileDBName "UPS_ProfileDB" -ProfileSyncDBName "UPS_SyncDB" -SocialDBName "UPS_SocialDB" -SiteNamingConflictResolution "None"
New-SPProfileServiceApplicationProxy -ServiceApplication $upsApp -Name "UPS Proxy" -DefaultProxyGroup
$upsServ = Get-SPServiceInstance | Where-Object {$_.TypeName -eq "User Profile Service"}
Start-SPServiceInstance $upsServ.Id
$upsSync = Get-SPServiceInstance | Where-Object {$_.TypeName -eq "User Profile Synchronization Service"}
$upsApp.SetSynchronizationMachine("Portal", $upsSync.Id, "$domain\spfarm", $admin_pass)
$upsApp.Update()
Start-SPServiceInstance $upsSync.Id
I've tried running each line one at a time by just copying it directly into the shell window after defining the variables, and none of them give an error, but there has to be something the CA GUI does that I'm missing.
For anyone else that happens to come across this problem, have a look-see at this: http://www.harbar.net/archive/2010/10/30/avoiding-the-default-schema-issue-when-creating-the-user-profile.aspx
TL;DR When you create UPS through CA, it creates a dbo user and schema on the SQL server using the farm account, however when doing it through powershell it creates it with a schema and user named after the farm account, but still tries to manage SQL using the dbo schema, which of course fails terribly.
The workaround is to put my code into its own script file, and then use Start-Process to run the script as the farm account (it's a lot cleaner than the Job method described in the linked article):
$credential = Get-Credential ("$domain\spfarm", $SecureString)
Start-Process -FilePath powershell.exe -ArgumentList "-File C:\upsSync.ps1" -Credential $credential
in my company we still have Exchange 2003 with a MS domain 2003. I also have some member servers 2008 and I would like to run some powershell scripts from this last server.
I need to create a user which have 3 different email addreses SMTP.
I run this code to create the user
New-ADUser -SamAccountName $adpsID -Name $fmbName -Description
$fmbName -DisplayName $fmbName -UserPrincipalName $adpsID
-EmailAddress $fmbNameEmail -AccountPassword (ConvertTo-SecureString -AsPlainText "!$%&DF45DFG_" -Force) -Enabled $true -PasswordNeverExpires $false -Path $pathFMB
and I tried this to add an extra email...
Set-Mailbox -identity $fmbName -EmailAddresses -Description
"SMTP:$($fmbNameEmail)#$($domainFQDN)"
I get the following error:
Set-Mailbox : The term 'Set-Mailbox' 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.
searching in google I found how to query the exchange 2003 usin WMI object but I couldnt find how to add mailboxes with WMI.
is it possible? is there any way to do so?
thanks a lot in advance.
Jose
The Exchange Management Shell was first introduced in Exchange 2007 so all the scripts you have for 2007,2010,2013 will not work on 2013 you will need to start from scratch.
On Exchange 2003 the Exchange API to use for Management is CDOEXM (important if you want to Mail-Enable objects) this is Com library you get when you install the exchange 2003 system management tools .Or you can modify the Directory objects directly using LDAP via ADSI. WMI on 2003 is useful if you want to access management information like Mailbox sizes or MessageTracking logs or you need to reconnect a disconnected Mailbox.
Cheers
Glen