24/10/2016 Comments(0)

    Import External Contacts in Office 365

    CSV File Template

    Name FirstName LastName StreetAddress City StateorProvince PostalCode Phone MobilePhone Pager HomePhone Company Title
    Department CountryOrRegion Fax Initials Notes Office

    Connect Windows PowerShell on your local computer to the cloud-based service

    Click Start > All Programs > Accessories > Windows PowerShell > Windows PowerShell.

    Run the following command:

     $LiveCred = Get-Credential

     

    In the Windows PowerShell Credential Request window that opens, type the credentials of an account in your cloud-based organization. When you are finished, click OK.

    Run the following command:

    $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection

    Note:The AllowRedirection parameter enables cloud-based organizations in datacenters all over the world to connect Windows PowerShell to the cloud-based service by using the same URL.

    Run the following command:

    Import-PSSession $Session
    
    

    A progress indicator appears that shows the importing of commands used in the cloud-based service into the client-side session of your local computer. When this process is complete, you can run these commands.

    Disconnect Windows PowerShell from the cloud-based service

    When you’re finished using the server-side session, always disconnect Windows PowerShell by running the following command:

     Remove-PSSession <session variable>

    For example, to disconnect from the server-side session that is defined by the $Session variable, run the following command:

    Remove-PSSession $Session

    Important: If you close the Windows PowerShell window without disconnecting from the server-side session, your connection will remain open for 15 minutes. Your account can only have three connections to the server-side session at one time.

     

    How to import the necessary details of the CSV file

    import-csv .\contact.csv| %{new-mailcontact -name $_.name -displayname $_.displayname -externalemailaddress 
    $_.externalEmailAddress -firstname $_.firstname -lastname $_.lastname}

    Note: This will only import Name and Email address

     

    How to import additional information:

    import-csv <filename>.csv | %{set-contact $_.Name -mobilephone $_.MobilePhone -StreetAddress $_.StreetAddress -City 
    $_.City -StateorProvince $_.StateorProvince -PostalCode $_.PostalCode -Phone $_.Phone -MobilePhone $_.MobilePhone

     

    Leave a reply