Move Exchange mailboxes to O365 via PowerShell script

We are having a problem getting our scripting to work. We have to move 200-300 mailboxes (on a daily basis) to O365. This is an ongoing process. Currently we have over 700,000 mailboxes in the cloud. (Those numbers are correct.)
We want to automate this process by exporting the list of mailboxes from the EMC (2010) to a CSV file.  Then to run a PS script within an Azure Active Directory PowerShell.
Here is what we currently have ...
========================
$cred = Get-Credential
domain.com\<exchange-admin-account>
<password>
Import-Csv book1.csv | Select-Object -ExpandProperty `Alias' | foreach {New-MoveRequest -Remote -RemoteHostName 'webmail.domain.com' -RemoteCredential $cred -TargetDeliveryDomain 'service.domain.com' -verbose}
==============================
There is a 'disconnect between the first two pipe segments from the last pipe segment.
For example ... Import-Csv book1.csv | Select-Object -ExpandProperty 'Alias'  works well, and returns a list of the user alias' to the screen.
Most of the last pipe segment works well, also.
{New-MoveRequest -Remote -RemoteHostName 'webmail.domain.com' -RemoteCredential $cred -TargetDeliveryDomain 'service.domain.com' -verbose}     This portion work well for us.
The 'disconnect' is that the data from the first portion does not translate into the variable to the actual MoveRequest. 
Anyone have any ideas? What are we missing?
Thank you in advance.

Does it work if you remove 'foreach' and  { }, as in:
Import-Csv book1.csv | Select-Object -ExpandProperty Alias |
New-MoveRequest -Remote -RemoteHostName 'webmail.domain.com' `
-RemoteCredential $cred -TargetDeliveryDomain 'service.domain.com' `
-verbose
When you put the 'foreach' keyword on the right-hand side of a pipe (|), it sends each output object (in your example, alias names) to the code in between { } after the 'foreach' keyword. When the 'foreach' keyword is on the right-hand side of a pipe, it
is really an alias for 'ForEach-Object'.
If that does not work, then try it this way:
Import-Csv book1.csv | Select-Object -ExpandProperty Alias | foreach-object {
New-MoveRequest -Identity $_ -Remote -RemoteHostName 'webmail.domain.com' `
-RemoteCredential $cred -TargetDeliveryDomain 'service.domain.com' `
-verbose
In this case I am guessing that the alias from the CSV file would be the
-Identity parameter of New-MoveRequest, so you would have to substitute the correct parameter name if it's not
-Identity.
Bill

Similar Messages

  • Hit with Virus that executed via PowerShell Scripting. Can I disable Powershell on my network via Group Policy and what implications does that have for me.

    Our network was hit recently with virus previously unknown, O97M.Crigent.  It is a nasty Macro virus that targets Microsoft Office Documents & Spreadsheets and uses a combination of Macros and Scripts via Powershell. 
    How do I disable PowerShell scripting via Group Policy?
    Will this raise any issues such as random application or network failures or other issues?
    Can I apply it to the entire domain or should I be selective and only apply it to the workstations?
    Network Summary: Windows 2008 Active Directoy Server, 75% Windows 7, 25% Windows XP workstations.
    DouglasOfSanMarcos

    Disabling Windows PowerShell can be done with GPO:
    Computer Configuration | Administrative Templates | Windows Components | Windows PowerShell
    From GPO Description: "This setting exists under both "Computer Configuration" and "User Configuration" in the group policy editor. The "Computer Configuration" has precedence over "User Configuration."
    By default this option is restricted any way on computers.
    I would be very selective when apply it at all:
    Workstations - I would apply to test group of workstations first, just to see that there are no side effects before applying to all computers. 
    Server - I wouldn't apply it at all. I have seen too many issues when setting this policy on Exchange and other systems.
     If you are using a Group Policy to define a PowerShell logon, logoff or computer script, that script will disregard any execution policy set locally or through a GPO.
    http://4sysops.com/archives/set-powershell-execution-policy-with-group-policy/
    http://technet.microsoft.com/en-us/library/hh849812.aspx
    Please take a moment to Vote as Helpful and/or Mark as Answer where applicable. Thanks.

  • Exchange 2010 SP2 to SP3 Powershell script execution policies

    Hi,
    I have broken Labs when installing service packs on exchange 2010 servers because the powershell execution policies have been incorrectly configured. Once the WMI service has been stopped, the scripts within the SP haven't been able to start it up again. 
    I can't find any info on Powershell script execution policies in relation to the SP3 for 2010 prerequisites. Does anyone know what they should be set at? And why haven't these been at the top of the list of prerequisites for installations of service packs
    for exchange? 

    Hello,
    Come back and mark the replies as answers if they help and unmark them if they provide no help.
    I'm marking the reply as answer as there has been no update for a couple of days.
    If you come back to find it doesn't work for you, please reply to us and unmark the answer.
    Cara Chen
    TechNet Community Support

  • Calculate factorial via powershell scripting

    hello guys i written script until calculate the factorial via powershell but i do not know what does not work !
    function factorial( [int] $n ) 
        $result = 1; 
        if ( $n -gt 1 ) 
            $result = $n * ( factorial ( $n - 1 ) ) 
        $result 
    this function can not work with big number like that 999 how can i solve that problem?

    I get similar results, with a slightly different function. I get results up to at least 170. From 180 through at least 990 I get "Infinity" for the answer. At 999 I get your error, which I believe cannot be avoided. Even if you avoided the
    call depth error, PowerShell seems to refuse to deal with such large numbers, and simply outputs "Infinity".
    This article goes into factorials in depth:http://en.wikipedia.org/wiki/Factorial
    It includes a table for very large values, plus a formula for approximating factorials of large numbers. You might be able to code the approximation formula.
    Richard Mueller - MVP Directory Services

  • Can't access Modal dialog box via Powershell script

    Hi,
    I have a powershell script to login to an IE website and everything works fine excepting when I call a modal dialog box.  I've attached the line where the modula dialog is invoked.  When it gets to this part the script hangs and I'm unable
    to get past this.  I've googled a few articles where it suggests I should run an a scheduled task to scrape for the modal dialog box but I've tried it without much luck.  If you can please give me some pointers on resolving this issue. 
    Thnx
    Sue.
    $ie.Document.getElementsByTagName("button") | ? { $_.innerText -eq 'UNLOCK User' } | Select-Object -first 1 | % { $_.Click() }
    Sue

    Hi,
    I have a powershell script to login to an IE website and everything works fine excepting when I call a modal dialog box.  I've attached the line where the modula dialog is invoked.  When it gets to this part the script hangs and I'm unable
    to get past this.  I've googled a few articles where it suggests I should run an a scheduled task to scrape for the modal dialog box but I've tried it without much luck.  If you can please give me some pointers on resolving this issue. 
    Thnx
    Sue.
    $ie.Document.getElementsByTagName("button") | ? { $_.innerText -eq 'UNLOCK User' } | Select-Object -first 1 | % { $_.Click() }
    Sue

  • Strange behavior from script when dismounting content databases via PowerShell script

    So, this is my first time posting a question here.  I have taught myself PowerShell and for the most between friends, co-workers, or internet forums, I have been able to pick through most of the issues I have seen.  This one has me stuck. 
    So, a little background, I have a script that goes through each web app in a farm, finds the database that hosts the root site, and detaches all other content databases from the farm.  It also writes a csv file so that a process can come along after the
    fact to re-attach the databases.  I use this for patching so psconfig does not take quite as long as we have more than 50 content databases.  Here is the odd part.  After the first content database is detached, the second one is skipped, but
    the remainder are detached.  So, I have two databases left per web app.  One that holds the root site and whatever the second database is after the first detach.  If I comment out the line that actually does the detach, this does not happen. 
    Now, using ISE and adding break points, what I have found is that when I initially populate the array with the content databases ($var=$webapp.contentdatabase) all databases are in there.  When I start the foreach, all databases are in there.  Right
    up to the point that I detach the first database, all databases are still in the array variable.  As soon as I detach that database, the database that I detached gets removed from the array.  It does this even if I set the variable to read only. 
    It only happens with the first database detached in each web app.  I will try to explain this again with an example.  This test farm has 4 databases.  DB1, DB2, DB3, and DB4.  DB1 holds the root site.  The logic pulls the webapp info. 
    It gets the URL of the webapp.  It takes that info and finds the site collection with that name (the root site).  Finds the database name from there.  It then gets a list of all databases in the webapp and starts to loop through.  So the
    first one in the list is DB1.  It has the root site, so logic says do not delete.  It comes back to the loop with the next database DB2.  At this point, the array still has all 4 databases in the array.  DB2 does not host the root site,
    so the logic gathers information and calls dismount-spcontentdatabase.  As soon as that is called, that database is removed from the array.  So, at this point, we have processes postion 0 and position 1 in the array.  Since the original position
    1 has been removed, DB3 is now at postion 1.  So, the loop continues.  Sine we have now skipped DB3, we find DB4 and dismount.  Now, we have in the array DB1,DB3, and DB4.  My test environment has more and all are still there except for
    the first one removed.  I have banged my head against the desk with this one.  If someone has some insight, I would appreciate it.
    Here is the code that does it.
    get-spwebapplication | foreach-object {
     $webapp=$_
     $waname=$webapp.displayname
     $waurl=$webapp.url
     $cdbs=$webapp.contentdatabases
     $rsite=get-spsite $waurl -erroraction silentlycontinue
     $rsitedb=$rsite.contentdatabase
     $rsitedbn=$rsitedb.name
     foreach ($cdb in $cdbs) {
      $cdbs=$cdbs2
      $cdbname=$cdb.name
      #Write-Host "$cdbname" -foregroundcolor red
      if ($cdbname -ne $rsitedbn) {
       $warn=$cdb.warningsitecount
       $max=$cdb.maximumsitecount
       $current=$cdb.currentsitecount
       $dbserver=$cdb.server
       Write-output "$waname,$cdbname,$dbserver,$warn,$max,$current" >> $outfile
       Write-host "dismounting $cdbname" -foregroundcolor green
       dismount-spcontentdatabase -identity $cdbname -confirm:$false
      else {
       Write-host "$cdbname holds root site. No action." -foregroundcolor yellow

    what about keeping an array of all the non-root collections (may be database name) instead of dismounting them in the foreach loop of all the databases? After we have all the databases that need to be deleted, in a for loop starting with 0 and
    counting to the number of databases, check the name of the database for each index and dismount that database
    pseudo code would be
    $dbstobedismounted = @()
    foreach($cdb in $cdbs)
    $dbstobedismounted + = $cdb.Name  //instead of actually dismounting
    for(int i=0;i<$webapp.ContentDataBases.Count;i++)
    $dabasename = $webapp.ContentDataBases[i].Name
    foreach($dbtobedismounted in $dbstobedismounted)
    if($databasename -eq $dbtobedismounted )
    dismount-spcontentdatabase -dentty $webapp.ContentDataBases[i]
    I'm sure you might have to do some modifications to make it work, but the point I'm making is instead of dismounting in the foreach loop, have a list and dismount in another for loop. Hope it helps.
    rani

  • Add a config item to windows computer via powershell script

    Hello All
    I am looking for a script which will add a config item into windows computer . I have some thing like this which will add the configuration item into an incident . But I want to add to a computer record in all windows computer. I think I am failing to find
    the source for windows computer records
    $incident    
    = get-scsmclass
    m.incident$ |get-scsmobject
    -filter "DisplayName -eq 'IR8 - test'"
    $computer    
    = get-scsmclass
    Microsoft.Windows.Computer$|get-scsmobject
    -filter "PrincipalName -eq 'test'"
    $relationship
    = Get-SCSMRelationshipClass
    -name System.WorkItemAboutConfigItem
    New-SCSMRelationshipObject
    -Relationship $relationship
    -Source $incident
    -Target $computer
    -bulk

    I really don't understand what your are trying to do. do you want to add a new windows computer object to the database, or add an existing windows computer object to the list of related items on a work item? 
    if you are trying to create a windows computer by hand, i would recommend against it. there are much easier ways to get that data from SCCM or AD via connectors. maybe you could elaborate on your need?
    If you are trying to relate an existing windows computer to a work item, then your script is correct. you just need to get the computer object in one hand, the work item in the other and mash them together with a New-SCSMRelationship around the correct Relationship
    class. remember that About (System.WorkItemAboutConfigItem) is for the Affected config item, where as Relates (System.WorkItemRelatesToConfigItem) is for the related config items. an arrow affects the target and is related to the archer; don't get them confused.
    the only other interpretation (and the one i find least likely) is that you are trying to relate two computers together, in which case the script is still correct, except, obviously, the relationship class should be System.ConfigItemRelatesToConfigItem,
    and you would need to get a windows computer in each hand. 

  • Uninstalled a program via PowerShell script, but it still shows up in Programs and Features

    I wrote a script that uninstalls a program just fine, but it still shows up in Programs and Features due to its entries still existing in the Registry. 
    Here is a portion of my script:
    Start-Process
    -FilePath MsiExec
    -ArgumentList "/X$($MyProgram.ProdID)",
    '/quiet'
    -NoNewWindow -Wait
    -PassThru 
    I believe the reason it is still showing up in Programs and Features is because I am missing some MsiExec switch to instruct it to be removed. I vaguely recall dealing with this about two years ago and I wrote a script that did exactly this, but now I completely
    forgot what it was. 
    Can someone help me out here, please?
    Thank you

    I realize that, but honestly don't know where else to submit a question like this in the forums? Also, the vendor is Microsoft. What I am trying to uninstall is any Forefront component, because when I deployed the SCEP client via SCCM 2012 the SCEP client
    was not able to uninstall some of the Forefront components. 
    Here is my script:
    $NewLine = "`r`n"
    $NewLine
    Write-Output "Please wait ..."
    #region ---------- Declare WMI Variables to be Used ----------
    $CM12R2ClientInstalled = Get-WmiObject -Class Win32_Product |
    Where-Object -FilterScript { $_.Name -eq "Configuration Manager Client" -and $_.Version -ge "5.00.7958.1000" }
    $FCSInstalled = Get-WmiObject -Class Win32Reg_AddRemovePrograms |
    Where-Object -FilterScript { $_.DisplayName -match "Forefront" }
    $SCEPInstalled = Get-WmiObject -Class Win32Reg_AddRemovePrograms |
    Where-Object -FilterScript { $_.DisplayName -eq "System Center Endpoint Protection" }
    #endregion ---------- Declare Variables to be Used ----------
    #region --------- Check if the SCCM 2012 R2 Client is Installed ---------
    $CM12ClientService = Get-Service -Name CcmExec
    If (($CM12R2ClientInstalled -ne $null) -and ($CM12ClientService -ne $null))
    $NewLine
    Write-Output "The $($CM12R2ClientInstalled.Name) $($CM12R2ClientInstalled.Version) is installed on $($env:COMPUTERNAME)"
    #endregion --------- Check if the SCCM 2012 R2 Client is Installed ---------
    #region -------- Uninstall any Forefront Component if any are Installed ---------
    If ($FCSInstalled)
    $NewLine
    Write-Output "The following Forefront component(s) are installed on $($env:COMPUTERNAME):"
    $NewLine
    $FCSInstalled.DisplayName
    Foreach ($FCS in $FCSInstalled)
    $NewLine
    Write-Output "Preparing to uninstall $($FCS.DisplayName)"
    $UninstallFCS = Start-Process -FilePath MsiExec -ArgumentList "/X$($FCS.ProdID)", 'REMOVEDATA=1' -NoNewWindow -Wait -PassThru
    If ($($UninstallFCS.ExitCode) -eq '0')
    $NewLine
    Write-Output "$($FCS.DisplayName) uninstalled successfully!"
    $NewLine
    #endregion -------- Uninstall any Forefront Component if any are Installed ---------
    #region --------- Install the SCEP Client if it is Not Installed ----------
    If ($SCEPInstalled -eq $null)
    $NewLine
    Write-Output "The System Center Endpoint Protection client is not installed on $($env:COMPUTERNAME)"
    $InstallSCEP = Start-Process -FilePath "C:\Windows\ccmsetup\SCEPInstall.exe" -ArgumentList '/s', '/q', '/NoSigsUpdateAtInitialExp', '/policy "C:\Windows\CCM\EPAMPolicy.xml"' -NoNewWindow -Wait -PassThru
    If ($($InstallSCEP.ExitCode) -eq '0')
    $NewLine
    Write-Output "System Center Endpoint Protection installed successfully!"
    $NewLine
    Else
    $NewLine
    Write-Warning -Message "System Center Endpoint Protection failed to install on $($env:COMPUTERNAME) with exit error: $($InstallSCEP.ExitCode)"
    $NewLine
    #endregion --------- Install the SCEP Client if it is Not Installed ----------
    Else
    $NewLine
    Write-Output "The System Center Endpoint Protection client is already installed on $($env:COMPUTERNAME)!"
    $NewLine
    Else
    $NewLine
    Write-Warning -Message "$($FCS.DisplayName) failed to uninstall on $($env:COMPUTERNAME) with exit error: $($UninstallFCS.ExitCode)"
    $NewLine
    Else
    $NewLine
    Write-Output "No Forefront components are installed on $($env:COMPUTERNAME)!"
    #region ---------- Install the SCEP Client if it is NOT Installed ----------
    If ($SCEPInstalled -eq $null)
    $NewLine
    Write-Output "The System Center Endpoint Protection client is not installed on $($env:COMPUTERNAME)"
    $InstallSCEP = Start-Process -FilePath "C:\Windows\ccmsetup\SCEPInstall.exe" -ArgumentList '/s', '/q', '/NoSigsUpdateAtInitialExp', '/policy "C:\Windows\CCM\EPAMPolicy.xml"' -NoNewWindow -Wait -PassThru
    If ($($InstallSCEP.ExitCode) -eq '0')
    $NewLine
    Write-Output "System Center Endpoint Protection installed successfully!"
    $NewLine
    Else
    $NewLine
    Write-Warning -Message "System Center Endpoint Protection failed to install on $($env:COMPUTERNAME) with exit error: $($InstallSCEP.ExitCode)"
    $NewLine
    #endregion --------- Install the SCEP Client if it is Not Installed ----------
    Else
    $NewLine
    Write-Output "The System Center Endpoint Protection client is already installed on $($env:COMPUTERNAME)!"
    $NewLine
    Else
    $NewLine
    Write-Output "The System Center Configuration Manager 2012 R2 client is not installed on $($env:COMPUTERNAME)!"
    $NewLine

  • Change "Update distribution points on a schedule" in SCCM 2007 via powershell script

    Hi
    I would like to change the Custom Schedule start time in the "Update distribution points on a schedule" on a package in SCCM 2007 with out logging into the SCCM console.
    I have following line code to query the package.
    Get-WmiObject
    -Namespace
    "Root\SMS\Site_$sitecode"
    -Query
    "SELECT * FROM SMS_PackageBaseclass WHERE PackageID='$PackageID'"
    -ComputerName $ServerName
    The problem is I only get the "SourceDate" and "LastRefreshedTime" from the query. I am not sure if I change the "LastRefreshTime" that it would change the start time in the Custom Schedule

    Hi Jason
    I progressed a little bit with you help. I now have the following bit of code.
    $Package = Get-WmiObject  -class SMS_Package -Namespace "Root\SMS\Site_$sitecode" -Filter "PackageID='$PackageID'" -ComputerName $ServerName
    $RefreshPkg = $Package.RefreshSchedule()
    $RefreshPkg.RefreshSchedule
    I get the following error:
    Method invocation failed because [System.Management.ManagementObject] doesn't contain a method named 'RefreshSchedule'.
    At line:7 char:1
    + $RefreshPkg = $Package.RefreshSchedule()
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (RefreshSchedule:String) [], RuntimeException
        + FullyQualifiedErrorId : MethodNotFound

  • Exchange PowerShell script to get mailbox properties of user from a CSV file

    Hi Team,
    I've a CSV file with alias of numerous users and I want to get their mailbox sizes and other properties. These users are dispersed in various databases of same Exchange organization.
    Need a Powershell Script, Any help?
    Muhammad Nadeem Ahmed Sr System Support Engineer Premier Systems (Pvt) Ltd T. +9221-2429051 Ext-226 F. +9221-2428777 M. +92300-8262627 Web. www.premier.com.pk

    You can use this and modify it to what you need. Output to a file (IE: Export-CSV "path to file"
    If you need more specifics let me know. This one is for one user at a time but can be used to read a CSV file.
    # Notifies the user a remote session needs to be started
    Write-Host "Get a users mailbox size" -fore yellow -back red;
    Write-Host "Please wait while a remote session started" -fore red -back yellow;
    # Import a remote session with exchange
    $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://exchangeservername/Powershell/ -Authentication Kerberos
    Import-PSSession $Session
    Do {
    # Prompts user for a name
    $name = Read-Host "Enter a username"
    # Get the mailbox statistics for that user
    Get-MailboxStatistics $name | fl totalitemsize, storagelimitstatus, totaldeleteditemsize | out-default
    # Give the user a choice to test another or EXIT
    $Output = Read-Host "Press Y to continue or ENTER to exit"
    # Ends the program if the user does not press Y
    Until ($Output -ne "Y")
    HossFly, Exchange Administrator

  • Powershell script to update mailbox search

    I am trying to update a mailbox search using a powershell script:
    Stop-MailboxSearch -Identity "LitHolds" -confirm:$false
    $members = (import-csv -Path "Path"| ForEach-Object{$_.SamAccountName})
    foreach ($user in $members)
    Set-MailboxSearch -Identity "LitHolds" -SourceMailboxes $user.samaccountname
    Start-MailboxSearch -Identity "LitHolds" -confirm:$false
    I essentially have our sysadmins populating a csv file and then they run this script manually every night with the latest updates.  They are telling me that the mailbox search is empty.
    When I run the script I am getting a watson error immediately after with the following:
    WARNING: An unexpected error has occurred and a Watson dump is being generated: Value cannot be null.
    Parameter name: legacyDN
    Value cannot be null.
    Parameter name: legacyDN
        + CategoryInfo          : NotSpecified: (:) [Stop-MailboxSearch], ArgumentNullException
        + FullyQualifiedErrorId : System.ArgumentNullException,Microsoft.Exchange.Management.Tasks.StopMailboxSearch
        + PSComputerName        : Exchange Server Name
    What I don't understand is why it's looking for a legacyDN??
    Anyone able to do something similar?
    Chuck

    Hi Chuck,
    I would like to verify if you have a legacy Exchange.
    The LegacyDN property indicates the legacyDN of the mailbox and matches the legacyExchangeDN attribute of the user object in  Microsoft Active Directory.
    If there is any update, please feel free to let me know.
    Best regards,
    Amy
    Amy Wang
    TechNet Community Support

  • Powershell script for mailbox permissions

    Hello,
    Part of my tasks as an Exchange admin is to give access to shared mailboxes. The access usually are:
    Send AS
    Receive As
    Send on Behalf Of
    Full mailbox
    Is there a powershell script out there that does all of the above?
    thanks,
    Alexis

    Hi,
    Probably not prewritten, but you can check the repository for starters:
    http://gallery.technet.microsoft.com/scriptcenter
    EDIT: I should mention - this isn't too hard to write, so this could be a good opportunity to learn how to get around in the EMS.
    Don't retire TechNet! -
    (Don't give up yet - 12,830+ strong and growing)

  • Trying to Migrate a Mailbox to O365

    Hello.  I don't know much about scripting or PowerShell but I'm having troubles getting something to work and I'm hoping that someone might help me out.  I am running O365 in a hybrid config with my on premise Exchange 2010 server.  Because I'd
    like to keep my on premise Exchange server and my local domain controllers, I was told elsewhere that, to create new accounts, I have to create them locally, migrate them up to Office 365 and then assign an O365 license to them.  That is how I have been
    creating all of my new users and shared mailboxes in the 6 months or so that we have been using O365.  I have begun dabbling with PowerShell and I'd like to find a way to automate the mailbox creation a bit.  I have figured out how to create a new
    local mailbox and set all necessary properties on it but I would also like to be able to migrate it up to O365 via PowerShell and that's the part that I'm having trouble with.  Here's what I have so far:
    New-Mailbox -Name JustaTest -Alias JustaTest -OrganizationalUnit "mydomain.com/My OU" -Database "Mailboxes" -UserPrincipalName [email protected] -Shared
    Add-MailboxPermission JustaTest -User "MyDomain\Me" -AccessRights FullAccess
    Add-ADPermission JustaTest -User "MyDomain\Me" -ExtendedRights Send-As
    Set-Mailbox "JustaTest" -EmailAddresses SMTP:[email protected],[email protected]
    $UserCredential = Get-Credential
    $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
    Import-PSSession $Session
    New-MoveRequest -Identity “JustaTest” -Remote -RemoteHostName “localmailserver.mydomain.com” -TargetDeliveryDomain mydomain.mail.onmicrosoft.com -RemoteCredential $Session
    The first 4 lines work great but the problems begin when I get to the move request.  I'm getting this when it gets to that part:
    C:\Windows\system32>New-MoveRequest -Identity "JustaTest" -Remote -RemoteHostName "localmailserver.mydomain.com" -TargetDeliveryDomain mydomain.mail.onmicrosoft.com -RemoteCredential $Session
    Cannot process argument transformation on parameter 'RemoteCredential'. Cannot convert the "System.Management.Automation.Runspaces.PSSession" value of type "Deserialized.System.Management.Automation.Runspaces.PSSession" to type "System.Management.Automation.PSCredential".
        + CategoryInfo          : InvalidData: (:) [New-MoveRequest], ParameterBindin...mationException
        + FullyQualifiedErrorId : ParameterArgumentTransformationError,New-MoveRequest
        + PSComputerName        : localmailserver.mydomain.com
    Any assistance that can be provided would be very much appreciated.
    Thanks in advance.
    -Chris

    Hi Chris,
    You passing the PSSession object ($Session ) to -RemoteCredential.
    Aren't you suppose to Pass the Admin credential object here ($UserCredential )
    Incorrect:New-MoveRequest -Identity "JustaTest" -Remote -RemoteHostName "localmailserver.mydomain.com" -TargetDeliveryDomain mydomain.mail.onmicrosoft.com -RemoteCredential $Session
    Corrected:
    New-MoveRequest -Identity "JustaTest" -Remote -RemoteHostName "localmailserver.mydomain.com" -TargetDeliveryDomain mydomain.mail.onmicrosoft.com -RemoteCredential $UserCredentialorGet-Mailbox -Identity "JustaTest" | New-MoveRequest -Remote -RemoteHostName localmailserver.mydomain.com -RemoteCredential $UserCredential -TargetDeliveryDomain "mydomain.mail.onmicrosoft.com"
    How about we validate the below points as well. Like is Get-Mailbox working on remote or not.
    After Step 4, the
    Exchange Online cmdlets are imported into your local Windows PowerShell session as tracked by a progress bar. If you don’t receive any errors, you connected successfully.
    A quick test is to run an Exchange Online cmdlet—for example, Get-Mailbox—and see the results.
    If you receive errors, check the following requirements:
    A common problem is an incorrect password. Run the three steps again and pay close attention to the user name and password you enter in Step 1.
    To help prevent denial-of-service (DoS) attacks, you're limited to three open remote PowerShell connections to your Exchange Online organization.
    Windows PowerShell needs to be configured to run scripts. You only need to configure this setting once on your computer, not every time you connect. To enable Windows PowerShell to run signed scripts, run the following command in an elevated Windows PowerShell
    window (a Windows PowerShell window you opened by selecting Run as administrator).
    Set-ExecutionPolicy RemoteSigned
    The account you use to connect to Exchange Online must be enabled for remote Shell. For more information, see
    Manage remote PowerShell access in Exchange Online.
    TCP port 80 traffic needs to be open between your local computer and Exchange Online. It's probably open, but it’s something to consider if your organization has a restrictive Internet access policy.
    Best way to learn PowerShell is to track the PS cmdlets used while doing it in EAC. Check out this wiki which should be applicable for O365 as well
    Exchange Admin Center Cmdlet Logging In Exchange Server 2013 SP1
    References:
    Hybrid Mailbox moves and EMC changes
    Error in Moving Mailboxes to O365
    Regards,
    Satyajit
    Please “Vote As Helpful”
    if you find my contribution useful or “Mark As Answer” if it does answer your question. That will encourage me - and others - to take time out to help you.

  • Powershell Script to Enable and Disable SharePoint list versioning

    Hi,
    We have a Sharepoint list with a date and time field named 'Today' which we update overnight
    via PowerShell script to give the current date and this recalculates other calculated fields
    in the list.
    All is fine but we have versioning enabled on the list and so we get a new version created everyday.
    Is there a way to disable the versioning prior to running the update and then re-enable
    after?
    This is the script
    Add-PSSnapin Microsoft.SharePoint.PowerShell
    Start-SPAssignment -Global
    $SPWeb = Get-SPWeb "<SharePointSiteUrl>"
    $List = $SPWeb.Lists["ListName"]
    $Items = $List.Items
    foreach ($item in $items)
     $modifiedBy = $item["Editor"]
     $modified = $item["Modified"]
     $item["Today"] = Get-Date
     $item["Editor"] = $modifiedBy
     $item["Modified"] = $modified
     $item.Update()
     $list.Update()
    $SPWeb.Dispose()
    Stop-SPAssignment -Global  

    Hi
    Here is a quick powershell script to iterate a site collection and remove versioning on all list of base-type Document Library. Also the iteration removes all the current versions of list items. Great for freeing up space and also to make publishing sites
    a little more easy to manage content for trusted content approvers!
    Check the below powershell script
    [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
    # Get site
    $site = new-object Microsoft.SharePoint.SPSite("http://YoServer:1002")
    # Iterate all the webs of the site
    foreach ($web in $site.AllWebs)
    # loop through all lists in web
    foreach ($list in $web.Lists)
    # Ensure list is of base Document Library
    if ($list.BaseType -ne "DocumentLibrary")
    # Move on
    continue
    # Loop through each item
    foreach ($item in $list.Items)
    # Get the file
    $file = $item.File
    # Delete all versions
    $file.Versions.DeleteAll()
    # Remove version from the list
    $list.EnableVersioning = $false
    $list.EnableModeration = $false
    # We still want to ensure check out
    $list.ForceCheckout = $true
    $list.Update()
    $web.Dispose();
    $site.Dispose();
    Please mark the Answer and Vote me if you think that it will help you to resolved your issue

  • Execute PowerShell Scripts via SAP NetWeaver Identity Management

    Hello,
    Has anyone implemented the execution of a PowerShell script from SAP NetWeaver Identity Management (7.1, 7.2, 8.0?).  Currently implementing 8.0, and our client is looking to kick off PowerShell scripts that would generate Active Directory accounts, Exchange accounts etc.
    Thanks!

    Hey Brendan,
    We've done this out of a 7.2 implementation for exchange 2010 admin processes.  We started with running powershell via a command line pass.  It worked pretty well but it wasn't plain sailing.  We used positional parameters to pass data to the scripts in question, we also had to come up with a return process that deals with any errors that might come of the powershell session.  We had some issues with the shell sessions closing after the script completed.
    We've since redesigned and now drop flat files to a constantly running powershell script that acts a bit like an IDM dispatcher (but obviously not integrated with IDM).  It kicks off other powershell sessions and monitors their progress allowing it to process time outs, stack work up, etc.
    We also found timing the processes to be an issue.  If you create an AD account in IDM and then try to immediately move onto mailbox enable (for example) the account we created wasn't yet replicated to exchange so we had to build wait time into various parts of the process.
    Thanks,
    Pete.

Maybe you are looking for

  • ITunes deletes genius data on startup

    I'm runnung Itunes 11.1.2 on Windows Vista and syncing with an iPod, iPad, and iPhone.  Each time I start iTunes its like it was the first time - agree to the licence agreement, watch the video, but worst of all, it deletes all Genius data and turns

  • Can't get to work the Audigy 2 0

    Hello, I just bought an Audigy 2 sound card. It looks like Audigy 2 ZS, it has black PCB and gold connectors. I've got it without any drivers. I've got only a midi gameport. I read on PCB the version number 0240. I googled that it could be the the pl

  • I am purchasing new 13in MacBook Pro.. Need info on Video editing

      I am Purchasing a new MacBook Pro 13 2.5 Dual Core i5 with 8GB of Ram. My work is buying this so I get what I am getting.  I will be uploading Sporting events and editing them into 2 to 3 minute Highlight Videos. Should I use Imovie or Final cut Pr

  • Passing values from JTextField to another class

    Hi, I have 2 classes...one is main and the other is a RequestForm class which is instantiated by main class using RequestForm application =new RequestForm(); the constructor for the RequestForm displays the form in which the users enters his/her pers

  • All Time Machine dates are white, no pink.  How can I be sure data is backed up on Time Capsule, not just on iMac itself?

    Apple support http://support.apple.com/kb/PH4256 says "If you back up to a Time Capsule or other network disk, a message briefly appears while Time Machine connects your computer to the backup disk."    When I enter Time Machine on my iMac (OS 10.6.8